Skip to contentSkip to conversation

hwmon: (w83795) Silent false warning from gcc

PATCH In review Jean Delvare 2 participants 2 messages Dec 19, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (w83795) Silent false warning from gcc

The code triggers a false warning with older versions of gcc:
w83795.c: In function 'w83795_update_device':
w83795.c:475: warning: 'lsb' may be used uninitialized in this function

I admit that the code is a little tricky, but I see no way to write it differently without hurting performance. So let's just silent the warning with a needless initialization.

---
 drivers/hwmon/w83795.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hwmon/w83795.c +2 -2
@@ -458,6 +458,7 @@ static void w83795_update_limits(struct
 {
 	struct w83795_data *data = i2c_get_clientdata(client);
 	int i, limit;
+	u8 lsb;
 
 	/* Read the voltage limits */
 	for (i = 0; i < ARRAY_SIZE(data->in); i++) {
@@ -479,9 +480,8 @@ static void w83795_update_limits(struct
 	}
 
 	/* Read the fan limits */
+	lsb = 0; /* Silent false gcc warning */
 	for (i = 0; i < ARRAY_SIZE(data->fan); i++) {
-		u8 lsb;
-
 		/* Each register contains LSB for 2 fans, but we want to
 		 * read it only once to save time */
 		if ((i & 1) = 0 && (data->has_fan & (3 << i)))
Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Acked-by on v1 1/1
#1 lore raw

Re: [lm-sensors] [PATCH] hwmon: (w83795) Silent false warning from

Quoted 9 lines · Jean Delvare

The code triggers a false warning with older versions of gcc:
w83795.c: In function 'w83795_update_device':
w83795.c:475: warning: 'lsb' may be used uninitialized in this function

I admit that the code is a little tricky, but I see no way to write it differently without hurting performance. So let's just silent the warning with a needless initialization.

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors