[libvirt] [PATCH] Fix gcc 4.6 warnings

gcc 4.6 warns when a variable is initialized but isn't used afterwards: vmware/vmware_driver.c:449:18: warning: variable 'vmxPath' set but not used [-Wunused-but-set-variable] This patch fixes these warnings. There are still 2 offending files: - vbox_tmpl.c: the variable is used inside an #ifdef and is assigned several times outside of #ifdef. Fixing the warning would have required wrapping all the assignment inside #ifdef which hurts readability. vbox/vbox_tmpl.c: In function 'vboxAttachDrives': vbox/vbox_tmpl.c:3918:22: warning: variable 'accessMode' set but not used [-Wunused-but-set-variable] - esx_vi_types.generated.c: the name implies it's generated code and I didn't want to dive into the code generator esx/esx_vi_types.generated.c: In function 'esxVI_FileQueryFlags_Free': esx/esx_vi_types.generated.c:1203:3: warning: variable 'item' set but not used [-Wunused-but-set-variable] --- src/nwfilter/nwfilter_ebiptables_driver.c | 7 +++---- src/util/logging.c | 3 +-- src/vmware/vmware_driver.c | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c index 6c9c470..977f74b 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -1634,7 +1634,7 @@ iptablesCreateRuleInstanceStateCtrl(virNWFilterDefPtr nwfilter, bool isIPv6) { int rc; - int directionIn = 0, directionOut = 0; + int directionIn = 0; char chainPrefix[2]; bool maySkipICMP, inout = false; char *matchState = NULL; @@ -1643,9 +1643,8 @@ iptablesCreateRuleInstanceStateCtrl(virNWFilterDefPtr nwfilter, if ((rule->tt == VIR_NWFILTER_RULE_DIRECTION_IN) || (rule->tt == VIR_NWFILTER_RULE_DIRECTION_INOUT)) { directionIn = 1; - directionOut = inout = (rule->tt == VIR_NWFILTER_RULE_DIRECTION_INOUT); - } else - directionOut = 1; + inout = (rule->tt == VIR_NWFILTER_RULE_DIRECTION_INOUT); + } chainPrefix[0] = 'F'; diff --git a/src/util/logging.c b/src/util/logging.c index 9d18752..bb3ba13 100644 --- a/src/util/logging.c +++ b/src/util/logging.c @@ -389,7 +389,7 @@ static void virLogDumpAllFD(const char *msg, int len) { void virLogEmergencyDumpAll(int signum) { int len; - int oldLogStart, oldLogLen, oldLogEnd; + int oldLogStart, oldLogLen; switch (signum) { #ifdef SIGFPE @@ -444,7 +444,6 @@ virLogEmergencyDumpAll(int signum) { * so it's best to reset it first. */ oldLogStart = virLogStart; - oldLogEnd = virLogEnd; oldLogLen = virLogLen; virLogEnd = 0; virLogLen = 0; diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index b5e416b..bbfb1a4 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -467,7 +467,7 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags ATTRIBUTE_UNUSED) } vmwareSetSentinal(cmd, vmw_types[driver->type]); - vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath); + vmwareSetSentinal(cmd, vmxPath); if (vm->state != VIR_DOMAIN_RUNNING) { -- 1.7.4.4

On Thu, Apr 14, 2011 at 11:22:35AM +0200, Christophe Fergeau wrote:
- vbox_tmpl.c: the variable is used inside an #ifdef and is assigned several times outside of #ifdef. Fixing the warning would have required wrapping all the assignment inside #ifdef which hurts readability.
On second thoughts, most of the #ifdef are already there, so it's not too ugly to fix this one too, patch to follow. Christophe

--- src/vbox/vbox_tmpl.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 0fbfba5..a7d78df 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -3915,7 +3915,9 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) PRUnichar *mediumFileUtf16 = NULL; PRUint32 storageBus = StorageBus_Null; PRUint32 deviceType = DeviceType_Null; +# if VBOX_API_VERSION >= 4000 PRUint32 accessMode = AccessMode_ReadOnly; +#endif PRInt32 deviceInst = 0; PRInt32 devicePort = 0; PRInt32 deviceSlot = 0; @@ -3924,24 +3926,27 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) { deviceType = DeviceType_HardDisk; - accessMode = AccessMode_ReadWrite; # if VBOX_API_VERSION < 4000 data->vboxObj->vtbl->FindHardDisk(data->vboxObj, mediumFileUtf16, &medium); +#else + accessMode = AccessMode_ReadWrite; # endif } else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM) { deviceType = DeviceType_DVD; - accessMode = AccessMode_ReadOnly; # if VBOX_API_VERSION < 4000 data->vboxObj->vtbl->FindDVDImage(data->vboxObj, mediumFileUtf16, &medium); +#else + accessMode = AccessMode_ReadOnly; # endif } else if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) { deviceType = DeviceType_Floppy; - accessMode = AccessMode_ReadWrite; # if VBOX_API_VERSION < 4000 data->vboxObj->vtbl->FindFloppyImage(data->vboxObj, mediumFileUtf16, &medium); +#else + accessMode = AccessMode_ReadWrite; # endif } else { VBOX_UTF16_FREE(mediumFileUtf16); -- 1.7.4.4

2011/4/14 Christophe Fergeau <cfergeau@redhat.com>:
--- src/vbox/vbox_tmpl.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 0fbfba5..a7d78df 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -3915,7 +3915,9 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) PRUnichar *mediumFileUtf16 = NULL; PRUint32 storageBus = StorageBus_Null; PRUint32 deviceType = DeviceType_Null; +# if VBOX_API_VERSION >= 4000 PRUint32 accessMode = AccessMode_ReadOnly; +#endif PRInt32 deviceInst = 0; PRInt32 devicePort = 0; PRInt32 deviceSlot = 0; @@ -3924,24 +3926,27 @@ vboxAttachDrives(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine)
if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_DISK) { deviceType = DeviceType_HardDisk; - accessMode = AccessMode_ReadWrite; # if VBOX_API_VERSION < 4000 data->vboxObj->vtbl->FindHardDisk(data->vboxObj, mediumFileUtf16, &medium); +#else
This else is not indented properly. make syntax-check should have caught that if you have cppi installed.
+ accessMode = AccessMode_ReadWrite; # endif
ACK. If fixed the minor indentation errors and pushed the result. Matthias

2011/4/14 Christophe Fergeau <cfergeau@redhat.com>:
gcc 4.6 warns when a variable is initialized but isn't used afterwards:
vmware/vmware_driver.c:449:18: warning: variable 'vmxPath' set but not used [-Wunused-but-set-variable]
This patch fixes these warnings. There are still 2 offending files:
- vbox_tmpl.c: the variable is used inside an #ifdef and is assigned several times outside of #ifdef. Fixing the warning would have required wrapping all the assignment inside #ifdef which hurts readability.
vbox/vbox_tmpl.c: In function 'vboxAttachDrives': vbox/vbox_tmpl.c:3918:22: warning: variable 'accessMode' set but not used [-Wunused-but-set-variable]
- esx_vi_types.generated.c: the name implies it's generated code and I didn't want to dive into the code generator
esx/esx_vi_types.generated.c: In function 'esxVI_FileQueryFlags_Free': esx/esx_vi_types.generated.c:1203:3: warning: variable 'item' set but not used [-Wunused-but-set-variable]
I can take care of that and I'll post a speculative patch for it as I don't have a gcc 4.6 at hand right now to test it my self.
--- src/nwfilter/nwfilter_ebiptables_driver.c | 7 +++---- src/util/logging.c | 3 +-- src/vmware/vmware_driver.c | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-)
ACK. Before I can apply this patch we need to solve an issue with email address. You used a RedHat one for this patch, but you are listed with a Gnome one in the AUTHORS. This makes the syntax-check unhappy. We can solve this by adding your RedHat address as an alias to the Gnome on to the .mailmap file or use your RedHat as the mail one in the AUTHORS files and add and alias the other way around to the .mailmap file. What way do you prefer? Matthias

On Thu, Apr 14, 2011 at 06:44:25PM +0200, Matthias Bolte wrote:
I can take care of that and I'll post a speculative patch for it as I don't have a gcc 4.6 at hand right now to test it my self.
I can easily test it, I'll let you know how it goes.
Before I can apply this patch we need to solve an issue with email address. You used a RedHat one for this patch, but you are listed with a Gnome one in the AUTHORS. This makes the syntax-check unhappy. We can solve this by adding your RedHat address as an alias to the Gnome on to the .mailmap file or use your RedHat as the mail one in the AUTHORS files and add and alias the other way around to the .mailmap file.
What way do you prefer?
I prefer the latter (@redhat.com in AUTHORS, and @gnome.org addy in .mailmap). Thanks! Christophe

2011/4/14 Christophe Fergeau <cfergeau@redhat.com>:
On Thu, Apr 14, 2011 at 06:44:25PM +0200, Matthias Bolte wrote:
I can take care of that and I'll post a speculative patch for it as I don't have a gcc 4.6 at hand right now to test it my self.
I can easily test it, I'll let you know how it goes.
Before I can apply this patch we need to solve an issue with email address. You used a RedHat one for this patch, but you are listed with a Gnome one in the AUTHORS. This makes the syntax-check unhappy. We can solve this by adding your RedHat address as an alias to the Gnome on to the .mailmap file or use your RedHat as the mail one in the AUTHORS files and add and alias the other way around to the .mailmap file.
What way do you prefer?
I prefer the latter (@redhat.com in AUTHORS, and @gnome.org addy in .mailmap).
Thanks!
Christophe
Okay, I change the addresses accordingly and pushed the result. Matthias
participants (2)
-
Christophe Fergeau
-
Matthias Bolte