From patchwork Mon May 23 20:35:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9132357 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0D2A160761 for ; Mon, 23 May 2016 20:36:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 016682808C for ; Mon, 23 May 2016 20:36:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA32E2824A; Mon, 23 May 2016 20:36:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FEC32808C for ; Mon, 23 May 2016 20:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754032AbcEWUg2 (ORCPT ); Mon, 23 May 2016 16:36:28 -0400 Received: from mout.kundenserver.de ([217.72.192.73]:59815 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753010AbcEWUg2 (ORCPT ); Mon, 23 May 2016 16:36:28 -0400 Received: from wuerfel.localnet ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0LfzrP-1bspNr3cHT-00pfVz; Mon, 23 May 2016 22:35:52 +0200 From: Arnd Bergmann To: linux-arm-kernel@lists.infradead.org Cc: Sudip Mukherjee , Matt Mackall , Herbert Xu , Maxime Coquelin , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Subject: Re: [PATCH] hwrng: stm32 - fix build warning Date: Mon, 23 May 2016 22:35:49 +0200 Message-ID: <6297051.TAxtzW5OIB@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-22-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <1464007448-25395-1-git-send-email-sudipm.mukherjee@gmail.com> References: <1464007448-25395-1-git-send-email-sudipm.mukherjee@gmail.com> MIME-Version: 1.0 X-Provags-ID: V03:K0:27WTwZa0RJYwjc0CQ00XKsfWpTjTYQxBDNPEIZm7ZJoJY9MKv+D AdFRyJvm+PmaSQ7WJsxnQl6SbVPCXa9LQ1Sn+b2Pwf4pv221kM1EXd5cge3mZInp+kfv5Cj lmCzem0lKe6EP/ULlw4XDprKA8sunWPgI0C7v9ulXrOCEeIDgy8WcrYx130jUG/+rdIUUzc enCvzIgIvTQ/n1Lbxtdcw== X-UI-Out-Filterresults: notjunk:1; V01:K0:CqgYJpuiwEs=:4bJIj8QDKltsamqZQ/aYZB BxhD/91mX3beL746SaUobEWIR9iXDhE1B9Fx0Tn/c3mlz9rHUWf2WX7rshWl3eNw76koB/2Qs pPChoNEvtc1F7yk5YhHgaQNxfRPnifAyiw6zxo7t1oBRttpLfe6pNuU/sxwIBJtpc8MdDF/9n R/wKjODNaHax8SAoSmYS61+chPG83Z6rutR0TjJmH5hTnC7An+SnUHusV3sen1peyDgBXs0ga GSBgf13ZK4coMw0f2F2x6VfxjHKxsHQ7zcAb/uX2IiHg9I56wlT4um5eOxkTMO8AFaSdX5/ZR TropxZhaftq7Qy3SKiYqgv66cjU/xU/3p5m8QvuRvCrc+RM33pMdgFiqe40Db7Af/s+nKedCi Ch4C2AGwExAsPIL3OrLR0KhnSYN5un8yXP9cdPMAa/UBPMluJRipAqZzsqHbxYYkFM4jdaUg9 mqBmSjoRB4P7y7pdbOH/GELByqVDZhh5zCJn7j2/OUiDjMMU3Q9jBkcWUF2oe8r7juloMMmF2 gnzpWlkbNQ0l4J4s8fCzr4S4DA02kuYgxmylB3Q4rWkHIX9/HTfjtZWB2q4BC62f4Iq4vEv8R 15/Tr/gH/4TxwomUop7URT4QrENqx4PAMj/E9Cdpb8/Wja1xsAVN6PWE80Gjg9QTzJ+8P3eTj Kib0SN93GMLQqagFawAVbrYe8NARRMSWk22UCeEkPty7UJR30vTKaMb4sviST8womu1A1Fwrq qpamFVOBzTisyg2k Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Monday, May 23, 2016 6:14:08 PM CEST Sudip Mukherjee wrote: > We have been getting build warning about: > drivers/char/hw_random/stm32-rng.c: In function 'stm32_rng_read': > drivers/char/hw_random/stm32-rng.c:82:19: warning: 'sr' may be used > uninitialized in this function > > On checking the code it turns out that sr can never be used > uninitialized as sr is getting initialized in the while loop and while > loop will always execute as the minimum value of max can be 32. > So just initialize sr to 0 while declaring it to silence the compiler. > > Signed-off-by: Sudip Mukherjee > --- I notice that you are using a really old compiler. While this warning seems to be valid in the sense that the compiler should figure out that the variable might be used uninitialized, please update your toolchain before reporting other such problems, as gcc-4.6 had a lot more false positives that newer ones (5.x or 6.x) have. > > build log at: > https://travis-ci.org/sudipm-mukherjee/parport/jobs/132180906 > > drivers/char/hw_random/stm32-rng.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c > index 92a8106..0533370 100644 > --- a/drivers/char/hw_random/stm32-rng.c > +++ b/drivers/char/hw_random/stm32-rng.c > @@ -52,7 +52,7 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) > { > struct stm32_rng_private *priv = > container_of(rng, struct stm32_rng_private, rng); > - u32 sr; > + u32 sr = 0; > int retval = 0; > > pm_runtime_get_sync((struct device *) priv->rng.priv); Does this work as well? I think it would be nicer to not add a bogus initialization. Arnd --- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/char/hw_random/stm32-rng.c b/drivers/char/hw_random/stm32-rng.c index 92a810648bd0..5c836b0afa40 100644 --- a/drivers/char/hw_random/stm32-rng.c +++ b/drivers/char/hw_random/stm32-rng.c @@ -79,7 +79,7 @@ static int stm32_rng_read(struct hwrng *rng, void *data, size_t max, bool wait) max -= sizeof(u32); } - if (WARN_ONCE(sr & (RNG_SR_SEIS | RNG_SR_CEIS), + if (WARN_ONCE(retval > 0 && (sr & (RNG_SR_SEIS | RNG_SR_CEIS)), "bad RNG status - %x\n", sr)) writel_relaxed(0, priv->base + RNG_SR);