The parameter 'cpu' is defined as unsigned int.
However in the cpumask_next() it is implicitly type conversed
to int.
It is universally accepted that the implicit type conversion is
terrible.
Also, having the good programming custom will set an example for
others.
Thus, it might be better to change the type of 'cpu' from
unsigned int to int.
Fixes: 3e8c4d3 ("drivers: thermal: Move various drivers for intel platforms into a subdir")
Signed-off-by: Jiasheng Jiang <[email protected]>
---
drivers/thermal/intel/intel_powerclamp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c
index b0eb5ec..ed46b5e 100644
--- a/drivers/thermal/intel/intel_powerclamp.c
+++ b/drivers/thermal/intel/intel_powerclamp.c
@@ -578,7 +578,7 @@ static int powerclamp_cpu_online(unsigned int cpu)
return 0;
}
-static int powerclamp_cpu_predown(unsigned int cpu)
+static int powerclamp_cpu_predown(int cpu)
{
if (clamping == false)
return 0;
--
2.7.4
Hi Jiasheng,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on rafael-pm/thermal]
[also build test ERROR on v5.15-rc7 next-20211028]
[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/Jiasheng-Jiang/thermal-Fix-implicit-type-conversion/20211028-112252
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal
config: i386-randconfig-a004-20211027 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 5db7568a6a1fcb408eb8988abdaff2a225a8eb72)
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/07e91da90fa6847b02bff413b1a24027e4d36392
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jiasheng-Jiang/thermal-Fix-implicit-type-conversion/20211028-112252
git checkout 07e91da90fa6847b02bff413b1a24027e4d36392
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All errors (new ones prefixed by >>):
>> drivers/thermal/intel/intel_powerclamp.c:723:9: error: incompatible function pointer types passing 'int (int)' to parameter of type 'int (*)(unsigned int)' [-Werror,-Wincompatible-function-pointer-types]
powerclamp_cpu_predown);
^~~~~~~~~~~~~~~~~~~~~~
include/linux/cpuhotplug.h:317:16: note: passing argument to parameter 'teardown' here
int (*teardown)(unsigned int cpu))
^
1 error generated.
vim +723 drivers/thermal/intel/intel_powerclamp.c
cb91fef1b71954e drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 704
4d2b6e4a9ebc290 drivers/thermal/intel_powerclamp.c Mathias Krause 2015-03-25 705 static int __init powerclamp_init(void)
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 706 {
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 707 int retval;
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 708
7fc775ffebb93f2 drivers/thermal/intel/intel_powerclamp.c Christophe JAILLET 2021-09-26 709 cpu_clamping_mask = bitmap_zalloc(num_possible_cpus(), GFP_KERNEL);
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 710 if (!cpu_clamping_mask)
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 711 return -ENOMEM;
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 712
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 713 /* probe cpu features and ids here */
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 714 retval = powerclamp_probe();
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 715 if (retval)
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 716 goto exit_free;
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 717
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 718 /* set default limit, maybe adjusted during runtime based on feedback */
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 719 window_size = 2;
cb91fef1b71954e drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 720 retval = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
cb91fef1b71954e drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 721 "thermal/intel_powerclamp:online",
cb91fef1b71954e drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 722 powerclamp_cpu_online,
cb91fef1b71954e drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 @723 powerclamp_cpu_predown);
cb91fef1b71954e drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 724 if (retval < 0)
cb91fef1b71954e drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 725 goto exit_free;
cb91fef1b71954e drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 726
cb91fef1b71954e drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 727 hp_state = retval;
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 728
8d962ac7f396bc8 drivers/thermal/intel_powerclamp.c Petr Mladek 2016-11-28 729 worker_data = alloc_percpu(struct powerclamp_worker_data);
8d962ac7f396bc8 drivers/thermal/intel_powerclamp.c Petr Mladek 2016-11-28 730 if (!worker_data) {
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 731 retval = -ENOMEM;
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 732 goto exit_unregister;
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 733 }
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 734
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 735 cooling_dev = thermal_cooling_device_register("intel_powerclamp", NULL,
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 736 &powerclamp_cooling_ops);
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 737 if (IS_ERR(cooling_dev)) {
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 738 retval = -ENODEV;
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 739 goto exit_free_thread;
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 740 }
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 741
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 742 if (!duration)
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 743 duration = jiffies_to_msecs(DEFAULT_DURATION_JIFFIES);
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 744
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 745 powerclamp_create_debug_files();
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 746
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 747 return 0;
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 748
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 749 exit_free_thread:
8d962ac7f396bc8 drivers/thermal/intel_powerclamp.c Petr Mladek 2016-11-28 750 free_percpu(worker_data);
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 751 exit_unregister:
cb91fef1b71954e drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 752 cpuhp_remove_state_nocalls(hp_state);
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 753 exit_free:
7fc775ffebb93f2 drivers/thermal/intel/intel_powerclamp.c Christophe JAILLET 2021-09-26 754 bitmap_free(cpu_clamping_mask);
c32a5087b70a670 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 755 return retval;
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 756 }
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 757 module_init(powerclamp_init);
d6d71ee4a14ae60 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 758
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
Hi Jiasheng,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on rafael-pm/thermal]
[also build test ERROR on v5.15-rc7 next-20211028]
[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/Jiasheng-Jiang/thermal-Fix-implicit-type-conversion/20211028-112252
base: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git thermal
config: x86_64-randconfig-a015-20211027 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/07e91da90fa6847b02bff413b1a24027e4d36392
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jiasheng-Jiang/thermal-Fix-implicit-type-conversion/20211028-112252
git checkout 07e91da90fa6847b02bff413b1a24027e4d36392
# save the attached .config to linux build tree
make W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
All errors (new ones prefixed by >>):
drivers/thermal/intel/intel_powerclamp.c: In function 'powerclamp_init':
>> drivers/thermal/intel/intel_powerclamp.c:723:9: error: passing argument 4 of 'cpuhp_setup_state_nocalls' from incompatible pointer type [-Werror=incompatible-pointer-types]
723 | powerclamp_cpu_predown);
| ^~~~~~~~~~~~~~~~~~~~~~
| |
| int (*)(int)
In file included from include/linux/cpu.h:20,
from drivers/thermal/intel/intel_powerclamp.c:31:
include/linux/cpuhotplug.h:317:16: note: expected 'int (*)(unsigned int)' but argument is of type 'int (*)(int)'
317 | int (*teardown)(unsigned int cpu))
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/cpuhp_setup_state_nocalls +723 drivers/thermal/intel/intel_powerclamp.c
cb91fef1b71954 drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 704
4d2b6e4a9ebc29 drivers/thermal/intel_powerclamp.c Mathias Krause 2015-03-25 705 static int __init powerclamp_init(void)
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 706 {
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 707 int retval;
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 708
7fc775ffebb93f drivers/thermal/intel/intel_powerclamp.c Christophe JAILLET 2021-09-26 709 cpu_clamping_mask = bitmap_zalloc(num_possible_cpus(), GFP_KERNEL);
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 710 if (!cpu_clamping_mask)
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 711 return -ENOMEM;
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 712
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 713 /* probe cpu features and ids here */
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 714 retval = powerclamp_probe();
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 715 if (retval)
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 716 goto exit_free;
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 717
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 718 /* set default limit, maybe adjusted during runtime based on feedback */
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 719 window_size = 2;
cb91fef1b71954 drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 720 retval = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
cb91fef1b71954 drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 721 "thermal/intel_powerclamp:online",
cb91fef1b71954 drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 722 powerclamp_cpu_online,
cb91fef1b71954 drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 @723 powerclamp_cpu_predown);
cb91fef1b71954 drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 724 if (retval < 0)
cb91fef1b71954 drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 725 goto exit_free;
cb91fef1b71954 drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 726
cb91fef1b71954 drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 727 hp_state = retval;
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 728
8d962ac7f396bc drivers/thermal/intel_powerclamp.c Petr Mladek 2016-11-28 729 worker_data = alloc_percpu(struct powerclamp_worker_data);
8d962ac7f396bc drivers/thermal/intel_powerclamp.c Petr Mladek 2016-11-28 730 if (!worker_data) {
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 731 retval = -ENOMEM;
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 732 goto exit_unregister;
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 733 }
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 734
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 735 cooling_dev = thermal_cooling_device_register("intel_powerclamp", NULL,
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 736 &powerclamp_cooling_ops);
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 737 if (IS_ERR(cooling_dev)) {
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 738 retval = -ENODEV;
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 739 goto exit_free_thread;
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 740 }
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 741
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 742 if (!duration)
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 743 duration = jiffies_to_msecs(DEFAULT_DURATION_JIFFIES);
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 744
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 745 powerclamp_create_debug_files();
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 746
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 747 return 0;
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 748
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 749 exit_free_thread:
8d962ac7f396bc drivers/thermal/intel_powerclamp.c Petr Mladek 2016-11-28 750 free_percpu(worker_data);
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 751 exit_unregister:
cb91fef1b71954 drivers/thermal/intel_powerclamp.c Sebastian Andrzej Siewior 2016-11-28 752 cpuhp_remove_state_nocalls(hp_state);
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 753 exit_free:
7fc775ffebb93f drivers/thermal/intel/intel_powerclamp.c Christophe JAILLET 2021-09-26 754 bitmap_free(cpu_clamping_mask);
c32a5087b70a67 drivers/thermal/intel_powerclamp.c [email protected] 2013-10-04 755 return retval;
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 756 }
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 757 module_init(powerclamp_init);
d6d71ee4a14ae6 drivers/thermal/intel_powerclamp.c Jacob Pan 2013-01-21 758
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
On Thu, Oct 28, 2021 at 5:22 AM Jiasheng Jiang <[email protected]> wrote:
>
> The parameter 'cpu' is defined as unsigned int.
> However in the cpumask_next() it is implicitly type conversed
> to int.
> It is universally accepted that the implicit type conversion is
> terrible.
> Also, having the good programming custom will set an example for
> others.
> Thus, it might be better to change the type of 'cpu' from
> unsigned int to int.
>
> Fixes: 3e8c4d3 ("drivers: thermal: Move various drivers for intel platforms into a subdir")
> Signed-off-by: Jiasheng Jiang <[email protected]>
> ---
> drivers/thermal/intel/intel_powerclamp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c
> index b0eb5ec..ed46b5e 100644
> --- a/drivers/thermal/intel/intel_powerclamp.c
> +++ b/drivers/thermal/intel/intel_powerclamp.c
> @@ -578,7 +578,7 @@ static int powerclamp_cpu_online(unsigned int cpu)
> return 0;
> }
>
> -static int powerclamp_cpu_predown(unsigned int cpu)
> +static int powerclamp_cpu_predown(int cpu)
> {
> if (clamping == false)
> return 0;
> --
I'm not going to consider any patches of this type, because IMO they
are not improvements.
Thanks!