diff mbox

thermal: cpu_cooling: fix ptr_ret.cocci warnings

Message ID 20150304203402.GA168719@athens.lkp.intel.com (mailing list archive)
State Changes Requested
Delegated to: Eduardo Valentin
Headers show

Commit Message

Fengguang Wu March 4, 2015, 8:34 p.m. UTC
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(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Eduardo Valentin March 5, 2015, 4:46 a.m. UTC | #1
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;
>  	}
>
diff mbox

Patch

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