Re: [PATCH 1/1] i2c: sh_mobile: eliminate a misreported warning

From: Wolfram Sang
Date: Fri May 29 2020 - 08:15:05 EST


On Wed, Apr 29, 2020 at 08:40:17PM +0800, Zhen Lei wrote:
> The warning is caused by the branches "if (pd->pos == -1)" and
> "if (pd->pos == 0)", because they appear after "real_pos = pd->pos - 2",
> so the compiler doesn't known the value of real_pos is negative through
> these two branches.
>
> To avoid this warning, eliminate the middleman "data".
>
> drivers/i2c/busses/i2c-sh_mobile.c: In function âsh_mobile_i2c_isrâ:
> drivers/i2c/busses/i2c-sh_mobile.c:396:26: warning: âdataâ may be used uninitialized in this function [-Wmaybe-uninitialized]
> pd->msg->buf[real_pos] = data;
> ^
> drivers/i2c/busses/i2c-sh_mobile.c:369:16: note: âdataâ was declared here
> unsigned char data;
>
> Signed-off-by: Zhen Lei <thunder.leizhen@xxxxxxxxxx>

Thanks for the patch and reminding me about the issue, it is correct.
However, an identical patch has been sent before and is now applied in
for-next:

http://patchwork.ozlabs.org/project/linux-i2c/patch/f526f90ea62741716de2ecfa310ba22d8cf1d3c2.1557377015.git.viresh.kumar@xxxxxxxxxx/

Attachment: signature.asc
Description: PGP signature