* [PATCH] thermal: cpu_cooling: fix ptr_ret.cocci warnings
[not found] <201503050401.EJ55ouQ7%fengguang.wu@intel.com>
@ 2015-03-04 20:34 ` kbuild test robot
2015-03-05 4:46 ` Eduardo Valentin
0 siblings, 1 reply; 3+ messages in thread
From: kbuild test robot @ 2015-03-04 20:34 UTC (permalink / raw)
To: Javi Merino
Cc: kbuild-all, Eduardo Valentin, Kapileshwar Singh, Punit Agrawal,
Zhang Rui, linux-pm, linux-kernel
drivers/thermal/cpu_cooling.c:463:18-24: WARNING: PTR_ERR_OR_ZERO can be used
Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
Generated by: scripts/coccinelle/api/ptr_ret.cocci
CC: Javi Merino <javi.merino@arm.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---
cpu_cooling.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -460,7 +460,7 @@ static int get_static_power(struct cpufr
if (voltage == 0) {
dev_warn_ratelimited(cpufreq_device->cpu_dev,
"Failed to get voltage for frequency %lu: %ld\n",
- freq_hz, IS_ERR(opp) ? PTR_ERR(opp) : 0);
+ freq_hz, PTR_ERR_OR_ZERO(opp));
return -EINVAL;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal: cpu_cooling: fix ptr_ret.cocci warnings
2015-03-04 20:34 ` [PATCH] thermal: cpu_cooling: fix ptr_ret.cocci warnings kbuild test robot
@ 2015-03-05 4:46 ` Eduardo Valentin
2015-03-05 10:48 ` Javi Merino
0 siblings, 1 reply; 3+ messages in thread
From: Eduardo Valentin @ 2015-03-05 4:46 UTC (permalink / raw)
To: kbuild test robot
Cc: Javi Merino, kbuild-all, Kapileshwar Singh, Punit Agrawal,
Zhang Rui, linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1809 bytes --]
On Thu, Mar 05, 2015 at 04:34:02AM +0800, kbuild test robot wrote:
> drivers/thermal/cpu_cooling.c:463:18-24: WARNING: PTR_ERR_OR_ZERO can be used
>
>
> Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
>
> Generated by: scripts/coccinelle/api/ptr_ret.cocci
>
> CC: Javi Merino <javi.merino@arm.com>
> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> ---
>
> cpu_cooling.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- a/drivers/thermal/cpu_cooling.c
> +++ b/drivers/thermal/cpu_cooling.c
> @@ -460,7 +460,7 @@ static int get_static_power(struct cpufr
> if (voltage == 0) {
> dev_warn_ratelimited(cpufreq_device->cpu_dev,
> "Failed to get voltage for frequency %lu: %ld\n",
> - freq_hz, IS_ERR(opp) ? PTR_ERR(opp) : 0);
> + freq_hz, PTR_ERR_OR_ZERO(opp));
This patch causes this compilation warning.
In file included from include/linux/device.h:27:0,
from include/linux/thermal.h:30,
from drivers/thermal/cpu_cooling.c:26:
drivers/thermal/cpu_cooling.c: In function ‘get_static_power’:
include/linux/ratelimit.h:31:9: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘int’ [-Wformat=]
struct ratelimit_state name = \
^
include/linux/device.h:1162:9: note: in expansion of macro ‘DEFINE_RATELIMIT_STATE’
static DEFINE_RATELIMIT_STATE(_rs, \
^
include/linux/device.h:1178:2: note: in expansion of macro ‘dev_level_ratelimited’
dev_level_ratelimited(dev_warn, dev, fmt, ##__VA_ARGS__)
^
drivers/thermal/cpu_cooling.c:463:3: note: in expansion of macro ‘dev_warn_ratelimited’
dev_warn_ratelimited(cpufreq_device->cpu_dev,
^
> return -EINVAL;
> }
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] thermal: cpu_cooling: fix ptr_ret.cocci warnings
2015-03-05 4:46 ` Eduardo Valentin
@ 2015-03-05 10:48 ` Javi Merino
0 siblings, 0 replies; 3+ messages in thread
From: Javi Merino @ 2015-03-05 10:48 UTC (permalink / raw)
To: Eduardo Valentin
Cc: kbuild test robot, kbuild-all@01.org, Kapileshwar Singh,
Punit Agrawal, Zhang Rui, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
On Thu, Mar 05, 2015 at 04:46:13AM +0000, Eduardo Valentin wrote:
> On Thu, Mar 05, 2015 at 04:34:02AM +0800, kbuild test robot wrote:
> > drivers/thermal/cpu_cooling.c:463:18-24: WARNING: PTR_ERR_OR_ZERO can be used
> >
> >
> > Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
> >
> > Generated by: scripts/coccinelle/api/ptr_ret.cocci
> >
> > CC: Javi Merino <javi.merino@arm.com>
> > Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> > ---
> >
> > cpu_cooling.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > --- a/drivers/thermal/cpu_cooling.c
> > +++ b/drivers/thermal/cpu_cooling.c
> > @@ -460,7 +460,7 @@ static int get_static_power(struct cpufr
> > if (voltage == 0) {
> > dev_warn_ratelimited(cpufreq_device->cpu_dev,
> > "Failed to get voltage for frequency %lu: %ld\n",
> > - freq_hz, IS_ERR(opp) ? PTR_ERR(opp) : 0);
> > + freq_hz, PTR_ERR_OR_ZERO(opp));
>
> This patch causes this compilation warning.
>
> In file included from include/linux/device.h:27:0,
> from include/linux/thermal.h:30,
> from drivers/thermal/cpu_cooling.c:26:
> drivers/thermal/cpu_cooling.c: In function ‘get_static_power’:
> include/linux/ratelimit.h:31:9: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘int’ [-Wformat=]
> struct ratelimit_state name = \
> ^
> include/linux/device.h:1162:9: note: in expansion of macro ‘DEFINE_RATELIMIT_STATE’
> static DEFINE_RATELIMIT_STATE(_rs, \
> ^
> include/linux/device.h:1178:2: note: in expansion of macro ‘dev_level_ratelimited’
> dev_level_ratelimited(dev_warn, dev, fmt, ##__VA_ARGS__)
> ^
> drivers/thermal/cpu_cooling.c:463:3: note: in expansion of macro ‘dev_warn_ratelimited’
> dev_warn_ratelimited(cpufreq_device->cpu_dev,
> ^
PTR_ERR_OR_ZERO() has the wrong signature in my opinion. PTR_ERR()
returns a long but PTR_ERR_OR_ZERO() returns an int. I think
PTR_ERR_OR_ZERO() should return a long so that it can be a truly
replacement for "IS_ERR(x) ? PTR_ERR(x) : 0". It's probably not
worth the churn though.
Find the correct fix below. Do you want me to send a proper patch?
---8<---
--- a/drivers/thermal/cpu_cooling.c
+++ b/drivers/thermal/cpu_cooling.c
@@ -461,8 +461,8 @@ static int get_static_power(struct cpufreq_cooling_device *cpufreq_device,
if (voltage == 0) {
dev_warn_ratelimited(cpufreq_device->cpu_dev,
- "Failed to get voltage for frequency %lu: %ld\n",
- freq_hz, IS_ERR(opp) ? PTR_ERR(opp) : 0);
+ "Failed to get voltage for frequency %lu: %d\n",
+ freq_hz, PTR_ERR_OR_ZERO(opp));
return -EINVAL;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-05 10:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <201503050401.EJ55ouQ7%fengguang.wu@intel.com>
2015-03-04 20:34 ` [PATCH] thermal: cpu_cooling: fix ptr_ret.cocci warnings kbuild test robot
2015-03-05 4:46 ` Eduardo Valentin
2015-03-05 10:48 ` Javi Merino
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).