From patchwork Mon Oct 8 21:01:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Bolle X-Patchwork-Id: 1566971 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id C354B40135 for ; Mon, 8 Oct 2012 21:15:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 77D579F369 for ; Mon, 8 Oct 2012 14:15:02 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 783 seconds by postgrey-1.32 at gabe; Mon, 08 Oct 2012 23:14:48 CEST Received: from cpsmtpb-ews03.kpnxchange.com (cpsmtpb-ews03.kpnxchange.com [213.75.39.6]) by gabe.freedesktop.org (Postfix) with ESMTP id E72969E861 for ; Mon, 8 Oct 2012 14:14:48 -0700 (PDT) Received: from cpsps-ews28.kpnxchange.com ([10.94.84.194]) by cpsmtpb-ews03.kpnxchange.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 8 Oct 2012 23:01:43 +0200 Received: from CPSMTPM-TLF103.kpnxchange.com ([195.121.3.6]) by cpsps-ews28.kpnxchange.com with Microsoft SMTPSVC(7.5.7601.17514); Mon, 8 Oct 2012 23:01:43 +0200 Received: from [192.168.1.101] ([212.123.169.34]) by CPSMTPM-TLF103.kpnxchange.com with Microsoft SMTPSVC(7.5.7601.17514); Mon, 8 Oct 2012 23:01:43 +0200 Message-ID: <1349730102.1397.24.camel@x61.thuisdomein> Subject: [PATCH] drm/nv40/pm: silence GCC warnings From: Paul Bolle To: David Airlie Date: Mon, 08 Oct 2012 23:01:42 +0200 X-Mailer: Evolution 3.4.4 (3.4.4-2.fc17) Mime-Version: 1.0 X-OriginalArrivalTime: 08 Oct 2012 21:01:43.0440 (UTC) FILETIME=[1ED37900:01CDA598] X-RcptDomain: lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Building nv40_pm.o triggers these GCC warnings: drivers/gpu/drm/nouveau/nv40_pm.c: In function 'nv40_pm_clocks_pre': drivers/gpu/drm/nouveau/nv40_pm.c:164:41: warning: 'log2P' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/gpu/drm/nouveau/nv40_pm.c:165:38: warning: 'M2' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/gpu/drm/nouveau/nv40_pm.c:165:45: warning: 'M1' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/gpu/drm/nouveau/nv40_pm.c:165:25: warning: 'N2' may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/gpu/drm/nouveau/nv40_pm.c:165:51: warning: 'N1' may be used uninitialized in this function [-Wmaybe-uninitialized] But these variables seem to be initialized when used there. If the preceding call of nv40_calc_pll() fails it will return a negative value and this code will never be run. And if that call succeeds it will return zero and all those five variables ought to be initialized when used there. Anyhow, it turns out that these warnings can be silenced by giving GCC slightly more detailed information a little earlier. See, get_pll_limits() returns an error-code integer (ie, negative on failure, zero on success). And a trivial tweak to nv40_calc_pll() that takes this into account makes these errors go away. Signed-off-by: Paul Bolle --- 0) I noticed these warnings while building recent releases (eg, v3.6-rc7, v3.6, and v3.6.1) on current Fedora 17, using Fedora's default config. But I found identical warnings in a build log for release v3.4-rc1. I didn't bother checking earlier releases. 1) Compile tested only (I do not have the hardware involved at hand). 2) This is not the only place where get_pll_limits()'s return value is checked. But this is apparently the only place where GCC needs to know that any non-zero return will be negative. drivers/gpu/drm/nouveau/nv40_pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nv40_pm.c b/drivers/gpu/drm/nouveau/nv40_pm.c index e66273a..3df30cb 100644 --- a/drivers/gpu/drm/nouveau/nv40_pm.c +++ b/drivers/gpu/drm/nouveau/nv40_pm.c @@ -114,7 +114,7 @@ nv40_calc_pll(struct drm_device *dev, u32 reg, struct pll_lims *pll, int ret; ret = get_pll_limits(dev, reg, pll); - if (ret) + if (ret < 0) return ret; if (clk < pll->vco1.maxfreq)