Skip to contentSkip to conversation

scsi: fix compiler warning with DEBUG and 48bit LBAs

PATCH New Andre Przywara 2 participants 2 messages Jul 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: fix compiler warning with DEBUG and 48bit LBAs

Commit 2b42c9317db ("ahci: support LBA48 data reads for 2+TB drives") introduced conditional code which triggers a warning when compiled with DEBUG enabled:

In file included from common/cmd_scsi.c:12:0:
common/cmd_scsi.c: In function 'scsi_read':
include/common.h:109:4: warning: 'smallblks' may be used uninitialized in this function [-Wmaybe-uninitialized]
...

Since this is for debug only, take the easy way and initialize the variable explicitly on declaration to avoid the warning. (Fix a nearby whitespace error on the way.)

---
Hi,

Bin: Sorry for the late reply, does that fix your problem?

Tom: Can you take this for 2015.07? Admittedly a quick fix (the debug output for big disks would be bogus).
If you are interested: I have a proper solution unfiying all three blocks and fixing the problem properly, but I guess that's nothing for this release still.

Cheers,
Andre.

 common/cmd_scsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/cmd_scsi.c +2 -2
index aaca3e8..31c4319 100644
@@ -368,7 +368,7 @@ static ulong scsi_read(int device, lbaint_t blknr, lbaint_t blkcnt,
 {
 	lbaint_t start, blks;
 	uintptr_t buf_addr;
-	unsigned short smallblks;
+	unsigned short smallblks = 0;
 	ccb* pccb=(ccb *)&tempccb;
 	device&=0xff;
 	/* Setup  device
@@ -391,7 +391,7 @@ static ulong scsi_read(int device, lbaint_t blknr, lbaint_t blkcnt,
 			scsi_setup_read16(pccb, start, blocks);
 			start += blocks;
 			blks -= blocks;
-		} else 
+		} else
 #endif
 		if (blks > SCSI_MAX_READ_BLK) {
 			pccb->datalen=scsi_dev_desc[device].blksz * SCSI_MAX_READ_BLK;
Signature · 1 line
1.8.4
#1 lore raw

PATCH 1/1 scsi: fix compiler warning with DEBUG and 48bit LBAs

Quoted 9 lines · Andre Przywara

Commit 2b42c9317db ("ahci: support LBA48 data reads for 2+TB drives") introduced conditional code which triggers a warning when compiled with DEBUG enabled:

In file included from common/cmd_scsi.c:12:0:
common/cmd_scsi.c: In function 'scsi_read':
include/common.h:109:4: warning: 'smallblks' may be used uninitialized in this function [-Wmaybe-uninitialized]
...

Quoted 5 lines

Since this is for debug only, take the easy way and initialize the variable explicitly on declaration to avoid the warning. (Fix a nearby whitespace error on the way.)

Quoted 40 lines

---
Hi,

Bin: Sorry for the late reply, does that fix your problem?

Tom: Can you take this for 2015.07? Admittedly a quick fix (the debug output for big disks would be bogus).
If you are interested: I have a proper solution unfiying all three blocks and fixing the problem properly, but I guess that's nothing for this release still.

Cheers,
Andre.

 common/cmd_scsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/cmd_scsi.c +2 -3
index aaca3e8..31c4319 100644
@@ -368,7 +368,7 @@ static ulong scsi_read(int device, lbaint_t blknr, lbaint_t blkcnt,
 {
        lbaint_t start, blks;
        uintptr_t buf_addr;
-       unsigned short smallblks;
+       unsigned short smallblks = 0;
        ccb* pccb=(ccb *)&tempccb;
        device&=0xff;
        /* Setup  device
@@ -391,7 +391,7 @@ static ulong scsi_read(int device, lbaint_t blknr, lbaint_t blkcnt,
                        scsi_setup_read16(pccb, start, blocks);
                        start += blocks;
                        blks -= blocks;
-               } else
+               } else
 #endif
                if (blks > SCSI_MAX_READ_BLK) {
                        pccb->datalen=scsi_dev_desc[device].blksz * SCSI_MAX_READ_BLK;
--
Quoted 2 lines

1.8.4

Regards,
Bin