From patchwork Thu Mar 5 10:48:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javi Merino X-Patchwork-Id: 5944761 X-Patchwork-Delegate: eduardo.valentin@ti.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 99FDDBF440 for ; Thu, 5 Mar 2015 10:48:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B9A4E2037F for ; Thu, 5 Mar 2015 10:48:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1C2C2034C for ; Thu, 5 Mar 2015 10:48:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751273AbbCEKsV (ORCPT ); Thu, 5 Mar 2015 05:48:21 -0500 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 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6D6B72A; Thu, 5 Mar 2015 02:48:40 -0800 (PST) Received: from e104805 (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 586803F2EE; Thu, 5 Mar 2015 02:48:18 -0800 (PST) Date: Thu, 5 Mar 2015 10:48:15 +0000 From: Javi Merino 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" Subject: Re: [PATCH] thermal: cpu_cooling: fix ptr_ret.cocci warnings 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-Disposition: inline In-Reply-To: <20150305044611.GA3632@developer.hsd1.ca.comcast.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 > > Signed-off-by: Fengguang Wu > > --- > > > > 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<--- --- 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 --- 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; }