RE: [PATCH v3] mmc-utils: fix warning on uninitialized 'cnt'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> When building following warning shows up:
> ```
> In function '__bswap_32',
>     inlined from 'do_rpmb_write_block' at mmc_cmds.c:2293:27:
> /home/autobuild/autobuild/instance-15/output-1/host/aarch64-buildroot-
> linux-gnu/sysroot/usr/include/bits/byteswap.h:52:10: error: 'cnt' may be
> used uninitialized [-Werror=maybe-uninitialized]
>    52 |   return __builtin_bswap32 (__bsx);
>       |          ^~~~~~~~~~~~~~~~~~~~~~~~~
> mmc_cmds.c: In function 'do_rpmb_write_block':
> mmc_cmds.c:2270:22: note: 'cnt' was declared here
> 2270 |         unsigned int cnt;
>       |                      ^~~
> cc1: all warnings being treated as errors ``` This is due to function
> rpmb_read_counter() that doesn't set its argument 'unsigned int *cnt' in all
> return points. So let's set *cnt to 0 in the return point that misses to initialize
> it.
> 
> Signed-off-by: Giulio Benetti <giulio.benetti@xxxxxxxxxxxxxxxxxxxxxx>
Reviewed-by: Avri Altman <avri.altman@xxxxxxx>


> ---
> V1->V2:
> * prefix subject with 'mmc-utils:' as pointed by Avri Altman
> V2->V3:
> * add missing commit as pointed by Avri Altman
> * initialize pointer inside rpmb_read_counter() as suggested by Arnd
> Bergmann
> ---
>  mmc_cmds.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/mmc_cmds.c b/mmc_cmds.c
> index 12b7802..4d203ef 100644
> --- a/mmc_cmds.c
> +++ b/mmc_cmds.c
> @@ -2238,8 +2238,10 @@ int rpmb_read_counter(int dev_fd, unsigned int
> *cnt)
>         }
> 
>         /* Check RPMB response */
> -       if (frame_out.result != 0)
> +       if (frame_out.result != 0) {
> +               *cnt = 0;
>                 return be16toh(frame_out.result);
> +       }
> 
>         *cnt = be32toh(frame_out.write_counter);
> 
> --
> 2.34.1





[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux