diff mbox series

ARM/smp_twd: Cleanup the unnecessary cast

Message ID 20210811131512.940-1-tangbin@cmss.chinamobile.com (mailing list archive)
State New, archived
Headers show
Series ARM/smp_twd: Cleanup the unnecessary cast | expand

Commit Message

Tang Bin Aug. 11, 2021, 1:15 p.m. UTC
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(-)

Comments

Russell King (Oracle) Aug. 11, 2021, 1:31 p.m. UTC | #1
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.
Tang Bin Aug. 11, 2021, 1:47 p.m. UTC | #2
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.
>
kernel test robot Aug. 11, 2021, 8:08 p.m. UTC | #3
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
diff mbox series

Patch

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;
 	}