From patchwork Mon Jun 3 23:44:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 10974087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 188B013AD for ; Mon, 3 Jun 2019 23:44:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2F0E28619 for ; Mon, 3 Jun 2019 23:44:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCA0F28646; Mon, 3 Jun 2019 23:44:49 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 56C4328619 for ; Mon, 3 Jun 2019 23:44:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726179AbfFCXom (ORCPT ); Mon, 3 Jun 2019 19:44:42 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:32929 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbfFCXol (ORCPT ); Mon, 3 Jun 2019 19:44:41 -0400 Received: by mail-ed1-f67.google.com with SMTP id y17so11185404edr.0; Mon, 03 Jun 2019 16:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iUy17fN7770FCrI/QNupqS+ou4at1wV04TcSjndKp2g=; b=oD9NwKTJf5z2zrDzsi8009pHmlRtw9kWEpI1bZ5z1Tj9w5XKm++lvrwDcBtM2GoOYR tAfx0fsmedFy5tadWiGYRb+d5oK+l1T6ue/4JMyzKO+l59ihgiA9Bi4FRsgYNRR4YqZA MGhldpQR2s0y1ahkROxL4LPO6pNwrsQ5zSyjLY8jLjrpIE/h2xoXaCSF1uK058Fdby+1 cRTVrlbB5Fxc+5SssC/A/x5r/XJFzpWYMsIuH6tsPgr1g7ISxP7Z0fUkSukxwE4PyQvJ vYrPtbAGZ8kbyQAvWXlVsUUnqcUfOBEQSIyb4k9yc2Q6xV8Yqs0I3G88yxl5jgPWucbK iXNQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=iUy17fN7770FCrI/QNupqS+ou4at1wV04TcSjndKp2g=; b=qwNWzBF5ovdmAtTLPzuhFPbi83ZvdC0PmnQK0JaEaic5QNSLmh+4y+AtWLFarhy6WU 9Gvz9l2nfj/SsnVUun43b3X3Ow3sjoF3Wu1Z01GRz8UncWfovToIM2cxCmDQhdevxsZM nuQb8Qq3AEMJHdA2+xnG7CufcT4JVNupQN5+Gb6fR0AyRxqFpoPEh2X06ebVCkDV5ON6 +tlzZ0aJbvXea8t+BZd4ynvZF3F5WJBc+aYYiGxKGkntS5y/yxVLI/Jo0VPuNqIaC8Hd foj3Di4Ggn8XwxoxZ2vq64+0OEZEKr8UKoaMVIO7pstcb4/YyGOcf++Te1oNGW3C4P79 Pcfw== X-Gm-Message-State: APjAAAUzM35+xX0JXO1grgzvpJ+xygBGifIbx2oN8kG1DzTgUUoV1f0z C0LQJhN2+ZibYLFHc448MDE= X-Google-Smtp-Source: APXvYqweCDTicOF+93cu952noxE9ZtNmcV/VMB+JSgKYoYKuLBG2FVMsTqn3lsN1cj2084kluUPO1w== X-Received: by 2002:a50:9413:: with SMTP id p19mr9742843eda.224.1559605480020; Mon, 03 Jun 2019 16:44:40 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:2b:2b15::2]) by smtp.gmail.com with ESMTPSA id gu4sm137011ejb.52.2019.06.03.16.44.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 16:44:39 -0700 (PDT) From: Nathan Chancellor To: Tyrel Datwyler , "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor , Michael Ellerman Subject: [PATCH v3] scsi: ibmvscsi: Don't use rc uninitialized in ibmvscsi_do_work Date: Mon, 3 Jun 2019 16:44:06 -0700 Message-Id: <20190603234405.29600-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.22.0.rc3 In-Reply-To: <20190603221941.65432-1-natechancellor@gmail.com> References: <20190603221941.65432-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP clang warns: drivers/scsi/ibmvscsi/ibmvscsi.c:2126:7: warning: variable 'rc' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized] case IBMVSCSI_HOST_ACTION_NONE: ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/scsi/ibmvscsi/ibmvscsi.c:2151:6: note: uninitialized use occurs here if (rc) { ^~ Initialize rc in the IBMVSCSI_HOST_ACTION_UNBLOCK case statement then shuffle IBMVSCSI_HOST_ACTION_NONE down to the default case statement and make it return early so that rc is never used uninitialized in this function. Fixes: 035a3c4046b5 ("scsi: ibmvscsi: redo driver work thread to use enum action states") Link: https://github.com/ClangBuiltLinux/linux/issues/502 Suggested-by: Michael Ellerman Suggested-by: Tyrel Datwyler Signed-off-by: Nathan Chancellor Acked-by: Tyrel Datwyler --- v1 -> v2: * Initialize rc in the case statements, rather than at the top of the function, as suggested by Michael. v2 -> v3: * default and IBMVSCSI_HOST_ACTION_NONE now return early from the function, as requested by Tyrel. drivers/scsi/ibmvscsi/ibmvscsi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 65053daef5f7..7f66a7783209 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -2109,8 +2109,8 @@ static void ibmvscsi_do_work(struct ibmvscsi_host_data *hostdata) spin_lock_irqsave(hostdata->host->host_lock, flags); switch (hostdata->action) { - case IBMVSCSI_HOST_ACTION_NONE: case IBMVSCSI_HOST_ACTION_UNBLOCK: + rc = 0; break; case IBMVSCSI_HOST_ACTION_RESET: spin_unlock_irqrestore(hostdata->host->host_lock, flags); @@ -2128,8 +2128,10 @@ static void ibmvscsi_do_work(struct ibmvscsi_host_data *hostdata) if (!rc) rc = ibmvscsi_send_crq(hostdata, 0xC001000000000000LL, 0); break; + case IBMVSCSI_HOST_ACTION_NONE: default: - break; + spin_unlock_irqrestore(hostdata->host->host_lock, flags); + return; } hostdata->action = IBMVSCSI_HOST_ACTION_NONE;