From patchwork Tue Jul 21 08:30:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 6833151 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2D3F09F380 for ; Tue, 21 Jul 2015 08:30:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 517C920670 for ; Tue, 21 Jul 2015 08:30:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E0A720648 for ; Tue, 21 Jul 2015 08:30:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753656AbbGUIa4 (ORCPT ); Tue, 21 Jul 2015 04:30:56 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:55604 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753144AbbGUIaz (ORCPT ); Tue, 21 Jul 2015 04:30:55 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1ZHR5F-0001e7-UN; Tue, 21 Jul 2015 08:31:21 +0200 Received: from ukl by dude.hi.pengutronix.de with local (Exim 4.86_RC4) (envelope-from ) id 1ZHSwn-00023c-54; Tue, 21 Jul 2015 10:30:45 +0200 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Mark Brown Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, linux-spi@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH] spi: mpc512x-psc: fix compiler warning about uninitialized variable Date: Tue, 21 Jul 2015 10:30:42 +0200 Message-Id: <1437467442-7011-1-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-spi@vger.kernel.org Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 This fixes several warnings like: drivers/spi/spi-mpc512x-psc.c: In function 'mpc512x_psc_spi_prep_xfer_hw': arch/powerpc/include/asm/io.h:163:2: warning: '__ret' may be used uninitialized in this function [-Wmaybe-uninitialized] introduced in commit 8bf960985dfc for some build configurations. Fixes: 8bf960985dfc ("spi: mpc512x-psc: add support for Freescale MPC5125") Signed-off-by: Uwe Kleine-König --- Hello, didn't check why "my" config doesn't throw this warning, but I could reproduce and fix it with the .config and toolchain as suggested by the build bot's report. An alternatives is to introduce a default case that BUG()s, but I think there is not much benefit over the NULL pointer exception that I introduced with my commit. I expected that giving the enum I introduced a name and using this to type the variable should do the trick, but this didn't made the compiler happy. Best regards Uwe drivers/spi/spi-mpc512x-psc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-mpc512x-psc.c b/drivers/spi/spi-mpc512x-psc.c index 280794dd248a..1e75341689a6 100644 --- a/drivers/spi/spi-mpc512x-psc.c +++ b/drivers/spi/spi-mpc512x-psc.c @@ -40,8 +40,8 @@ enum { * MPC5121 (which uses a struct mpc52xx_psc) and MPC5125 (using mpc5125_psc). */ #define psc_addr(mps, regname) ({ \ - void *__ret; \ - switch(mps->type) { \ + void *__ret = NULL; \ + switch (mps->type) { \ case TYPE_MPC5121: { \ struct mpc52xx_psc __iomem *psc = mps->psc; \ __ret = &psc->regname; \