From patchwork Mon Jan 16 13:27:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9519297 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 10B616020B for ; Mon, 16 Jan 2017 18:44:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00CF127B81 for ; Mon, 16 Jan 2017 18:44:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E993B2811E; Mon, 16 Jan 2017 18:44:33 +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=-1.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 130CF27B81 for ; Mon, 16 Jan 2017 18:44:30 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5DB5F2672B8; Mon, 16 Jan 2017 19:44:29 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id C91CF267232; Mon, 16 Jan 2017 19:42:10 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 656362670B8; Mon, 16 Jan 2017 14:28:20 +0100 (CET) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) by alsa0.perex.cz (Postfix) with ESMTP id 343F5267058 for ; Mon, 16 Jan 2017 14:28:14 +0100 (CET) Received: from wuerfel.lan ([78.43.21.235]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MSYbs-1c1aXz2dr2-00RcUn; Mon, 16 Jan 2017 14:28:07 +0100 From: Arnd Bergmann To: Jaroslav Kysela , Takashi Iwai Date: Mon, 16 Jan 2017 14:27:57 +0100 Message-Id: <20170116132805.2207208-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:/CsUh4t6CBW015iU+KlVbqG1pljavBucwZ7asxq/yp58rZvCt0K m4HMiCjo2bSXwl3tNz+hbZna89lfStXE4aW1ItIadbVYjQg2ontaLrXXthlMw/pDVBfiV5C sY69Q6lMvwP8GUIPrekMcbkPwIB9V5TuOXRQrphBr2qXOtRz9YJg6vwPagDtQGPYhJbP1DY xQ2aTLS4RS3cawyoHzT9Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:urySP5nxK1Y=:x1g5B5/PzwZp9qaNS9raF7 7B08y+TXNuywUVXMuw1A0VLGwMMvVfI/90B+Mr3z5O5raBpZc2lkMcmY4vrT2jkzUTyaqYc0z rJCA+Aoz1rqEfrj3rk3WI4E5c+6yPkq/NfRJYNSovHhq5REtkS9xyT7pqFLG1VIBXEFfmiRf4 U1N9YjEGbp1C1aU+XtGoY+62SK5G+PfzvNQsQw67pbYGEALMIPwJWUbRyg5AAycRCtxGVi5fL CK6h1K1n0BtJ/eSh5FrbUIplfFJSeZD6h2tMG/3zYGq71e4ApRbxSLjmocO0kRT9Ltknm7OMO jOZP7at7F9DLGgE9mgtYl4+1qt5ddcZ7xUgfvVHN980dgaL5eWRTcHbTITDsHuKaqYmTP5sNL CTJN495eu9ioKAjdHrRfXp0ksssTz7ko+vHqud96mjXRFRDeECq58huR40rGfi6kwXhdtmITc wfhsZ7mM++7M7tpXtlPgW6ofy0lrszcg1rqg8bVWS3H82I8QK3CGOXYrLeO6FqOLrr5/O/02x b7Uf6pklzkUe0LUMjOArwIfkLnF51S61YsLWO6brMhVMt6s02Xezzd3sp9lPlCeP8n5JIqGin XWnWfml1osGA/EivQ0C6JsbLz6qBgfwqzsrhHzozjm4ZYy3L4Sb0cq0Hky4EdZ/COmMl+Ub+2 K5LgmAwGtUGeXEpZSWNDTATWEaBnyvgeAb3j8++1fIVH5j6aaD2dmVn3JPclIrqmXtU8= Cc: linux-mips@linux-mips.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [alsa-devel] [PATCH v3] ALSA: mips: avoid potential uninitialized variable use X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP MIPS allmodconfig results in this warning: sound/mips/hal2.c: In function 'hal2_gain_get': sound/mips/hal2.c:224:35: error: 'r' may be used uninitialized in this function [-Werror=maybe-uninitialized] sound/mips/hal2.c:223:35: error: 'l' may be used uninitialized in this function [-Werror=maybe-uninitialized] sound/mips/hal2.c: In function 'hal2_gain_put': sound/mips/hal2.c:260:13: error: 'new' may be used uninitialized in this function [-Werror=maybe-uninitialized] sound/mips/hal2.c:260:13: error: 'old' may be used uninitialized in this function [-Werror=maybe-uninitialized] Returning an error for all unexpected cases shuts up the warning Signed-off-by: Arnd Bergmann --- v3: actually send the correct patch, sorry for the mixup v2: return an error instead trying to handle gracefully sound/mips/hal2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c index ede449f0b50d..00fc9241d266 100644 --- a/sound/mips/hal2.c +++ b/sound/mips/hal2.c @@ -219,6 +219,8 @@ static int hal2_gain_get(struct snd_kcontrol *kcontrol, l = (tmp >> H2I_C2_L_GAIN_SHIFT) & 15; r = (tmp >> H2I_C2_R_GAIN_SHIFT) & 15; break; + default: + return -EINVAL; } ucontrol->value.integer.value[0] = l; ucontrol->value.integer.value[1] = r; @@ -256,6 +258,8 @@ static int hal2_gain_put(struct snd_kcontrol *kcontrol, new |= (r << H2I_C2_R_GAIN_SHIFT); hal2_i_write32(hal2, H2I_ADC_C2, new); break; + default: + return -EINVAL; } return old != new; }