All the mail mirrored from lore.kernel.org
 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 16:59 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ 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] 5+ 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 16:59 ` kernel test robot
  2021-07-27 16:59 ` kernel test robot
  2021-07-27 17:34 ` Nathan Chancellor
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-07-27 16:59 UTC (permalink / raw
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5452 bytes --]

Hi Tang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[cannot apply to net/master linus/master v5.14-rc3 next-20210726]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tang-Bin/nfc-s3fwrn5-fix-undefined-parameter-values-in-dev_err/20210727-202559
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git b0e81817629a496854ff1799f6cbd89597db65fd
config: h8300-randconfig-r032-20210727 (attached as .config)
compiler: h8300-linux-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/6800fa99883890b135346d9fb8fff11b50426812
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tang-Bin/nfc-s3fwrn5-fix-undefined-parameter-values-in-dev_err/20210727-202559
        git checkout 6800fa99883890b135346d9fb8fff11b50426812
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross ARCH=h8300 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/device.h:15,
                    from include/linux/acpi.h:15,
                    from include/linux/irqchip.h:14,
                    from arch/h8300/include/asm/irq.h:5,
                    from include/linux/irq.h:23,
                    from include/asm-generic/hardirq.h:17,
                    from ./arch/h8300/include/generated/asm/hardirq.h:1,
                    from include/linux/hardirq.h:11,
                    from include/linux/interrupt.h:11,
                    from include/net/nfc/nci_core.h:20,
                    from drivers/nfc/s3fwrn5/s3fwrn5.h:14,
                    from drivers/nfc/s3fwrn5/firmware.c:14:
   drivers/nfc/s3fwrn5/firmware.c: In function 's3fwrn5_fw_download':
>> drivers/nfc/s3fwrn5/firmware.c:425:4: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat=]
     425 |    "Cannot allocate shash (code=%d)\n", PTR_ERR(tfm));
         |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
      19 | #define dev_fmt(fmt) fmt
         |                      ^~~
   drivers/nfc/s3fwrn5/firmware.c:424:3: note: in expansion of macro 'dev_err'
     424 |   dev_err(&fw_info->ndev->nfc_dev->dev,
         |   ^~~~~~~
   drivers/nfc/s3fwrn5/firmware.c:425:34: note: format string is defined here
     425 |    "Cannot allocate shash (code=%d)\n", PTR_ERR(tfm));
         |                                 ~^
         |                                  |
         |                                  int
         |                                 %ld


vim +425 drivers/nfc/s3fwrn5/firmware.c

   409	
   410	int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
   411	{
   412		struct s3fwrn5_fw_image *fw = &fw_info->fw;
   413		u8 hash_data[SHA1_DIGEST_SIZE];
   414		struct crypto_shash *tfm;
   415		u32 image_size, off;
   416		int ret;
   417	
   418		image_size = fw_info->sector_size * fw->image_sectors;
   419	
   420		/* Compute SHA of firmware data */
   421	
   422		tfm = crypto_alloc_shash("sha1", 0, 0);
   423		if (IS_ERR(tfm)) {
   424			dev_err(&fw_info->ndev->nfc_dev->dev,
 > 425				"Cannot allocate shash (code=%d)\n", PTR_ERR(tfm));
   426			return PTR_ERR(tfm);
   427		}
   428	
   429		ret = crypto_shash_tfm_digest(tfm, fw->image, image_size, hash_data);
   430	
   431		crypto_free_shash(tfm);
   432		if (ret) {
   433			dev_err(&fw_info->ndev->nfc_dev->dev,
   434				"Cannot compute hash (code=%d)\n", ret);
   435			return ret;
   436		}
   437	
   438		/* Firmware update process */
   439	
   440		dev_info(&fw_info->ndev->nfc_dev->dev,
   441			"Firmware update: %s\n", fw_info->fw_name);
   442	
   443		ret = s3fwrn5_fw_enter_update_mode(fw_info, hash_data,
   444			SHA1_DIGEST_SIZE, fw_info->sig, fw_info->sig_size);
   445		if (ret < 0) {
   446			dev_err(&fw_info->ndev->nfc_dev->dev,
   447				"Unable to enter update mode\n");
   448			return ret;
   449		}
   450	
   451		for (off = 0; off < image_size; off += fw_info->sector_size) {
   452			ret = s3fwrn5_fw_update_sector(fw_info,
   453				fw_info->base_addr + off, fw->image + off);
   454			if (ret < 0) {
   455				dev_err(&fw_info->ndev->nfc_dev->dev,
   456					"Firmware update error (code=%d)\n", ret);
   457				return ret;
   458			}
   459		}
   460	
   461		ret = s3fwrn5_fw_complete_update_mode(fw_info);
   462		if (ret < 0) {
   463			dev_err(&fw_info->ndev->nfc_dev->dev,
   464				"Unable to complete update mode\n");
   465			return ret;
   466		}
   467	
   468		dev_info(&fw_info->ndev->nfc_dev->dev,
   469			"Firmware update: success\n");
   470	
   471		return ret;
   472	}
   473	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38048 bytes --]

^ permalink raw reply	[flat|nested] 5+ 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 16:59 ` kernel test robot
@ 2021-07-27 16:59 ` kernel test robot
  2021-07-27 17:34 ` Nathan Chancellor
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-07-27 16:59 UTC (permalink / raw
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5092 bytes --]

Hi Tang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[cannot apply to net/master linus/master v5.14-rc3 next-20210726]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Tang-Bin/nfc-s3fwrn5-fix-undefined-parameter-values-in-dev_err/20210727-202559
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git b0e81817629a496854ff1799f6cbd89597db65fd
config: arm-defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/6800fa99883890b135346d9fb8fff11b50426812
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tang-Bin/nfc-s3fwrn5-fix-undefined-parameter-values-in-dev_err/20210727-202559
        git checkout 6800fa99883890b135346d9fb8fff11b50426812
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/device.h:15,
                    from include/linux/dma-mapping.h:7,
                    from include/linux/skbuff.h:31,
                    from include/net/nfc/nci_core.h:21,
                    from drivers/nfc/s3fwrn5/s3fwrn5.h:14,
                    from drivers/nfc/s3fwrn5/firmware.c:14:
   drivers/nfc/s3fwrn5/firmware.c: In function 's3fwrn5_fw_download':
>> drivers/nfc/s3fwrn5/firmware.c:425:4: warning: format '%d' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat=]
     425 |    "Cannot allocate shash (code=%d)\n", PTR_ERR(tfm));
         |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
      19 | #define dev_fmt(fmt) fmt
         |                      ^~~
   drivers/nfc/s3fwrn5/firmware.c:424:3: note: in expansion of macro 'dev_err'
     424 |   dev_err(&fw_info->ndev->nfc_dev->dev,
         |   ^~~~~~~
   drivers/nfc/s3fwrn5/firmware.c:425:34: note: format string is defined here
     425 |    "Cannot allocate shash (code=%d)\n", PTR_ERR(tfm));
         |                                 ~^
         |                                  |
         |                                  int
         |                                 %ld


vim +425 drivers/nfc/s3fwrn5/firmware.c

   409	
   410	int s3fwrn5_fw_download(struct s3fwrn5_fw_info *fw_info)
   411	{
   412		struct s3fwrn5_fw_image *fw = &fw_info->fw;
   413		u8 hash_data[SHA1_DIGEST_SIZE];
   414		struct crypto_shash *tfm;
   415		u32 image_size, off;
   416		int ret;
   417	
   418		image_size = fw_info->sector_size * fw->image_sectors;
   419	
   420		/* Compute SHA of firmware data */
   421	
   422		tfm = crypto_alloc_shash("sha1", 0, 0);
   423		if (IS_ERR(tfm)) {
   424			dev_err(&fw_info->ndev->nfc_dev->dev,
 > 425				"Cannot allocate shash (code=%d)\n", PTR_ERR(tfm));
   426			return PTR_ERR(tfm);
   427		}
   428	
   429		ret = crypto_shash_tfm_digest(tfm, fw->image, image_size, hash_data);
   430	
   431		crypto_free_shash(tfm);
   432		if (ret) {
   433			dev_err(&fw_info->ndev->nfc_dev->dev,
   434				"Cannot compute hash (code=%d)\n", ret);
   435			return ret;
   436		}
   437	
   438		/* Firmware update process */
   439	
   440		dev_info(&fw_info->ndev->nfc_dev->dev,
   441			"Firmware update: %s\n", fw_info->fw_name);
   442	
   443		ret = s3fwrn5_fw_enter_update_mode(fw_info, hash_data,
   444			SHA1_DIGEST_SIZE, fw_info->sig, fw_info->sig_size);
   445		if (ret < 0) {
   446			dev_err(&fw_info->ndev->nfc_dev->dev,
   447				"Unable to enter update mode\n");
   448			return ret;
   449		}
   450	
   451		for (off = 0; off < image_size; off += fw_info->sector_size) {
   452			ret = s3fwrn5_fw_update_sector(fw_info,
   453				fw_info->base_addr + off, fw->image + off);
   454			if (ret < 0) {
   455				dev_err(&fw_info->ndev->nfc_dev->dev,
   456					"Firmware update error (code=%d)\n", ret);
   457				return ret;
   458			}
   459		}
   460	
   461		ret = s3fwrn5_fw_complete_update_mode(fw_info);
   462		if (ret < 0) {
   463			dev_err(&fw_info->ndev->nfc_dev->dev,
   464				"Unable to complete update mode\n");
   465			return ret;
   466		}
   467	
   468		dev_info(&fw_info->ndev->nfc_dev->dev,
   469			"Firmware update: success\n");
   470	
   471		return ret;
   472	}
   473	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 54024 bytes --]

^ permalink raw reply	[flat|nested] 5+ 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 16:59 ` kernel test robot
  2021-07-27 16:59 ` kernel test robot
@ 2021-07-27 17:34 ` Nathan Chancellor
  2021-07-28  1:32   ` tangbin
  2 siblings, 1 reply; 5+ 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] 5+ 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; 5+ 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] 5+ messages in thread

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

Thread overview: 5+ 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 16:59 ` kernel test robot
2021-07-27 16:59 ` kernel test robot
2021-07-27 17:34 ` Nathan Chancellor
2021-07-28  1:32   ` tangbin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.