linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nfc: s3fwrn5: fix undefined parameter values in dev_err()
@ 2021-07-27 12:25 Tang Bin
  2021-07-27 17:34 ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: Tang Bin @ 2021-07-27 12:25 UTC (permalink / raw)
  To: k.opasiak, davem; +Cc: netdev, linux-kernel, Tang Bin, Zhang Shengju

In the function s3fwrn5_fw_download(), the 'ret' is not assigned,
so the correct value should be given in dev_err function.

Fixes: a0302ff5906a ("nfc: s3fwrn5: remove unnecessary label")
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
---
 drivers/nfc/s3fwrn5/firmware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nfc/s3fwrn5/firmware.c b/drivers/nfc/s3fwrn5/firmware.c
index 1421ffd46d9a..52c6f76adfb2 100644
--- a/drivers/nfc/s3fwrn5/firmware.c
+++ b/drivers/nfc/s3fwrn5/firmware.c
@@ -422,7 +422,7 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
 	tfm = crypto_alloc_shash("sha1", 0, 0);
 	if (IS_ERR(tfm)) {
 		dev_err(&fw_info->ndev->nfc_dev->dev,
-			"Cannot allocate shash (code=%d)\n", ret);
+			"Cannot allocate shash (code=%d)\n", PTR_ERR(tfm));
 		return PTR_ERR(tfm);
 	}
 
-- 
2.18.2




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] nfc: s3fwrn5: fix undefined parameter values in dev_err()
  2021-07-27 12:25 [PATCH] nfc: s3fwrn5: fix undefined parameter values in dev_err() Tang Bin
@ 2021-07-27 17:34 ` Nathan Chancellor
  2021-07-28  1:32   ` tangbin
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2021-07-27 17:34 UTC (permalink / raw)
  To: Tang Bin; +Cc: k.opasiak, davem, netdev, linux-kernel, Zhang Shengju

On Tue, Jul 27, 2021 at 08:25:06PM +0800, Tang Bin wrote:
> In the function s3fwrn5_fw_download(), the 'ret' is not assigned,
> so the correct value should be given in dev_err function.
> 
> Fixes: a0302ff5906a ("nfc: s3fwrn5: remove unnecessary label")
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>

This clears up a clang warning that I see:

drivers/nfc/s3fwrn5/firmware.c:425:41: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized]
                        "Cannot allocate shash (code=%d)\n", ret);
                                                             ^~~
./include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
        dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                       ^~~~~~~~~~~
./include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                _p_func(dev, fmt, ##__VA_ARGS__);                       \
                                    ^~~~~~~~~~~
drivers/nfc/s3fwrn5/firmware.c:416:9: note: initialize the variable 'ret' to silence this warning
        int ret;
               ^
                = 0
1 error generated.

One comment below but regardless:

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  drivers/nfc/s3fwrn5/firmware.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/nfc/s3fwrn5/firmware.c b/drivers/nfc/s3fwrn5/firmware.c
> index 1421ffd46d9a..52c6f76adfb2 100644
> --- a/drivers/nfc/s3fwrn5/firmware.c
> +++ b/drivers/nfc/s3fwrn5/firmware.c
> @@ -422,7 +422,7 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
>  	tfm = crypto_alloc_shash("sha1", 0, 0);
>  	if (IS_ERR(tfm)) {
>  		dev_err(&fw_info->ndev->nfc_dev->dev,
> -			"Cannot allocate shash (code=%d)\n", ret);
> +			"Cannot allocate shash (code=%d)\n", PTR_ERR(tfm));

We know this is going to be an error pointer so this could be changed to

"Cannot allocate shash (code=%pe)\n", tfm);

to make it a little cleaner to understand. See commit 57f5677e535b
("printf: add support for printing symbolic error names").

>  		return PTR_ERR(tfm);
>  	}
>  
> -- 
> 2.18.2

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nfc: s3fwrn5: fix undefined parameter values in dev_err()
  2021-07-27 17:34 ` Nathan Chancellor
@ 2021-07-28  1:32   ` tangbin
  0 siblings, 0 replies; 3+ messages in thread
From: tangbin @ 2021-07-28  1:32 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: k.opasiak, davem, netdev, linux-kernel, Zhang Shengju

Hi Nathan:

On 2021/7/28 1:34, Nathan Chancellor wrote:
> On Tue, Jul 27, 2021 at 08:25:06PM +0800, Tang Bin wrote:
>> In the function s3fwrn5_fw_download(), the 'ret' is not assigned,
>> so the correct value should be given in dev_err function.
>>
>> Fixes: a0302ff5906a ("nfc: s3fwrn5: remove unnecessary label")
>> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
>> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> This clears up a clang warning that I see:
>
> drivers/nfc/s3fwrn5/firmware.c:425:41: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized]
>                          "Cannot allocate shash (code=%d)\n", ret);
>                                                               ^~~
> ./include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err'
>          dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
>                                                                         ^~~~~~~~~~~
> ./include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
>                  _p_func(dev, fmt, ##__VA_ARGS__);                       \
>                                      ^~~~~~~~~~~
> drivers/nfc/s3fwrn5/firmware.c:416:9: note: initialize the variable 'ret' to silence this warning
>          int ret;
>                 ^
>                  = 0
> 1 error generated.
>
> One comment below but regardless:
>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
>
>> ---
>>   drivers/nfc/s3fwrn5/firmware.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/nfc/s3fwrn5/firmware.c b/drivers/nfc/s3fwrn5/firmware.c
>> index 1421ffd46d9a..52c6f76adfb2 100644
>> --- a/drivers/nfc/s3fwrn5/firmware.c
>> +++ b/drivers/nfc/s3fwrn5/firmware.c
>> @@ -422,7 +422,7 @@ int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
>>   	tfm = crypto_alloc_shash("sha1", 0, 0);
>>   	if (IS_ERR(tfm)) {
>>   		dev_err(&fw_info->ndev->nfc_dev->dev,
>> -			"Cannot allocate shash (code=%d)\n", ret);
>> +			"Cannot allocate shash (code=%d)\n", PTR_ERR(tfm));
> We know this is going to be an error pointer so this could be changed to
>
> "Cannot allocate shash (code=%pe)\n", tfm);
>
> to make it a little cleaner to understand. See commit 57f5677e535b
> ("printf: add support for printing symbolic error names").

Got it. My patch is looks like a revert, so in the dev_err I used 
'PTR_ERR(tfm)'. After your suggestion,

I will send V2 for you.

Thanks

Tang Bin



>
>>   		return PTR_ERR(tfm);
>>   	}
>>   
>> -- 
>> 2.18.2
> Cheers,
> Nathan



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-28  1:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-27 12:25 [PATCH] nfc: s3fwrn5: fix undefined parameter values in dev_err() Tang Bin
2021-07-27 17:34 ` Nathan Chancellor
2021-07-28  1:32   ` tangbin

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).