Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2878174ybi; Sun, 2 Jun 2019 03:18:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXbte5IsVU9cyGNYHScGMk79umqDYII9117VntQjb4jZ0NXVsrosOCVtXVm9fxc8PmoumI X-Received: by 2002:a63:3710:: with SMTP id e16mr20559174pga.391.1559470688778; Sun, 02 Jun 2019 03:18:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559470688; cv=none; d=google.com; s=arc-20160816; b=UIgKJ8pNuZ7jQAeGUyC8LhKd4YIS5l0ID0NgVTB1yJeWcM5kp+4Ee0UqFh+DCxJfqK eToAE0h8mk93cejnVQtUfFK+7XrXOjgsZ19sMDnVCH4p7pQ5H9bY/8AGAwqVa64DWYHw lh/3MxOQLaPw7JxvFQ+Q4ZLR/AtaUNTQJufr1E+DvEH/aE8Zz2ZSCwGznziXgZqOaHQ8 WZowj3bwpBszKa3GX3R8em1owzGVP0Qm9EdvLGoY1DqecAIZ66vJJPWkchvXaygPymYz ns9cv367pCwwEvbo245tIo47rHKmWNIKLZyYNV22JfAgz7Jn0DvturMwfNULIFIRQsV3 LhfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=rT2lnpxZR53CFF1dcspCBa2L/RIlDvf5eHgEimj1fE4=; b=TFaiGpFBHHL4KvWKpBEHhPiSVcbckxpZNWPoQa/Th5/VCXWbO0I1h3yPzbvvAva5+l 7A6Sp6dV17au0kofIvUlUyCfmsa03yZETGuAEm71E6oj20JR3B9/WcY0Vq2AlS1p9Tzl juklafotUSJFkNlCf35jOmplfc13p/okNFxCUooNXR/qhkHnFh9kEmMxu6l39AVLh/lw u8YJKAawvjs2LttBmcBhiX+d5PNL2EfC0AO/5022Bdf+OFs41Qs8XbHgrOXN75DxWwq2 7y7camG+h2AaTAjfDadz6zZrI+DCaO3FVe17P98GtyrA1w9WGwjQEAD/HvogKefL91JI k7fA== ARC-Authentication-Results: i=1; mx.google.com; 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 j12si13662867plt.101.2019.06.02.03.17.53; Sun, 02 Jun 2019 03:18:08 -0700 (PDT) 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; 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 S1726655AbfFBKPn (ORCPT + 99 others); Sun, 2 Jun 2019 06:15:43 -0400 Received: from ozlabs.org ([203.11.71.1]:49641 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726122AbfFBKPm (ORCPT ); Sun, 2 Jun 2019 06:15:42 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 45GvG369hPz9s7h; Sun, 2 Jun 2019 20:15:39 +1000 (AEST) From: Michael Ellerman To: Nathan Chancellor , Tyrel Datwyler , "James E.J. Bottomley" , "Martin K. Petersen" Cc: clang-built-linux@googlegroups.com, Nathan Chancellor , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org Subject: Re: [PATCH] scsi: ibmvscsi: Don't use rc uninitialized in ibmvscsi_do_work In-Reply-To: <20190531185306.41290-1-natechancellor@gmail.com> References: <20190531185306.41290-1-natechancellor@gmail.com> Date: Sun, 02 Jun 2019 20:15:38 +1000 Message-ID: <87blzgnvhx.fsf@concordia.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nathan, Nathan Chancellor writes: > 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 to zero so that the atomic_set and dev_err statement don't > trigger for the cases that just break. > > Fixes: 035a3c4046b5 ("scsi: ibmvscsi: redo driver work thread to use enum action states") > Link: https://github.com/ClangBuiltLinux/linux/issues/502 > Signed-off-by: Nathan Chancellor > --- > drivers/scsi/ibmvscsi/ibmvscsi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c > index 727c31dc11a0..6714d8043e62 100644 > --- a/drivers/scsi/ibmvscsi/ibmvscsi.c > +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c > @@ -2118,7 +2118,7 @@ static unsigned long ibmvscsi_get_desired_dma(struct vio_dev *vdev) > static void ibmvscsi_do_work(struct ibmvscsi_host_data *hostdata) > { > unsigned long flags; > - int rc; > + int rc = 0; > char *action = "reset"; > > spin_lock_irqsave(hostdata->host->host_lock, flags); It's always preferable IMHO to keep any initialisation as localised as possible, so that the compiler can continue to warn about uninitialised usages elsewhere. In this case that would mean doing the rc = 0 in the switch, something like: diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 727c31dc11a0..7ee5755cf636 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c @@ -2123,9 +2123,6 @@ 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: - break; case IBMVSCSI_HOST_ACTION_RESET: spin_unlock_irqrestore(hostdata->host->host_lock, flags); rc = ibmvscsi_reset_crq_queue(&hostdata->queue, hostdata); @@ -2142,7 +2139,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: + case IBMVSCSI_HOST_ACTION_UNBLOCK: default: + rc = 0; break; } But then that makes me wonder if that's actually correct? If we get an action that we don't recognise should we just throw it away like that? (by doing hostdata->action = IBMVSCSI_HOST_ACTION_NONE). Tyrel? cheers