diff mbox series

mmc_cmds.c: fix warning on uninitialized 'cnt'

Message ID 20220918121637.1101135-1-giulio.benetti@benettiengineering.com (mailing list archive)
State Superseded
Headers show
Series mmc_cmds.c: fix warning on uninitialized 'cnt' | expand

Commit Message

Giulio Benetti Sept. 18, 2022, 12:16 p.m. UTC
Since -Werror is enabled by default build fails with:
```
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
```
So let's fix the warning by initializing cnt local variable.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 mmc_cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Avri Altman Sept. 18, 2022, 12:34 p.m. UTC | #1
> Since -Werror is enabled by default build fails with:
> ```
> 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 ``` So let's fix the warning by
> initializing cnt local variable.
> 
> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
Please prefix you subject with "mmc-utils:"

Thanks,
Avri

> ---
>  mmc_cmds.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mmc_cmds.c b/mmc_cmds.c
> index 12b7802..777d649 100644
> --- a/mmc_cmds.c
> +++ b/mmc_cmds.c
> @@ -2436,7 +2436,7 @@ int do_rpmb_write_block(int nargs, char **argv)
>         int ret, dev_fd, key_fd, data_fd;
>         unsigned char key[32];
>         uint16_t addr;
> -       unsigned int cnt;
> +       unsigned int cnt = 0;
>         struct rpmb_frame frame_in = {
>                 .req_resp    = htobe16(MMC_RPMB_WRITE),
>                 .block_count = htobe16(1)
> --
> 2.34.1
Giulio Benetti Sept. 18, 2022, 12:36 p.m. UTC | #2
On 18/09/22 14:34, Avri Altman wrote:
>> Since -Werror is enabled by default build fails with:
>> ```
>> 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 ``` So let's fix the warning by
>> initializing cnt local variable.
>>
>> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> Please prefix you subject with "mmc-utils:"

Ok, thank you. Going to send V2

Best regards
diff mbox series

Patch

diff --git a/mmc_cmds.c b/mmc_cmds.c
index 12b7802..777d649 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -2436,7 +2436,7 @@  int do_rpmb_write_block(int nargs, char **argv)
 	int ret, dev_fd, key_fd, data_fd;
 	unsigned char key[32];
 	uint16_t addr;
-	unsigned int cnt;
+	unsigned int cnt = 0;
 	struct rpmb_frame frame_in = {
 		.req_resp    = htobe16(MMC_RPMB_WRITE),
 		.block_count = htobe16(1)