Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp160913imu; Fri, 16 Nov 2018 19:56:01 -0800 (PST) X-Google-Smtp-Source: AJdET5fo93gqd9p+OQbRbWHy7bKefWs9I+kzAYVVaZ6RXxbYv/8r2tB4nW/dZyhV6w0PyDur0MAW X-Received: by 2002:a17:902:6bc1:: with SMTP id m1-v6mr13801564plt.34.1542426961395; Fri, 16 Nov 2018 19:56:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542426961; cv=none; d=google.com; s=arc-20160816; b=gdcTqnPa++X0mNjdoLeW8ChNJKrs2iXlyEjm7NFpQLlvSDvOVhKnGfH6SzedZywsqh RBXxrDaiSMmwgtFcf5Jw6q0FduHnmd4MzVeq3NK7n9DpRmKFtDeUrfNa3h4e5biUgmKC 3EWXYCxsCn40mmR6PCediOD5UDHpd94Tlo2tEB9RpepDAMUW67Vu4DlENqdj1frxqSVa C6QfzoJHBg9miJoqwVh/EOljXEnCm22u1BScfdB1qVgnyuEwk3DGXuonDEBRPL3HQ9jA gVf/H6H2aUiyoWobFFJnfNHtJdZa+o1nlGQQgowjMGbWeStPQmwdbAYZkSyS3W+HwQ8V sy6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=rk0sxhdj9KtpA38fFQRAocxRA5sbD33dk1fpH2uJ4Iw=; b=wptuvbjNZR4eBorz2jBPmvz8k1Nc/moQnRDJtj9qFgcoGpbQYO3cMQia2K9pqlANtr uXjdu1jIePlN3CU+69cTuA1qo8QpkJomjBRpYwz5x9PCv6gTaW3JsF3i0AzRaRIbFZqn ShXKCxAit+8JE/58f+06+U38CDmInLfIkoqq6ALYBbMMrMB/YusewXoRSJ4hZkvYbRUi uHhSBkyjOobo3bAOaVnLwIcESG96vcsRJD0Yr0V5WyDSS0h+bHfjqwgbAZB2vb7tXi+j G0J4Gq0oqQqnwq1/Pd0g0kesUpfr72J0DRept8juzCuVsP2/2VxkIx6OBykHcn1Jyo90 dhKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lixom-net.20150623.gappssmtp.com header.s=20150623 header.b=xHFkwVu+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61-v6si34901272plr.72.2018.11.16.19.55.45; Fri, 16 Nov 2018 19:56:01 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lixom-net.20150623.gappssmtp.com header.s=20150623 header.b=xHFkwVu+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730517AbeKQOKY (ORCPT + 99 others); Sat, 17 Nov 2018 09:10:24 -0500 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34402 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729714AbeKQOKY (ORCPT ); Sat, 17 Nov 2018 09:10:24 -0500 Received: by mail-pl1-f194.google.com with SMTP id f12-v6so12046117plo.1 for ; Fri, 16 Nov 2018 19:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lixom-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=rk0sxhdj9KtpA38fFQRAocxRA5sbD33dk1fpH2uJ4Iw=; b=xHFkwVu+h1S8JYb2sFrbz5D40GTXA9qdcJsLpODc+IrlFCkdmpphDv8FRUONbXFMse kb52TOPFGkvuMuV8ZNuM8vvpCdSsE2O3w+7b/kXXihXswf0LdahNz5IyKTleo+Pkkkqa /6QW4KA8JyG1TIJUD0chHJ4PGiuAi27SPiRj5s+FnmK4YwcBw33cf+1ztIZHAg1KlNrc ttlG0ZaMt5F9B03xzX98dmGiB2yMq6/8TkXznvFUfQcWG3RmRI0f3Y0lS2r2olfzE8R/ KrmBLs6P4+IJdYYXE3aPocEdiubCswnyTzbOvD5r/PTfbFbD13q5HuZecmXphcbCd9pG dojg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rk0sxhdj9KtpA38fFQRAocxRA5sbD33dk1fpH2uJ4Iw=; b=g4gmjAtRvr5neXvBpIs/Ji4khVwdxlssDcu+pZ0pLGKP6f0tB7CvLkrrYXdOmBN6Ca AC/wD/H4bCkYk0Hh2lroU9/xP+P85OGb1A3XbWwCSBvJK35isPr3mLw0yUe78bblwHmN OywLKY9ErDshSbf40k46Sjs5+TAzEG9PSIW0ofdFXzsC4Y5ariF/egVB24C+K0WNbC84 nkko70QPqRaLArk9n7fmC6ya6yGf53go5zVVAnaR58keo5uPJC9N3RjR96YuLnaWOukW +q4zGP8gnPHUuKCsqYtHXLc+WQqSXDE4ognKSj38pc2523dMdLNbfZ6Z1UGnEbvnr5VO TgPQ== X-Gm-Message-State: AGRZ1gJNtuqZ8QUPCaSAAsFbQmEWRyV9+DcRXLgVHRA+3PoIZZVSVjOQ jiCXGPjeJwWsyErpEF7Y7VeeoA== X-Received: by 2002:a17:902:70cb:: with SMTP id l11-v6mr13961702plt.30.1542426909701; Fri, 16 Nov 2018 19:55:09 -0800 (PST) Received: from rip.lixom.net (99-152-116-91.lightspeed.sntcca.sbcglobal.net. [99.152.116.91]) by smtp.gmail.com with ESMTPSA id p5-v6sm36112904pfb.109.2018.11.16.19.55.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Nov 2018 19:55:08 -0800 (PST) From: Olof Johansson To: broonie@kernel.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, opembmc@lists.ozlabs.org, Tomer Maimon , Olof Johansson Subject: [PATCH] spi: npcm: Fix uninitialized variable warning Date: Fri, 16 Nov 2018 19:55:04 -0800 Message-Id: <20181117035504.95804-1-olof@lixom.net> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The compiler has no way to know that rsize 1 or 2 are the only valid values. Also simplify the code a bit with early return. The warning was: drivers/spi/spi-npcm-pspi.c:215:6: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized] Signed-off-by: Olof Johansson --- drivers/spi/spi-npcm-pspi.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/spi/spi-npcm-pspi.c b/drivers/spi/spi-npcm-pspi.c index 342178e282bcd..be0539cb19e49 100644 --- a/drivers/spi/spi-npcm-pspi.c +++ b/drivers/spi/spi-npcm-pspi.c @@ -217,15 +217,23 @@ static void npcm_pspi_recv(struct npcm_pspi *priv) rsize = min(bytes_per_word(priv->bits_per_word), priv->rx_bytes); priv->rx_bytes -= rsize; - if (priv->rx_buf) { - if (rsize == 1) - val = ioread8(priv->base + NPCM_PSPI_DATA); - if (rsize == 2) - val = ioread16(priv->base + NPCM_PSPI_DATA); + if (!priv->rx_buf) + return; - *priv->rx_buf = val; - priv->rx_buf += rsize; + switch (rsize) { + case 1: + val = ioread8(priv->base + NPCM_PSPI_DATA); + break; + case 2: + val = ioread16(priv->base + NPCM_PSPI_DATA); + break; + default: + WARN_ON_ONCE(1); + return; } + + *priv->rx_buf = val; + priv->rx_buf += rsize; } static int npcm_pspi_transfer_one(struct spi_master *master, -- 2.11.0