Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1319095 > unrolled thread

[PATCH 6/7] scsi: aha1542: avoid uninitialized variable warnings

Started byArnd Bergmann <arnd@arndb.de>
First post2016-01-27 17:00 +0100
Last post2016-01-27 17:00 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 6/7] scsi: aha1542: avoid uninitialized variable warnings Arnd Bergmann <arnd@arndb.de> - 2016-01-27 17:00 +0100

#1319095 — [PATCH 6/7] scsi: aha1542: avoid uninitialized variable warnings

FromArnd Bergmann <arnd@arndb.de>
Date2016-01-27 17:00 +0100
Subject[PATCH 6/7] scsi: aha1542: avoid uninitialized variable warnings
Message-ID<qVAFJ-5LQ-25@gated-at.bofh.it>
Gcc incorrectly detects that two variables in aha1542_queuecommand might
be used without an initialization:

scsi/aha1542.c: In function 'aha1542_queuecommand':
scsi/aha1542.c:382:16: error: 'cptr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
scsi/aha1542.c:379:11: error: 'sg_count' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The only user of these is doing the same check that the assigment
has, so it is actually guaranteed to work. Adding an "else" clause
with a fake initialization shuts up the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/aha1542.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 5b8b2937a3fe..7db448ec8beb 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -403,6 +403,9 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
 		cptr = kmalloc(sizeof(*cptr) * sg_count, GFP_KERNEL | GFP_DMA);
 		if (!cptr)
 			return SCSI_MLQUEUE_HOST_BUSY;
+	} else {
+		sg_count = 0;
+		cptr = NULL;
 	}
 
 	/* Use the outgoing mailboxes in a round-robin fashion, because this
-- 
2.7.0

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web