[PATCH] scsi: core: Move declaration before statements in scsi_dec_host_busy()

liyin.zhang.cn@windriver.com posted 1 patch 2 months, 1 week ago
drivers/scsi/scsi_lib.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] scsi: core: Move declaration before statements in scsi_dec_host_busy()
Posted by liyin.zhang.cn@windriver.com 2 months, 1 week ago
From: Liyin Zhang <liyin.zhang.cn@windriver.com>

Commit 4e6c90119907 ("scsi: core: Move scsi_host_busy() out of host lock
if it is for per-command") introduced a variable declaration of 'busy' in
scsi_dec_host_busy().

Commit cc872e35c0df ("scsi: core: Wake up the error handler when final
completions race against each other") then added a 'smp_mb()' statement
before that declaration, resulting in mixed declarations and code which is
forbidden in ISO C90. The kernel 5.10 builds with '-std=gnu89' by default,
which makes this a compile warning.

Move the declaration before the statement to fix the warning.

Among the current longterm stable branches, only 5.15 and 5.10 build with
'-std=gnu89' by default. Since commit cc872e35c0df was not backported to
5.15, no compile warning is triggered there. Therefore this fix is only
needed for 5.10.

Fixes: cc872e35c0df ("scsi: core: Wake up the error handler when final completions race against each other")
Signed-off-by: Liyin Zhang <liyin.zhang.cn@windriver.com>
---
 drivers/scsi/scsi_lib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 8d570632982f..14b37fb76400 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -306,6 +306,7 @@ EXPORT_SYMBOL(__scsi_execute);
 static void scsi_dec_host_busy(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
 {
 	unsigned long flags;
+	unsigned int busy;
 
 	rcu_read_lock();
 	__clear_bit(SCMD_STATE_INFLIGHT, &cmd->state);
@@ -318,7 +319,7 @@ static void scsi_dec_host_busy(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
 		 */
 		smp_mb();
 
-		unsigned int busy = scsi_host_busy(shost);
+		busy = scsi_host_busy(shost);
 
 		spin_lock_irqsave(shost->host_lock, flags);
 		if (shost->host_failed || shost->host_eh_scheduled)
-- 
2.34.1