From: Guenter Roeck Date: Tue, 12 Jun 2012 15:27:49 +0000 (-0700) Subject: hwmon: (w83781d) Fix compile warning X-Git-Tag: v3.2.95~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a650af0da798563dcd0621f045fa4454c203f307;p=thirdparty%2Fkernel%2Fstable.git hwmon: (w83781d) Fix compile warning commit bbc8a569ae91e0951f4b7f8eb33ef1970bf2129c upstream. The following compile warning may be seen if the driver is compiled with -Wuninitialized: drivers/hwmon/w83781d.c: warning: 'sc_addr[1]' may be used uninitialized in this function [-Wuninitialized] While this is a false positive, it is annoying in nightly builds, and may help to conceal real problems. The current code is quite tricky, and and it is easy to rearrage the code to make the warning disappear. So fix it. Cc: Jean Delvare Signed-off-by: Guenter Roeck Signed-off-by: Ben Hutchings --- diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index 65b685e2c7b73..56a69c1a2bb8a 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c @@ -826,6 +826,7 @@ w83781d_detect_subclients(struct i2c_client *new_client) struct i2c_adapter *adapter = new_client->adapter; struct w83781d_data *data = i2c_get_clientdata(new_client); enum chips kind = data->type; + int num_sc = 1; id = i2c_adapter_id(adapter); @@ -850,6 +851,7 @@ w83781d_detect_subclients(struct i2c_client *new_client) } if (kind != w83783s) { + num_sc = 2; if (force_subclients[0] == id && force_subclients[1] == address) { sc_addr[1] = force_subclients[3]; @@ -865,7 +867,7 @@ w83781d_detect_subclients(struct i2c_client *new_client) } } - for (i = 0; i <= 1; i++) { + for (i = 0; i < num_sc; i++) { data->lm75[i] = i2c_new_dummy(adapter, sc_addr[i]); if (!data->lm75[i]) { dev_err(&new_client->dev, "Subclient %d " @@ -876,8 +878,6 @@ w83781d_detect_subclients(struct i2c_client *new_client) goto ERROR_SC_3; goto ERROR_SC_2; } - if (kind == w83783s) - break; } return 0;