Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: aha1542: avoid uninitialized variable warnings

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>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Arnd Bergmann and committed by
Martin K. Petersen
ec54adfb 860cd9c0

+3
+3
drivers/scsi/aha1542.c
··· 403 403 cptr = kmalloc(sizeof(*cptr) * sg_count, GFP_KERNEL | GFP_DMA); 404 404 if (!cptr) 405 405 return SCSI_MLQUEUE_HOST_BUSY; 406 + } else { 407 + sg_count = 0; 408 + cptr = NULL; 406 409 } 407 410 408 411 /* Use the outgoing mailboxes in a round-robin fashion, because this