while compiling with make W=1 (gcc gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8))
found the following warning
drivers/video/backlight/adp5520_bl.c: In function ‘adp5520_show’:
drivers/video/backlight/adp5520_bl.c:146:6: warning: variable ‘error’ set but not used [-Wunused-but-set-variable]
fixed by removing the variable
Cc: Jingoo Han <redacted>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Cc: Richard Purdie <redacted>
Signed-off-by: Devendra Naga <redacted>
---
drivers/video/backlight/adp5520_bl.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
From: Andrew Morton <akpm@linux-foundation.org> Date: 2013-03-08 21:01:00
On Fri, 8 Mar 2013 14:31:07 -0500 Devendra Naga [off-list ref] wrote:
quoted hunk
while compiling with make W=1 (gcc gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8))
found the following warning
drivers/video/backlight/adp5520_bl.c: In function ___adp5520_show___:
drivers/video/backlight/adp5520_bl.c:146:6: warning: variable ___error___ set but not used [-Wunused-but-set-variable]
fixed by removing the variable
...
@@ -143,11 +143,10 @@ static int adp5520_bl_setup(struct backlight_device *bl)staticssize_tadp5520_show(structdevice*dev,char*buf,intreg){structadp5520_bl*data=dev_get_drvdata(dev);-interror;uint8_treg_val;mutex_lock(&data->lock);-error=adp5520_read(data->master,reg,®_val);+adp5520_read(data->master,reg,®_val);mutex_unlock(&data->lock);returnsprintf(buf,"%u\n",reg_val);
We shouldn't just ignore the error; with the code as it stands, a
adp5520_read() failure will result in the kernel displaying
uninitialised garbage.
So it would be better to propagate the adp5520_read() return value back
to the caller if it's negative.
(This assumes that the i2c layer returns a sane return value - if it
does, that would make i2c pretty unique :( We could get paranoid and
return a hard-wired -EIO, but it would be bad of us to overwrite things
like -ENOMEM).
So I'd suggest this:
From: Jingoo Han <hidden> Date: 2013-03-11 00:56:49
On Saturday, March 09, 2013 4:31 AM, Devendra Naga wrote:
quoted hunk
while compiling with make W=1 (gcc gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8))
found the following warning
drivers/video/backlight/adp5520_bl.c: In function ‘adp5520_show’:
drivers/video/backlight/adp5520_bl.c:146:6: warning: variable ‘error’ set but not used [-Wunused-but-
set-variable]
fixed by removing the variable
Cc: Jingoo Han <redacted>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Cc: Richard Purdie <redacted>
Signed-off-by: Devendra Naga <redacted>
---
drivers/video/backlight/adp5520_bl.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
@@ -143,11 +143,10 @@ static int adp5520_bl_setup(struct backlight_device *bl)staticssize_tadp5520_show(structdevice*dev,char*buf,intreg){structadp5520_bl*data=dev_get_drvdata(dev);-interror;uint8_treg_val;mutex_lock(&data->lock);-error=adp5520_read(data->master,reg,®_val);+adp5520_read(data->master,reg,®_val);mutex_unlock(&data->lock);
Hi Devendra Naga,
I also agree with Andrew Morton's opinion.
It would be better to check return value from I2C read/write functions.
Best regards,
Jingoo Han
On Fri, Mar 8, 2013 at 4:01 PM, Andrew Morton [off-list ref] wrote:
quoted hunk
On Fri, 8 Mar 2013 14:31:07 -0500 Devendra Naga [off-list ref] wrote:
quoted
while compiling with make W=1 (gcc gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8))
found the following warning
drivers/video/backlight/adp5520_bl.c: In function ___adp5520_show___:
drivers/video/backlight/adp5520_bl.c:146:6: warning: variable ___error___ set but not used [-Wunused-but-set-variable]
fixed by removing the variable
...
@@ -143,11 +143,10 @@ static int adp5520_bl_setup(struct backlight_device *bl)staticssize_tadp5520_show(structdevice*dev,char*buf,intreg){structadp5520_bl*data=dev_get_drvdata(dev);-interror;uint8_treg_val;mutex_lock(&data->lock);-error=adp5520_read(data->master,reg,®_val);+adp5520_read(data->master,reg,®_val);mutex_unlock(&data->lock);returnsprintf(buf,"%u\n",reg_val);
We shouldn't just ignore the error; with the code as it stands, a
adp5520_read() failure will result in the kernel displaying
uninitialised garbage.
So it would be better to propagate the adp5520_read() return value back
to the caller if it's negative.
(This assumes that the i2c layer returns a sane return value - if it
does, that would make i2c pretty unique :( We could get paranoid and
return a hard-wired -EIO, but it would be bad of us to overwrite things
like -ENOMEM).
So I'd suggest this:
On Sun, Mar 10, 2013 at 8:56 PM, Jingoo Han [off-list ref] wrote:
On Saturday, March 09, 2013 4:31 AM, Devendra Naga wrote:
quoted
while compiling with make W=1 (gcc gcc (GCC) 4.7.2 20121109 (Red Hat 4.7.2-8))
found the following warning
drivers/video/backlight/adp5520_bl.c: In function ‘adp5520_show’:
drivers/video/backlight/adp5520_bl.c:146:6: warning: variable ‘error’ set but not used [-Wunused-but-
set-variable]
fixed by removing the variable
Cc: Jingoo Han <redacted>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Cc: Richard Purdie <redacted>
Signed-off-by: Devendra Naga <redacted>
---
drivers/video/backlight/adp5520_bl.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)