All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: w1: slaves: Drop unnecessary explicit casting
@ 2023-04-20  0:21 Anup Sharma
  2023-04-20  2:35 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Anup Sharma @ 2023-04-20  0:21 UTC (permalink / raw)
  To: zbr; +Cc: linux-kernel

Provide correct specifiers while printing error logs to discard the use
of unnecessary explicit casting.

Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>
---
 drivers/w1/slaves/w1_ds2433.c  | 6 +++---
 drivers/w1/slaves/w1_ds28e04.c | 8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c
index 0f72df15a024..ba441d42b0b0 100644
--- a/drivers/w1/slaves/w1_ds2433.c
+++ b/drivers/w1/slaves/w1_ds2433.c
@@ -213,15 +213,15 @@ static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
 #ifdef CONFIG_W1_SLAVE_DS2433_CRC
 	/* can only write full blocks in cached mode */
 	if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) {
-		dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n",
-			(int)off, count);
+		dev_err(&sl->dev, "invalid offset/count off=%pe cnt=%zd\n",
+			off, count);
 		return -EINVAL;
 	}
 
 	/* make sure the block CRCs are valid */
 	for (idx = 0; idx < count; idx += W1_PAGE_SIZE) {
 		if (crc16(CRC16_INIT, &buf[idx], W1_PAGE_SIZE) != CRC16_VALID) {
-			dev_err(&sl->dev, "bad CRC at offset %d\n", (int)off);
+			dev_err(&sl->dev, "bad CRC at offset %pe\n", off);
 			return -EINVAL;
 		}
 	}
diff --git a/drivers/w1/slaves/w1_ds28e04.c b/drivers/w1/slaves/w1_ds28e04.c
index 6cef6e2edb89..6edfe6a4600a 100644
--- a/drivers/w1/slaves/w1_ds28e04.c
+++ b/drivers/w1/slaves/w1_ds28e04.c
@@ -234,8 +234,8 @@ static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
 	if (w1_enable_crccheck) {
 		/* can only write full blocks in cached mode */
 		if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) {
-			dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n",
-				(int)off, count);
+			dev_err(&sl->dev, "invalid offset/count off=%pe cnt=%zd\n",
+				off, count);
 			return -EINVAL;
 		}
 
@@ -243,8 +243,8 @@ static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
 		for (idx = 0; idx < count; idx += W1_PAGE_SIZE) {
 			if (crc16(CRC16_INIT, &buf[idx], W1_PAGE_SIZE)
 				!= CRC16_VALID) {
-				dev_err(&sl->dev, "bad CRC at offset %d\n",
-					(int)off);
+				dev_err(&sl->dev, "bad CRC at offset %pe\n",
+					off);
 				return -EINVAL;
 			}
 		}
-- 
2.34.1


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

* Re: [PATCH] drivers: w1: slaves: Drop unnecessary explicit casting
  2023-04-20  0:21 [PATCH] drivers: w1: slaves: Drop unnecessary explicit casting Anup Sharma
@ 2023-04-20  2:35 ` kernel test robot
  2023-04-20  6:29 ` kernel test robot
  2023-04-23 13:38 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-04-20  2:35 UTC (permalink / raw)
  To: Anup Sharma, zbr; +Cc: oe-kbuild-all, linux-kernel

Hi Anup,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.3-rc7 next-20230419]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Anup-Sharma/drivers-w1-slaves-Drop-unnecessary-explicit-casting/20230420-082340
patch link:    https://lore.kernel.org/r/ZECFjQMLwnoYPMeL%40yoga
patch subject: [PATCH] drivers: w1: slaves: Drop unnecessary explicit casting
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230420/202304201037.YqeNgQrk-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 12.1.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/intel-lab-lkp/linux/commit/211461ea088a31e3a084fd539e243c9d32db3cb6
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Anup-Sharma/drivers-w1-slaves-Drop-unnecessary-explicit-casting/20230420-082340
        git checkout 211461ea088a31e3a084fd539e243c9d32db3cb6
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash drivers/w1/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304201037.YqeNgQrk-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from include/linux/device.h:15,
                    from drivers/w1/slaves/w1_ds2433.c:11:
   drivers/w1/slaves/w1_ds2433.c: In function 'eeprom_write':
>> drivers/w1/slaves/w1_ds2433.c:216:35: warning: format '%p' expects argument of type 'void *', but argument 3 has type 'loff_t' {aka 'long long int'} [-Wformat=]
     216 |                 dev_err(&sl->dev, "invalid offset/count off=%pe cnt=%zd\n",
         |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
     144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                        ^~~~~~~
   drivers/w1/slaves/w1_ds2433.c:216:17: note: in expansion of macro 'dev_err'
     216 |                 dev_err(&sl->dev, "invalid offset/count off=%pe cnt=%zd\n",
         |                 ^~~~~~~
   drivers/w1/slaves/w1_ds2433.c:216:62: note: format string is defined here
     216 |                 dev_err(&sl->dev, "invalid offset/count off=%pe cnt=%zd\n",
         |                                                             ~^
         |                                                              |
         |                                                              void *
         |                                                             %lld
   drivers/w1/slaves/w1_ds2433.c:224:43: warning: format '%p' expects argument of type 'void *', but argument 3 has type 'loff_t' {aka 'long long int'} [-Wformat=]
     224 |                         dev_err(&sl->dev, "bad CRC at offset %pe\n", off);
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
     144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                        ^~~~~~~
   drivers/w1/slaves/w1_ds2433.c:224:25: note: in expansion of macro 'dev_err'
     224 |                         dev_err(&sl->dev, "bad CRC at offset %pe\n", off);
         |                         ^~~~~~~
   drivers/w1/slaves/w1_ds2433.c:224:63: note: format string is defined here
     224 |                         dev_err(&sl->dev, "bad CRC at offset %pe\n", off);
         |                                                              ~^
         |                                                               |
         |                                                               void *
         |                                                              %lld
--
   In file included from include/linux/device.h:15,
                    from drivers/w1/slaves/w1_ds28e04.c:11:
   drivers/w1/slaves/w1_ds28e04.c: In function 'eeprom_write':
>> drivers/w1/slaves/w1_ds28e04.c:237:43: warning: format '%p' expects argument of type 'void *', but argument 3 has type 'loff_t' {aka 'long long int'} [-Wformat=]
     237 |                         dev_err(&sl->dev, "invalid offset/count off=%pe cnt=%zd\n",
         |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
     144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                        ^~~~~~~
   drivers/w1/slaves/w1_ds28e04.c:237:25: note: in expansion of macro 'dev_err'
     237 |                         dev_err(&sl->dev, "invalid offset/count off=%pe cnt=%zd\n",
         |                         ^~~~~~~
   drivers/w1/slaves/w1_ds28e04.c:237:70: note: format string is defined here
     237 |                         dev_err(&sl->dev, "invalid offset/count off=%pe cnt=%zd\n",
         |                                                                     ~^
         |                                                                      |
         |                                                                      void *
         |                                                                     %lld
   drivers/w1/slaves/w1_ds28e04.c:246:51: warning: format '%p' expects argument of type 'void *', but argument 3 has type 'loff_t' {aka 'long long int'} [-Wformat=]
     246 |                                 dev_err(&sl->dev, "bad CRC at offset %pe\n",
         |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:110:30: note: in definition of macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                              ^~~
   include/linux/dev_printk.h:144:56: note: in expansion of macro 'dev_fmt'
     144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                        ^~~~~~~
   drivers/w1/slaves/w1_ds28e04.c:246:33: note: in expansion of macro 'dev_err'
     246 |                                 dev_err(&sl->dev, "bad CRC at offset %pe\n",
         |                                 ^~~~~~~
   drivers/w1/slaves/w1_ds28e04.c:246:71: note: format string is defined here
     246 |                                 dev_err(&sl->dev, "bad CRC at offset %pe\n",
         |                                                                      ~^
         |                                                                       |
         |                                                                       void *
         |                                                                      %lld


vim +216 drivers/w1/slaves/w1_ds2433.c

   202	
   203	static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
   204				    struct bin_attribute *bin_attr, char *buf,
   205				    loff_t off, size_t count)
   206	{
   207		struct w1_slave *sl = kobj_to_w1_slave(kobj);
   208		int addr, len, idx;
   209	
   210		if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0)
   211			return 0;
   212	
   213	#ifdef CONFIG_W1_SLAVE_DS2433_CRC
   214		/* can only write full blocks in cached mode */
   215		if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) {
 > 216			dev_err(&sl->dev, "invalid offset/count off=%pe cnt=%zd\n",
   217				off, count);
   218			return -EINVAL;
   219		}
   220	
   221		/* make sure the block CRCs are valid */
   222		for (idx = 0; idx < count; idx += W1_PAGE_SIZE) {
   223			if (crc16(CRC16_INIT, &buf[idx], W1_PAGE_SIZE) != CRC16_VALID) {
   224				dev_err(&sl->dev, "bad CRC at offset %pe\n", off);
   225				return -EINVAL;
   226			}
   227		}
   228	#endif	/* CONFIG_W1_SLAVE_DS2433_CRC */
   229	
   230		mutex_lock(&sl->master->bus_mutex);
   231	
   232		/* Can only write data to one page at a time */
   233		idx = 0;
   234		while (idx < count) {
   235			addr = off + idx;
   236			len = W1_PAGE_SIZE - (addr & W1_PAGE_MASK);
   237			if (len > (count - idx))
   238				len = count - idx;
   239	
   240			if (w1_f23_write(sl, addr, len, &buf[idx]) < 0) {
   241				count = -EIO;
   242				goto out_up;
   243			}
   244			idx += len;
   245		}
   246	
   247	out_up:
   248		mutex_unlock(&sl->master->bus_mutex);
   249	
   250		return count;
   251	}
   252	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

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

* Re: [PATCH] drivers: w1: slaves: Drop unnecessary explicit casting
  2023-04-20  0:21 [PATCH] drivers: w1: slaves: Drop unnecessary explicit casting Anup Sharma
  2023-04-20  2:35 ` kernel test robot
@ 2023-04-20  6:29 ` kernel test robot
  2023-04-23 13:38 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2023-04-20  6:29 UTC (permalink / raw)
  To: Anup Sharma, zbr; +Cc: llvm, oe-kbuild-all, linux-kernel

Hi Anup,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.3-rc7 next-20230419]
[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#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Anup-Sharma/drivers-w1-slaves-Drop-unnecessary-explicit-casting/20230420-082340
patch link:    https://lore.kernel.org/r/ZECFjQMLwnoYPMeL%40yoga
patch subject: [PATCH] drivers: w1: slaves: Drop unnecessary explicit casting
config: x86_64-randconfig-a015-20230417 (https://download.01.org/0day-ci/archive/20230420/202304201411.fS7y0KJP-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
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/intel-lab-lkp/linux/commit/211461ea088a31e3a084fd539e243c9d32db3cb6
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Anup-Sharma/drivers-w1-slaves-Drop-unnecessary-explicit-casting/20230420-082340
        git checkout 211461ea088a31e3a084fd539e243c9d32db3cb6
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/w1/slaves/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304201411.fS7y0KJP-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/w1/slaves/w1_ds28e04.c:238:5: warning: format specifies type 'void *' but the argument has type 'loff_t' (aka 'long long') [-Wformat]
                                   off, count);
                                   ^~~
   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/w1/slaves/w1_ds28e04.c:247:6: warning: format specifies type 'void *' but the argument has type 'loff_t' (aka 'long long') [-Wformat]
                                           off);
                                           ^~~
   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__);                       \
                                ~~~    ^~~~~~~~~~~
   2 warnings generated.


vim +238 drivers/w1/slaves/w1_ds28e04.c

   221	
   222	static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
   223				    struct bin_attribute *bin_attr, char *buf,
   224				    loff_t off, size_t count)
   225	
   226	{
   227		struct w1_slave *sl = kobj_to_w1_slave(kobj);
   228		int addr, len, idx;
   229	
   230		count = w1_f1C_fix_count(off, count, W1_EEPROM_SIZE);
   231		if (count == 0)
   232			return 0;
   233	
   234		if (w1_enable_crccheck) {
   235			/* can only write full blocks in cached mode */
   236			if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) {
   237				dev_err(&sl->dev, "invalid offset/count off=%pe cnt=%zd\n",
 > 238					off, count);
   239				return -EINVAL;
   240			}
   241	
   242			/* make sure the block CRCs are valid */
   243			for (idx = 0; idx < count; idx += W1_PAGE_SIZE) {
   244				if (crc16(CRC16_INIT, &buf[idx], W1_PAGE_SIZE)
   245					!= CRC16_VALID) {
   246					dev_err(&sl->dev, "bad CRC at offset %pe\n",
   247						off);
   248					return -EINVAL;
   249				}
   250			}
   251		}
   252	
   253		mutex_lock(&sl->master->mutex);
   254	
   255		/* Can only write data to one page at a time */
   256		idx = 0;
   257		while (idx < count) {
   258			addr = off + idx;
   259			len = W1_PAGE_SIZE - (addr & W1_PAGE_MASK);
   260			if (len > (count - idx))
   261				len = count - idx;
   262	
   263			if (w1_f1C_write(sl, addr, len, &buf[idx]) < 0) {
   264				count = -EIO;
   265				goto out_up;
   266			}
   267			idx += len;
   268		}
   269	
   270	out_up:
   271		mutex_unlock(&sl->master->mutex);
   272	
   273		return count;
   274	}
   275	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

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

* Re: [PATCH] drivers: w1: slaves: Drop unnecessary explicit casting
  2023-04-20  0:21 [PATCH] drivers: w1: slaves: Drop unnecessary explicit casting Anup Sharma
  2023-04-20  2:35 ` kernel test robot
  2023-04-20  6:29 ` kernel test robot
@ 2023-04-23 13:38 ` Krzysztof Kozlowski
  2 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2023-04-23 13:38 UTC (permalink / raw)
  To: Anup Sharma, zbr; +Cc: linux-kernel

On 20/04/2023 02:21, Anup Sharma wrote:
> Provide correct specifiers while printing error logs to discard the use
> of unnecessary explicit casting.
> 
> Signed-off-by: Anup Sharma <anupnewsmail@gmail.com>
> ---
>  drivers/w1/slaves/w1_ds2433.c  | 6 +++---
>  drivers/w1/slaves/w1_ds28e04.c | 8 ++++----
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/w1/slaves/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c
> index 0f72df15a024..ba441d42b0b0 100644
> --- a/drivers/w1/slaves/w1_ds2433.c
> +++ b/drivers/w1/slaves/w1_ds2433.c
> @@ -213,15 +213,15 @@ static ssize_t eeprom_write(struct file *filp, struct kobject *kobj,
>  #ifdef CONFIG_W1_SLAVE_DS2433_CRC
>  	/* can only write full blocks in cached mode */
>  	if ((off & W1_PAGE_MASK) || (count & W1_PAGE_MASK)) {
> -		dev_err(&sl->dev, "invalid offset/count off=%d cnt=%zd\n",
> -			(int)off, count);
> +		dev_err(&sl->dev, "invalid offset/count off=%pe cnt=%zd\n",
> +			off, count);

I don't think you tested this patch. Why do you think off is a pointer?

Best regards,
Krzysztof


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

end of thread, other threads:[~2023-04-23 13:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20  0:21 [PATCH] drivers: w1: slaves: Drop unnecessary explicit casting Anup Sharma
2023-04-20  2:35 ` kernel test robot
2023-04-20  6:29 ` kernel test robot
2023-04-23 13:38 ` Krzysztof Kozlowski

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.