hwmon: (sch56xx-common) Fix build warnings
Guenter Roeck
maintainerPATCH 1/1 hwmon: (sch56xx-common) Fix build warnings
Fix:
warning: 'address' may be used uninitialized in this function
warning: 'name' may be used uninitialized in this function
While those are false warnings, the patch reduces module size on x86_64 by approximately 110 bytes, so it is still worth the effort.
--- drivers/hwmon/sch56xx-common.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/hwmon/sch56xx-common.c +11 -11
@@ -503,10 +503,10 @@ EXPORT_SYMBOL(sch56xx_watchdog_unregister);* platform dev find, add and remove functions */ -static int __init sch56xx_find (int sioaddr,unsigned short *address, -const char **name) +static int __init sch56xx_find (int sioaddr,const char **name) {u8 devid; +unsigned short address;int err; err =superio_enter (sioaddr);
@@ -540,13 +540,14 @@ static int __init sch56xx_find(int sioaddr, unsigned short *address,* Warning the order of the low / high byte is the other way around * as on most other superio devices!! */ - *address =superio_inb (sioaddr,SIO_REG_ADDR ) | + address =superio_inb (sioaddr,SIO_REG_ADDR ) |superio_inb (sioaddr,SIO_REG_ADDR +1 ) <<8 ; -if (*address =0 ) { +if (address =0 ) {pr_warn ("Base address not set\n" ); err = -ENODEV ; goto exit; } + err = address; exit:superio_exit (sioaddr);
@@ -593,15 +594,14 @@ exit_device_put:static int __init sch56xx_init (void ) { -int err;unsigned short address; -const char *name; +const char *name =NULL ; - err =sch56xx_find (0x4e , &address, &name); -if (err) - err =sch56xx_find (0x2e , &address, &name); -if (err) -return err; + address =sch56xx_find (0x4e , &name); +if (address <0 ) + address =sch56xx_find (0x2e , &name); +if (address <0 ) +return address;return sch56xx_device_add (address, name); }
Signature · 7 lines
1.7.9.7 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi,
Quoted 8 lines · Guenter Roeck
Fix:
warning: 'address' may be used uninitialized in this function
warning: 'name' may be used uninitialized in this functionWhile those are false warnings, the patch reduces module size on
x86_64by approximately 110 bytes, so it is still worth the effort.Signed-off-by Guenter Roeck <[email protected]>
Looks good:
Regards,
Hans
Quoted 51 lines
--- drivers/hwmon/sch56xx-common.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)drivers/hwmon/sch56xx-common.c +6
-9@@ -503,10 +503,10 @@ EXPORT_SYMBOL(sch56xx_watchdog_unregister);* platform dev find, add and remove functions */ -static int __init sch56xx_find (int sioaddr,unsigned short *address, -const char **name) +static int __init sch56xx_find (int sioaddr,const char **name) {u8 devid; +unsigned short address;int err; err =superio_enter (sioaddr);@@ -540,13 +540,14 @@ static int __init sch56xx_find(int sioaddr, unsigned short *address,* Warning the order of the low / high byte is the other way around * as on most other superio devices!! */ - *address =superio_inb (sioaddr,SIO_REG_ADDR ) | + address =superio_inb (sioaddr,SIO_REG_ADDR ) |superio_inb (sioaddr,SIO_REG_ADDR +1 ) <<8 ; -if (*address =0 ) { +if (address =0 ) {pr_warn ("Base address not set\n" ); err = -ENODEV ; goto exit; } + err = address; exit:superio_exit (sioaddr);@@ -593,15 +594,14 @@ exit_device_put:static int __init sch56xx_init (void ) { -int err;unsigned short address; -const char *name; +const char *name =NULL ; - err =sch56xx_find (0x4e , &address, &name); -if (err) - err =sch56xx_find (0x2e , &address, &name);
drivers/hwmon/sch56xx-common.c exit_device_put: · line 607
Quoted 10 lines
drivers/hwmon/sch56xx-common.c +5
-2-if (err) -return err; + address =sch56xx_find (0x4e , &name); +if (address <0 ) + address =sch56xx_find (0x2e , &name); +if (address <0 ) +return address;return sch56xx_device_add (address, name); }
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors