Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2021005imu; Sun, 18 Nov 2018 13:58:56 -0800 (PST) X-Google-Smtp-Source: AJdET5dbJNSjLAUFDZMUoAit1N3PfBPPF5g8QaWao7Pex2l/c9KXJPAi64KbuRSsEAABieQxKvYO X-Received: by 2002:a17:902:1123:: with SMTP id d32-v6mr19611676pla.62.1542578335853; Sun, 18 Nov 2018 13:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542578335; cv=none; d=google.com; s=arc-20160816; b=muayFA9/pVUIeP+a23Wdd/EG/7FvjqzcuNCXmwb84uYkZ6E+/AtB99UTvnwUVCI/It GtnW8BuHx8jOnb9zqZLoxq7xHSgyJtJHOO8tVc450XsaMw9J2UJuKdPN1s/FiFhSFFEL JBZK/OyxXzxAF8jFKE0AKVmEN66gGTYQpD7QnyE7wVarhJympRwVR/MLSc2jAtelKaFc BM381pI+7CNlu+KtiwL1p6C910n6MtoswvWAp087hC07kMRDMNeZcPabk6Q1bXyeBcTB X9ypzMVQ8iNKnVHBs+is5x9PF9TOrrzhESVmkjv9TnWTvMRu/4NaZiORtafX2/6UF02o mNQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=BxQfJW2kQdDn9A8wc85LDvFA3SC8nq6Od4NzrYEAoJQ=; b=NehKVc+CfkJArgQJ5CoAO5MrDMWh7J05Mlz5XG45Cduqdk3+WLU+w7BSt3COSHqHK9 vzZL68EPL1Bia9VuhVXDPEfYViT1tJmjBKs7Kqx5y/iglIRLy31BVYQ1jgkiaVetUETH L6XIrxR6bdOIKhoqs4gXb03onck0+0nOFMdvBWhicSulYxG0N30UYzNaJNXWsUYXy71q YsH5hWNIzXVmTE+tpTCkPl/aCaL3Ce9fPT1n+MJbpuFt4VjVtKBB3Brx6Dnf1vmlz8IU WH8kwjt1G/CKYXtmURzKMfqxMHOJaX1NoNZFH0kVNL+J5+Kvo+qiTL3CBeAIAabimxsB hR9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lixom-net.20150623.gappssmtp.com header.s=20150623 header.b=ynES27Hd; 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 86si7644913pfl.46.2018.11.18.13.58.19; Sun, 18 Nov 2018 13:58:55 -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=ynES27Hd; 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 S1726999AbeKSH7n (ORCPT + 99 others); Mon, 19 Nov 2018 02:59:43 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:33900 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726499AbeKSH7n (ORCPT ); Mon, 19 Nov 2018 02:59:43 -0500 Received: by mail-it1-f195.google.com with SMTP id x124so5781624itd.1 for ; Sun, 18 Nov 2018 13:38:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lixom-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=BxQfJW2kQdDn9A8wc85LDvFA3SC8nq6Od4NzrYEAoJQ=; b=ynES27HdNbD0PVHV7e69Z6p+PkDuc3Z3O9gikWL42ver/F7A+g6u2hZMRjufdP7dCe cs4RL2LRIRynYY4zOPoIo7SU6BFAoFzjR/By2L+BUpgQGqbMVSgiQnNx/3oMWjmZOlzp WpDy1x1a45njNNjwaBpgE7n861BD2GhnBQxOGXg6ECn7fKT6X9lamyepvTOji12OxXyU Bb0Bwfd6lZB8CZvngiaUbGma6MCc1vgFFiiSMRHh3qFdMGzg737BZUW4M7zjjAFsLGB0 oH5LRN9QLjL5/jMdFy07SDZK4lB2SCU18Ta09viWiGTchdPY7U6fTMO/7edvQ20jBBmc Vx9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BxQfJW2kQdDn9A8wc85LDvFA3SC8nq6Od4NzrYEAoJQ=; b=e5Xk2sEo0MtrfeQyw+kbgVnLxzWfcejqa2Zb7Iu0GneP/NxW2X1BxUlF3HCubDFJs9 6hQZEF6OjLviAqeiGk86tDAnox9wIzEe+hascYzdlD74OuFq0BeXmP3NOaqIXFl2Tjvt U/Xx3wqqDRRLDp0WJ/9BlKUUSTB7QjmTw9qhIWd+wRK67UHutAFPB5i78Cz6QZUxq4f2 YNQ7Q264gKhNCVdX/K0He30tlLRxfKe5sCMAsA8FC5unhNglKy0de6+JieFzipTyV1tb /A18iMcrWCTG2Yk6OcpxcKPBMHwrAjBBRiVcmuPw2b4LI6TD0CS5ctFxROUzW7aFlTZQ TPNQ== X-Gm-Message-State: AA+aEWbns5yKn31fPc9dqOH0WhT+KJAB/csMhWt2EnCGty1pxV6BovjD 32BXfBTx4JRiPrUV1a7mkDh9PdVI46sdOySS4Va2/Q== X-Received: by 2002:a24:28d2:: with SMTP id h201mr2453929ith.136.1542577096014; Sun, 18 Nov 2018 13:38:16 -0800 (PST) MIME-Version: 1.0 References: <20181118123504.83082-1-tmaimon77@gmail.com> <20181118123504.83082-2-tmaimon77@gmail.com> In-Reply-To: <20181118123504.83082-2-tmaimon77@gmail.com> From: Olof Johansson Date: Sun, 18 Nov 2018 13:38:05 -0800 Message-ID: Subject: Re: [PATCH v1 1/1] spi: npcm: fix uninitialized 'val' warning in receive function To: Tomer Maimon Cc: Mark Brown , Rob Herring , Mark Rutland , yuenn@google.com, venture@google.com, brendanhiggins@google.com, avifishman70@gmail.com, Joel Stanley , linux-spi@vger.kernel.org, openbmc@lists.ozlabs.org, Linux Kernel Mailing List , DTML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 18, 2018 at 4:36 AM Tomer Maimon wrote: > > Fix uninitialized 'val' warning receive function, send function > has been modify to be aligned with the receive function. > > Signed-off-by: Tomer Maimon > --- > drivers/spi/spi-npcm-pspi.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/drivers/spi/spi-npcm-pspi.c b/drivers/spi/spi-npcm-pspi.c > index 6dae91091143..f75df49ab84e 100644 > --- a/drivers/spi/spi-npcm-pspi.c > +++ b/drivers/spi/spi-npcm-pspi.c > @@ -199,11 +199,11 @@ static void npcm_pspi_send(struct npcm_pspi *priv) > wsize = min(bytes_per_word(priv->bits_per_word), priv->tx_bytes); > priv->tx_bytes -= wsize; > > - if (priv->tx_buf) { > - if (wsize == 1) > - iowrite8(*priv->tx_buf, NPCM_PSPI_DATA + priv->base); > + if (priv->tx_buf && wsize) { In general, doing an early: if (!condition) return; is a pattern we prefer in the kernel. Setting up the assumptions at the beginning of the function makes it easier to follow the code flow, and saves a level of indentation. It's a matter of taste though, and this function has only one level. So, either way is OK. Just mentioning it. > if (wsize == 2) > iowrite16(*priv->tx_buf, NPCM_PSPI_DATA + priv->base); > + else > + iowrite8(*priv->tx_buf, NPCM_PSPI_DATA + priv->base); I think this is broken? If wsize is something else than 1 or 2, you'll do a one-byte write but advance the buffer pointer with a different amount. It'll be fairly tricky to debug if this ever happens (it shouldn't, but still). This is why I added a WARN_ON_ONCE() in my patch instead. -Olof