[libvirt] [PATCH] conf: Fix initialization value of 'multi' in PCI address

The 'multi' element in PCI address struct used as 'virTristateSwitch', and its default value is 'VIR_TRISTATE_SWITCH_ABSENT'. Current PCI process use 'false' to initialization 'multi', which is ambiguously for assignment or comparison. This patch use '{0}' to initialize the whole PCI address struct, which fix the 'multi' initialization and makes code more simplify and explicitly. Signed-off-by: Xian Han Yu <xhyubj@linux.vnet.ibm.com> --- src/conf/domain_addr.c | 2 +- src/conf/node_device_conf.c | 2 +- src/qemu/qemu_domain_address.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index a0c2f88..cf6b73d 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -569,7 +569,7 @@ virDomainPCIAddressGetNextSlot(virDomainPCIAddressSetPtr addrs, /* default to starting the search for a free slot from * the first slot of domain 0 bus 0... */ - virPCIDeviceAddress a = { 0, 0, 0, 0, false }; + virPCIDeviceAddress a = {0}; char *addrStr = NULL; if (addrs->nbuses == 0) { diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index a23d8ef..c8e30d9 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1163,7 +1163,7 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContextPtr ctxt, goto cleanup; for (i = 0; i < nAddrNodes; i++) { - virPCIDeviceAddress addr = { 0, 0, 0, 0, 0 }; + virPCIDeviceAddress addr = {0}; if (virPCIDeviceAddressParseXML(addrNodes[i], &addr) < 0) goto cleanup; if (VIR_ALLOC(pciAddr) < 0) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 3d52d72..bb16738 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1096,7 +1096,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def, /* USB2 needs special handling to put all companions in the same slot */ if (IS_USB2_CONTROLLER(def->controllers[i])) { - virPCIDeviceAddress addr = { 0, 0, 0, 0, false }; + virPCIDeviceAddress addr = {0}; bool foundAddr = false; memset(&tmp_addr, 0, sizeof(tmp_addr)); -- 2.5.5

Ping... On 8/15/2016 12:22 PM, Xian Han Yu wrote:
The 'multi' element in PCI address struct used as 'virTristateSwitch', and its default value is 'VIR_TRISTATE_SWITCH_ABSENT'. Current PCI process use 'false' to initialization 'multi', which is ambiguously for assignment or comparison. This patch use '{0}' to initialize the whole PCI address struct, which fix the 'multi' initialization and makes code more simplify and explicitly.
Signed-off-by: Xian Han Yu <xhyubj@linux.vnet.ibm.com> --- src/conf/domain_addr.c | 2 +- src/conf/node_device_conf.c | 2 +- src/qemu/qemu_domain_address.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index a0c2f88..cf6b73d 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -569,7 +569,7 @@ virDomainPCIAddressGetNextSlot(virDomainPCIAddressSetPtr addrs, /* default to starting the search for a free slot from * the first slot of domain 0 bus 0... */ - virPCIDeviceAddress a = { 0, 0, 0, 0, false }; + virPCIDeviceAddress a = {0}; char *addrStr = NULL;
if (addrs->nbuses == 0) { diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index a23d8ef..c8e30d9 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1163,7 +1163,7 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContextPtr ctxt, goto cleanup;
for (i = 0; i < nAddrNodes; i++) { - virPCIDeviceAddress addr = { 0, 0, 0, 0, 0 }; + virPCIDeviceAddress addr = {0}; if (virPCIDeviceAddressParseXML(addrNodes[i], &addr) < 0) goto cleanup; if (VIR_ALLOC(pciAddr) < 0) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 3d52d72..bb16738 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1096,7 +1096,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
/* USB2 needs special handling to put all companions in the same slot */ if (IS_USB2_CONTROLLER(def->controllers[i])) { - virPCIDeviceAddress addr = { 0, 0, 0, 0, false }; + virPCIDeviceAddress addr = {0}; bool foundAddr = false;
memset(&tmp_addr, 0, sizeof(tmp_addr));

Ping On 8/15/2016 12:22 PM, Xian Han Yu wrote:
The 'multi' element in PCI address struct used as 'virTristateSwitch', and its default value is 'VIR_TRISTATE_SWITCH_ABSENT'. Current PCI process use 'false' to initialization 'multi', which is ambiguously for assignment or comparison. This patch use '{0}' to initialize the whole PCI address struct, which fix the 'multi' initialization and makes code more simplify and explicitly.
Signed-off-by: Xian Han Yu <xhyubj@linux.vnet.ibm.com> --- src/conf/domain_addr.c | 2 +- src/conf/node_device_conf.c | 2 +- src/qemu/qemu_domain_address.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index a0c2f88..cf6b73d 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -569,7 +569,7 @@ virDomainPCIAddressGetNextSlot(virDomainPCIAddressSetPtr addrs, /* default to starting the search for a free slot from * the first slot of domain 0 bus 0... */ - virPCIDeviceAddress a = { 0, 0, 0, 0, false }; + virPCIDeviceAddress a = {0}; char *addrStr = NULL;
if (addrs->nbuses == 0) { diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index a23d8ef..c8e30d9 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1163,7 +1163,7 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContextPtr ctxt, goto cleanup;
for (i = 0; i < nAddrNodes; i++) { - virPCIDeviceAddress addr = { 0, 0, 0, 0, 0 }; + virPCIDeviceAddress addr = {0}; if (virPCIDeviceAddressParseXML(addrNodes[i], &addr) < 0) goto cleanup; if (VIR_ALLOC(pciAddr) < 0) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 3d52d72..bb16738 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1096,7 +1096,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
/* USB2 needs special handling to put all companions in the same slot */ if (IS_USB2_CONTROLLER(def->controllers[i])) { - virPCIDeviceAddress addr = { 0, 0, 0, 0, false }; + virPCIDeviceAddress addr = {0}; bool foundAddr = false;
memset(&tmp_addr, 0, sizeof(tmp_addr));

On Mon, Aug 15, 2016 at 06:22:25AM +0200, Xian Han Yu wrote:
The 'multi' element in PCI address struct used as 'virTristateSwitch', and its default value is 'VIR_TRISTATE_SWITCH_ABSENT'. Current PCI process use 'false' to initialization 'multi', which is ambiguously for assignment or comparison. This patch use '{0}' to initialize the whole PCI address struct, which fix the 'multi' initialization and makes code more simplify and explicitly.
Signed-off-by: Xian Han Yu <xhyubj@linux.vnet.ibm.com> --- src/conf/domain_addr.c | 2 +- src/conf/node_device_conf.c | 2 +- src/qemu/qemu_domain_address.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
ACK, I'll push it after release since there's no bug that's fixed by this commit. Martin

On 9/2/2016 9:18 PM, Martin Kletzander wrote:
On Mon, Aug 15, 2016 at 06:22:25AM +0200, Xian Han Yu wrote:
The 'multi' element in PCI address struct used as 'virTristateSwitch', and its default value is 'VIR_TRISTATE_SWITCH_ABSENT'. Current PCI process use 'false' to initialization 'multi', which is ambiguously for assignment or comparison. This patch use '{0}' to initialize the whole PCI address struct, which fix the 'multi' initialization and makes code more simplify and explicitly.
Signed-off-by: Xian Han Yu <xhyubj@linux.vnet.ibm.com> --- src/conf/domain_addr.c | 2 +- src/conf/node_device_conf.c | 2 +- src/qemu/qemu_domain_address.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
ACK, I'll push it after release since there's no bug that's fixed by this commit.
Martin
OK, thanks : ) Xian Han
participants (2)
-
Martin Kletzander
-
Xian Han Yu