LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] ARM/smp_twd: Cleanup the unnecessary cast
@ 2021-08-11 13:15 Tang Bin
  2021-08-11 13:31 ` Russell King (Oracle)
  2021-08-11 20:08 ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Tang Bin @ 2021-08-11 13:15 UTC (permalink / raw)
  To: linux; +Cc: linux-arm-kernel, linux-kernel, Tang Bin

It's not necessary to specify 'int' castingfor 'PTR_ERR(twd_clk)'.

Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
---
 arch/arm/kernel/smp_twd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index 9a14f721a..423e9079d 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -199,7 +199,7 @@ static void twd_get_clock(struct device_node *np)
 		twd_clk = clk_get_sys("smp_twd", NULL);
 
 	if (IS_ERR(twd_clk)) {
-		pr_err("smp_twd: clock not found %d\n", (int) PTR_ERR(twd_clk));
+		pr_err("smp_twd: clock not found %d\n", PTR_ERR(twd_clk));
 		return;
 	}
 
-- 
2.20.1.windows.1




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

* Re: [PATCH] ARM/smp_twd: Cleanup the unnecessary cast
  2021-08-11 13:15 [PATCH] ARM/smp_twd: Cleanup the unnecessary cast Tang Bin
@ 2021-08-11 13:31 ` Russell King (Oracle)
  2021-08-11 13:47   ` tangbin
  2021-08-11 20:08 ` kernel test robot
  1 sibling, 1 reply; 4+ messages in thread
From: Russell King (Oracle) @ 2021-08-11 13:31 UTC (permalink / raw)
  To: Tang Bin; +Cc: linux-arm-kernel, linux-kernel

On Wed, Aug 11, 2021 at 09:15:12PM +0800, Tang Bin wrote:
> It's not necessary to specify 'int' castingfor 'PTR_ERR(twd_clk)'.
> 
> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
> ---
>  arch/arm/kernel/smp_twd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
> index 9a14f721a..423e9079d 100644
> --- a/arch/arm/kernel/smp_twd.c
> +++ b/arch/arm/kernel/smp_twd.c
> @@ -199,7 +199,7 @@ static void twd_get_clock(struct device_node *np)
>  		twd_clk = clk_get_sys("smp_twd", NULL);
>  
>  	if (IS_ERR(twd_clk)) {
> -		pr_err("smp_twd: clock not found %d\n", (int) PTR_ERR(twd_clk));
> +		pr_err("smp_twd: clock not found %d\n", PTR_ERR(twd_clk));

Sorry, NAK.

This change _will_ produce a compiler warning. "%d" expects an argument
of type "int", but PTR_ERR() returns a type of "long". Sorry, but the
cast is entirely necessary.

A better solution today would be to get rid of the PTR_ERR() entirely
and use %pe, which will get us a textual description of the error when
the appropriate kernel configuration option is enabled.

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

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

* Re: [PATCH] ARM/smp_twd: Cleanup the unnecessary cast
  2021-08-11 13:31 ` Russell King (Oracle)
@ 2021-08-11 13:47   ` tangbin
  0 siblings, 0 replies; 4+ messages in thread
From: tangbin @ 2021-08-11 13:47 UTC (permalink / raw)
  To: Russell King (Oracle); +Cc: linux-arm-kernel, linux-kernel

Hi Russell:

On 2021/8/11 21:31, Russell King (Oracle) wrote:
> On Wed, Aug 11, 2021 at 09:15:12PM +0800, Tang Bin wrote:
>> It's not necessary to specify 'int' castingfor 'PTR_ERR(twd_clk)'.
>>
>> Signed-off-by: Tang Bin <tangbin@cmss.chinamobile.com>
>> ---
>>   arch/arm/kernel/smp_twd.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
>> index 9a14f721a..423e9079d 100644
>> --- a/arch/arm/kernel/smp_twd.c
>> +++ b/arch/arm/kernel/smp_twd.c
>> @@ -199,7 +199,7 @@ static void twd_get_clock(struct device_node *np)
>>   		twd_clk = clk_get_sys("smp_twd", NULL);
>>   
>>   	if (IS_ERR(twd_clk)) {
>> -		pr_err("smp_twd: clock not found %d\n", (int) PTR_ERR(twd_clk));
>> +		pr_err("smp_twd: clock not found %d\n", PTR_ERR(twd_clk));
> Sorry, NAK.
>
> This change _will_ produce a compiler warning. "%d" expects an argument
> of type "int", but PTR_ERR() returns a type of "long". Sorry, but the
> cast is entirely necessary.
>
> A better solution today would be to get rid of the PTR_ERR() entirely
> and use %pe, which will get us a textual description of the error when
> the appropriate kernel configuration option is enabled.
>
Got it, Thanks.
>



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

* Re: [PATCH] ARM/smp_twd: Cleanup the unnecessary cast
  2021-08-11 13:15 [PATCH] ARM/smp_twd: Cleanup the unnecessary cast Tang Bin
  2021-08-11 13:31 ` Russell King (Oracle)
@ 2021-08-11 20:08 ` kernel test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-08-11 20:08 UTC (permalink / raw)
  To: Tang Bin, linux; +Cc: kbuild-all, linux-arm-kernel, linux-kernel, Tang Bin

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

Hi Tang,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on xlnx/master]
[also build test WARNING on arm/for-next keystone/next soc/for-next rockchip/for-next arm64/for-next/core shawnguo/for-next clk/clk-next linus/master v5.14-rc5 next-20210811]
[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/ARM-smp_twd-Cleanup-the-unnecessary-cast/20210811-211613
base:   https://github.com/Xilinx/linux-xlnx master
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/d796b458f195f35962a4ca889134f542e2186b1f
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Tang-Bin/ARM-smp_twd-Cleanup-the-unnecessary-cast/20210811-211613
        git checkout d796b458f195f35962a4ca889134f542e2186b1f
        # 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/printk.h:7,
                    from include/linux/kernel.h:16,
                    from arch/arm/kernel/smp_twd.c:9:
   arch/arm/kernel/smp_twd.c: In function 'twd_get_clock':
>> include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long int' [-Wformat=]
       5 | #define KERN_SOH "\001"  /* ASCII Start Of Header */
         |                  ^~~~~~
   include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH'
      11 | #define KERN_ERR KERN_SOH "3" /* error conditions */
         |                  ^~~~~~~~
   include/linux/printk.h:343:9: note: in expansion of macro 'KERN_ERR'
     343 |  printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~~~
   arch/arm/kernel/smp_twd.c:202:3: note: in expansion of macro 'pr_err'
     202 |   pr_err("smp_twd: clock not found %d\n", PTR_ERR(twd_clk));
         |   ^~~~~~


vim +5 include/linux/kern_levels.h

314ba3520e513a Joe Perches 2012-07-30  4  
04d2c8c83d0e3a Joe Perches 2012-07-30 @5  #define KERN_SOH	"\001"		/* ASCII Start Of Header */
04d2c8c83d0e3a Joe Perches 2012-07-30  6  #define KERN_SOH_ASCII	'\001'
04d2c8c83d0e3a Joe Perches 2012-07-30  7  

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

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

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

end of thread, other threads:[~2021-08-11 20:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 13:15 [PATCH] ARM/smp_twd: Cleanup the unnecessary cast Tang Bin
2021-08-11 13:31 ` Russell King (Oracle)
2021-08-11 13:47   ` tangbin
2021-08-11 20:08 ` kernel test robot

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