Subject: kern/33966: gcc4 build failure in scsipi/cd.c
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <dholland@eecs.harvard.edu>
List: netbsd-bugs
Date: 07/10/2006 16:15:00
>Number:         33966
>Category:       kern
>Synopsis:       gcc4 build failure in scsipi/cd.c
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 10 16:15:00 +0000 2006
>Originator:     David A. Holland <dholland@eecs.harvard.edu>
>Release:        NetBSD 3.99.21
>Organization:
   Harvard EECS
>Environment:
	
	
System: NetBSD weatherwax 3.99.21 NetBSD 3.99.21 (WEATHERWAX) #0: Fri Jul  7 13:37:33 EDT 2006  dholland@weatherwax:/usr/src/sys/arch/i386/compile/WEATHERWAX i386
Architecture: i386
Machine: i386
>Description:
        gcc4 issues some signedness warnings when compiling scsipi/cd.c.
        As the kernel builds with -Werror, this fails it, and as gcc4 is
        now the default, it fails by default.

>How-To-Repeat:
	Build a kernel with SCSI CD support using gcc4.
>Fix:

(This has been checked for any unwanted consequences of the signedness
change. Note that the actual warning occurs at a call to
read_cd_capacity, not any of the lines changed.)

Index: sys/dev/scsipi/cd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/scsipi/cd.c,v
retrieving revision 1.242
diff -u -r1.242 cd.c
--- sys/dev/scsipi/cd.c	30 Mar 2006 16:09:28 -0000	1.242
+++ sys/dev/scsipi/cd.c	10 Jul 2006 16:12:15 -0000
@@ -1645,7 +1645,7 @@
  * we count.
  */
 static int
-read_cd_capacity(struct scsipi_periph *periph, int *blksize, u_long *size)
+read_cd_capacity(struct scsipi_periph *periph, uint32_t *blksize, u_long *size)
 {
 	struct scsipi_read_cd_capacity    cap_cmd;
 	struct scsipi_read_cd_cap_data    cap;
@@ -1728,7 +1728,7 @@
 static u_long
 cd_size(struct cd_softc *cd, int flags)
 {
-	int blksize;
+	uint32_t blksize;
 	u_long size;
 	int error;
 
@@ -1750,7 +1750,7 @@
 	cd->params.disksize512 = ((u_int64_t)cd->params.disksize * blksize) / DEV_BSIZE;
 
 	SC_DEBUG(cd->sc_periph, SCSIPI_DB2,
-	    ("cd_size: %d %ld\n", blksize, size));
+	    ("cd_size: %lu %ld\n", (unsigned long) blksize, size));
 
 	return size;
 }