Message ID | 20220918124210.1127345-1-giulio.benetti@benettiengineering.com |
---|---|
State | Superseded |
Headers | show |
Series | [v2] mmc-utils: mmc_cmds.c: fix warning on uninitialized 'cnt' | expand |
You forgot to include your commit log. Also no need to include the module name - just mmc-utils: fix warning on uninitialized 'cnt' Please feel free to add my reviewed-by once you do. Thanks, Avri > > Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> > --- > V1->V2: > * prefix subjet with 'mmc-utils:' as pointed by Avri Altman > --- > 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
Hi Arnd, On 18/09/22 16:13, Arnd Bergmann wrote: > On Sun, Sep 18, 2022, at 2:42 PM, Giulio Benetti wrote: >> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> >> --- >> V1->V2: >> * prefix subjet with 'mmc-utils:' as pointed by Avri Altman >> --- >> 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) > > I think this is the wrong place to initialize it, I would > suggest doing it inside of rpmb_read_counter() when returning > an error, to make it clear that this is not the intended > counter but something that is not actually meant to be used. > > If you initialize local variables to bogus values, you remove > the possibility for the compiler to warn a function actually uses > something without initialization. Totally right, thank you.
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)
Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> --- V1->V2: * prefix subjet with 'mmc-utils:' as pointed by Avri Altman --- mmc_cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)