* [PATCH] i2c: sh_mobile: Fix compilation warning
@ 2019-05-09 4:43 Viresh Kumar
2020-05-29 12:12 ` Wolfram Sang
0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2019-05-09 4:43 UTC (permalink / raw)
To: Wolfram Sang; +Cc: Viresh Kumar, Vincent Guittot, linux-i2c, linux-kernel
This currently generates a warning:
drivers/i2c/busses/i2c-sh_mobile.c: In function 'sh_mobile_i2c_isr':
drivers/i2c/busses/i2c-sh_mobile.c:399:26: warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized]
Though the code looks okay and shouldn't ever use the variable
uninitialized.
Fix the warning by moving the code around and getting rid of 'data'.
Compile tested only.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/i2c/busses/i2c-sh_mobile.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 8777af4c695e..945eb8504fb7 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -369,7 +369,6 @@ static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd)
static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
{
- unsigned char data;
int real_pos;
/* switch from TX (address) to RX (data) adds two interrupts */
@@ -390,13 +389,11 @@ static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd)
if (real_pos < 0)
i2c_op(pd, OP_RX_STOP);
else
- data = i2c_op(pd, OP_RX_STOP_DATA);
+ pd->msg->buf[real_pos] = i2c_op(pd, OP_RX_STOP_DATA);
} else if (real_pos >= 0) {
- data = i2c_op(pd, OP_RX);
+ pd->msg->buf[real_pos] = i2c_op(pd, OP_RX);
}
- if (real_pos >= 0)
- pd->msg->buf[real_pos] = data;
done:
pd->pos++;
return pd->pos == (pd->msg->len + 2);
--
2.21.0.rc0.269.g1a574e7a288b
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: sh_mobile: Fix compilation warning
2019-05-09 4:43 [PATCH] i2c: sh_mobile: Fix compilation warning Viresh Kumar
@ 2020-05-29 12:12 ` Wolfram Sang
2020-06-01 3:59 ` Viresh Kumar
0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2020-05-29 12:12 UTC (permalink / raw)
To: Viresh Kumar; +Cc: Vincent Guittot, linux-i2c, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 791 bytes --]
On Thu, May 09, 2019 at 10:13:46AM +0530, Viresh Kumar wrote:
> This currently generates a warning:
>
> drivers/i2c/busses/i2c-sh_mobile.c: In function 'sh_mobile_i2c_isr':
> drivers/i2c/busses/i2c-sh_mobile.c:399:26: warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> Though the code looks okay and shouldn't ever use the variable
> uninitialized.
>
> Fix the warning by moving the code around and getting rid of 'data'.
>
> Compile tested only.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested on a Renesas Lager board (R-Car H2). Dumping register sets
produces identical results.
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
And code is actually cleaner now.
Applied to for-next, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: sh_mobile: Fix compilation warning
2020-05-29 12:12 ` Wolfram Sang
@ 2020-06-01 3:59 ` Viresh Kumar
2020-06-02 6:50 ` Wolfram Sang
0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2020-06-01 3:59 UTC (permalink / raw)
To: Wolfram Sang; +Cc: Vincent Guittot, linux-i2c, linux-kernel
On 29-05-20, 14:12, Wolfram Sang wrote:
> On Thu, May 09, 2019 at 10:13:46AM +0530, Viresh Kumar wrote:
> > This currently generates a warning:
> >
> > drivers/i2c/busses/i2c-sh_mobile.c: In function 'sh_mobile_i2c_isr':
> > drivers/i2c/busses/i2c-sh_mobile.c:399:26: warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >
> > Though the code looks okay and shouldn't ever use the variable
> > uninitialized.
> >
> > Fix the warning by moving the code around and getting rid of 'data'.
> >
> > Compile tested only.
> >
> > Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>
> Tested on a Renesas Lager board (R-Car H2). Dumping register sets
> produces identical results.
>
> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
>
> And code is actually cleaner now.
>
> Applied to for-next, thanks!
>
Almost after an year, wondering on how you reached this patch now :)
--
viresh
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] i2c: sh_mobile: Fix compilation warning
2020-06-01 3:59 ` Viresh Kumar
@ 2020-06-02 6:50 ` Wolfram Sang
0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2020-06-02 6:50 UTC (permalink / raw)
To: Viresh Kumar; +Cc: Vincent Guittot, linux-i2c, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 239 bytes --]
> Almost after an year, wondering on how you reached this patch now :)
Another developer sent the same patch. And last time I was unsure if I
liked the new code better (for reasons I can't recall anymore); this
time it was clear to me.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-06-02 6:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-09 4:43 [PATCH] i2c: sh_mobile: Fix compilation warning Viresh Kumar
2020-05-29 12:12 ` Wolfram Sang
2020-06-01 3:59 ` Viresh Kumar
2020-06-02 6:50 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).