From mboxrd@z Thu Jan 1 00:00:00 1970 From: Javi Merino Subject: Re: [PATCH] thermal: cpu_cooling: fix ptr_ret.cocci warnings Date: Thu, 5 Mar 2015 10:48:15 +0000 Message-ID: <20150305104815.GA2865@e104805> References: <201503050401.EJ55ouQ7%fengguang.wu@intel.com> <20150304203402.GA168719@athens.lkp.intel.com> <20150305044611.GA3632@developer.hsd1.ca.comcast.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from foss.arm.com ([217.140.101.70]:56526 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750819AbbCEKsU (ORCPT ); Thu, 5 Mar 2015 05:48:20 -0500 Content-Disposition: inline In-Reply-To: <20150305044611.GA3632@developer.hsd1.ca.comcast.net> Sender: linux-pm-owner@vger.kernel.org List-Id: linux-pm@vger.kernel.org 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 c= an be used > >=20 > >=20 > > Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR > >=20 > > Generated by: scripts/coccinelle/api/ptr_ret.cocci > >=20 > > CC: Javi Merino > > Signed-off-by: Fengguang Wu > > --- > >=20 > > cpu_cooling.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > >=20 > > --- 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 =3D=3D 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)); >=20 > This patch causes this compilation warning. >=20 > 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 =E2=80=98get_static_power=E2= =80=99: > include/linux/ratelimit.h:31:9: warning: format =E2=80=98%ld=E2=80=99= expects argument of type =E2=80=98long int=E2=80=99, but argument 4 ha= s type =E2=80=98int=E2=80=99 [-Wformat=3D] > struct ratelimit_state name =3D \ > ^ > include/linux/device.h:1162:9: note: in expansion of macro =E2=80=98D= EFINE_RATELIMIT_STATE=E2=80=99 > static DEFINE_RATELIMIT_STATE(_rs, \ > ^ > include/linux/device.h:1178:2: note: in expansion of macro =E2=80=98d= ev_level_ratelimited=E2=80=99 > dev_level_ratelimited(dev_warn, dev, fmt, ##__VA_ARGS__) > ^ > drivers/thermal/cpu_cooling.c:463:3: note: in expansion of macro =E2=80= =98dev_warn_ratelimited=E2=80=99 > 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. =46ind 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, =20 if (voltage =3D=3D 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; } =20