[PATCH] gcc 4.x cleanups of cam code

Craig Rodrigues rodrigc at crodrigues.org
Thu Jan 18 02:29:08 UTC 2007


Hi,

Could someone who is more familiar with CAM take a look
at the pass I did to try to clean up some gcc 4.x compiler warnings?
gcc 4.x is more intolerant than gcc 3.x of mixing up assignments of
char * and unsigned char *.

Thanks.
-- 
Craig Rodrigues        
rodrigc at crodrigues.org
-------------- next part --------------
Index: cam.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/cam.c,v
retrieving revision 1.10
diff -u -u -r1.10 cam.c
--- cam.c	18 Apr 2006 21:53:39 -0000	1.10
+++ cam.c	18 Jan 2007 02:05:36 -0000
@@ -104,7 +104,7 @@
 #endif
 
 void
-cam_strvis(u_int8_t *dst, const u_int8_t *src, int srclen, int dstlen)
+cam_strvis(char *dst, const char *src, int srclen, int dstlen)
 {
 
 	/* Trim leading/trailing spaces, nulls. */
@@ -115,9 +115,9 @@
 		srclen--;
 
 	while (srclen > 0 && dstlen > 1) {
-		u_int8_t *cur_pos = dst;
+		char *cur_pos = dst;
 
-		if (*src < 0x20 || *src >= 0x80) {
+		if ((u_char)*src < 0x20 || (u_char)*src >= 0x80) {
 			/* SCSI-II Specifies that these should never occur. */
 			/* non-printable character */
 			if (dstlen > 4) {
@@ -147,7 +147,7 @@
  * wildcard '?' matches a single non-space character.
  */
 int
-cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len)
+cam_strmatch(const char *str, const char *pattern, int str_len)
 {
 
 	while (*pattern != '\0'&& str_len > 0) {  
Index: cam.h
===================================================================
RCS file: /home/ncvs/src/sys/cam/cam.h,v
retrieving revision 1.11
diff -u -u -r1.11 cam.h
--- cam.h	5 Jan 2005 22:34:34 -0000	1.11
+++ cam.h	18 Jan 2007 02:05:36 -0000
@@ -199,9 +199,9 @@
 caddr_t	cam_quirkmatch(caddr_t target, caddr_t quirk_table, int num_entries,
 		       int entry_size, cam_quirkmatch_t *comp_func);
 
-void	cam_strvis(u_int8_t *dst, const u_int8_t *src, int srclen, int dstlen);
+void	cam_strvis(char *dst, const char *src, int srclen, int dstlen);
 
-int	cam_strmatch(const u_int8_t *str, const u_int8_t *pattern, int str_len);
+int	cam_strmatch(const char *str, const char *pattern, int str_len);
 const struct cam_status_entry*
 	cam_fetch_status_entry(cam_status status);
 #ifdef _KERNEL
Index: cam_periph.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/cam_periph.c,v
retrieving revision 1.64
diff -u -u -r1.64 cam_periph.c
--- cam_periph.c	5 Dec 2006 07:45:27 -0000	1.64
+++ cam_periph.c	18 Jan 2007 02:05:36 -0000
@@ -648,7 +648,7 @@
 		mapinfo->bp[i]->b_saveaddr = mapinfo->bp[i]->b_data;
 
 		/* put our pointer in the data slot */
-		mapinfo->bp[i]->b_data = *data_ptrs[i];
+		mapinfo->bp[i]->b_data = (caddr_t)*data_ptrs[i];
 
 		/* set the transfer length, we know it's < DFLTPHYS */
 		mapinfo->bp[i]->b_bufsize = lengths[i];
@@ -676,7 +676,7 @@
 		}
 
 		/* set our pointer to the new mapped area */
-		*data_ptrs[i] = mapinfo->bp[i]->b_data;
+		*data_ptrs[i] = (u_int8_t *)mapinfo->bp[i]->b_data;
 
 		mapinfo->num_bufs_used++;
 	}
Index: scsi/scsi_cd.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_cd.c,v
retrieving revision 1.97
diff -u -u -r1.97 scsi_cd.c
--- scsi/scsi_cd.c	5 Dec 2006 07:45:27 -0000	1.97
+++ scsi/scsi_cd.c	18 Jan 2007 02:05:36 -0000
@@ -1522,7 +1522,7 @@
 					/* lba */ bp->bio_offset /
 					  softc->params.blksize,
 					bp->bio_bcount / softc->params.blksize,
-					/* data_ptr */ bp->bio_data,
+					/* data_ptr */(u_int8_t *)bp->bio_data,
 					/* dxfer_len */ bp->bio_bcount,
 					/* sense_len */ SSD_FULL_SIZE,
 					/* timeout */ 30000);
Index: scsi/scsi_ch.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_ch.c,v
retrieving revision 1.43
diff -u -u -r1.43 scsi_ch.c
--- scsi/scsi_ch.c	5 Dec 2006 07:45:28 -0000	1.43
+++ scsi/scsi_ch.c	18 Jan 2007 02:05:36 -0000
@@ -1063,7 +1063,7 @@
 	struct read_element_status_header *st_hdr;
 	struct read_element_status_page_header *pg_hdr;
 	struct read_element_status_descriptor *desc;
-	caddr_t data = NULL;
+	u_int8_t *data = NULL;
 	size_t size, desclen;
 	int avail, i, error = 0;
 	struct changer_element_status *user_data = NULL;
@@ -1091,7 +1091,7 @@
 	 * we can allocate enough storage for all of them.  We assume
 	 * that the first one can fit into 1k.
 	 */
-	data = (caddr_t)malloc(1024, M_DEVBUF, M_WAITOK);
+	data = (u_int8_t *)malloc(1024, M_DEVBUF, M_WAITOK);
 
 	ccb = cam_periph_getccb(periph, /*priority*/ 1);
 
@@ -1128,7 +1128,7 @@
 	 * device.
 	 */
 	free(data, M_DEVBUF);
-	data = (caddr_t)malloc(size, M_DEVBUF, M_WAITOK);
+	data = (u_int8_t *)malloc(size, M_DEVBUF, M_WAITOK);
 
 	scsi_read_element_status(&ccb->csio,
 				 /* retries */ 1,
Index: scsi/scsi_da.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_da.c,v
retrieving revision 1.200
diff -u -u -r1.200 scsi_da.c
--- scsi/scsi_da.c	5 Dec 2006 07:45:28 -0000	1.200
+++ scsi/scsi_da.c	18 Jan 2007 02:05:36 -0000
@@ -1277,7 +1277,7 @@
 						/*lba*/bp->bio_pblkno,
 						/*block_count*/bp->bio_bcount /
 						softc->params.secsize,
-						/*data_ptr*/ bp->bio_data,
+						/*data_ptr*/ (u_int8_t *)bp->bio_data,
 						/*dxfer_len*/ bp->bio_bcount,
 						/*sense_len*/SSD_FULL_SIZE,
 						/*timeout*/da_default_timeout*1000);
Index: scsi/scsi_low.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_low.c,v
retrieving revision 1.26
diff -u -u -r1.26 scsi_low.c
--- scsi/scsi_low.c	2 Nov 2006 00:54:33 -0000	1.26
+++ scsi/scsi_low.c	18 Jan 2007 02:05:36 -0000
@@ -150,7 +150,7 @@
 /**************************************************************
  * Declarations
  **************************************************************/
-/* static */ void scsi_low_info(struct scsi_low_softc *, struct targ_info *, u_char *);
+/* static */ void scsi_low_info(struct scsi_low_softc *, struct targ_info *, char *);
 static void scsi_low_engage(void *);
 static struct slccb *scsi_low_establish_ccb(struct targ_info *, struct lun_info *, scsi_low_tag_t);
 static int scsi_low_done(struct scsi_low_softc *, struct slccb *);
@@ -2934,7 +2934,7 @@
 scsi_low_restart(slp, flags, s)
 	struct scsi_low_softc *slp;
 	int flags;
-	u_char *s;
+	char *s;
 {
 	int error;
 
@@ -3022,7 +3022,7 @@
 {
 	struct targ_info *ti;
 	struct slccb *cb;
-	u_char *s;
+	char *s;
 
 	/* 
 	 * Check select vs reselected collision.
@@ -3768,7 +3768,7 @@
 {
 	struct targ_info *ti = slp->sl_Tnexus;
 	u_int period = 0, offset = 0, speed;
-	u_char *s;
+	char *s;
 	int error;
 
 	if ((MSGIN_PERIOD(ti) >= ti->ti_maxsynch.period &&
@@ -4732,7 +4732,7 @@
 scsi_low_info(slp, ti, s)
 	struct scsi_low_softc *slp;
 	struct targ_info *ti;
-	u_char *s;
+	char *s;
 {
 
 	if (slp == NULL)
@@ -4755,7 +4755,7 @@
 	}
 }
 
-static u_char *phase[] =
+static const char *phase[] =
 {
 	"FREE", "ARBSTART", "SELSTART", "SELECTED",
 	"CMDOUT", "DATA", "MSGIN", "MSGOUT", "STATIN", "DISC", "RESEL"
Index: scsi/scsi_low.h
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_low.h,v
retrieving revision 1.8
diff -u -u -r1.8 scsi_low.h
--- scsi/scsi_low.h	5 Jan 2005 22:34:34 -0000	1.8
+++ scsi/scsi_low.h	18 Jan 2007 02:05:36 -0000
@@ -547,7 +547,7 @@
 	struct scsi_low_osdep_interface sl_si;
 #define	sl_dev	sl_si.si_dev
 	struct scsi_low_osdep_funcs *sl_osdep_fp;
-	u_char sl_xname[16];
+	char sl_xname[16];
 				
 	/* our chain */
 	LIST_ENTRY(scsi_low_softc) sl_chain;
@@ -716,7 +716,7 @@
  */
 #define	SCSI_LOW_RESTART_HARD	1
 #define	SCSI_LOW_RESTART_SOFT	0
-int scsi_low_restart(struct scsi_low_softc *, int, u_char *);
+int scsi_low_restart(struct scsi_low_softc *, int, char *);
 
 /* 
  * Scsi utility fucntions
Index: scsi/scsi_pt.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_pt.c,v
retrieving revision 1.44
diff -u -u -r1.44 scsi_pt.c
--- scsi/scsi_pt.c	5 Dec 2006 07:45:28 -0000	1.44
+++ scsi/scsi_pt.c	18 Jan 2007 02:05:36 -0000
@@ -505,7 +505,7 @@
 				  bp->bio_cmd == BIO_READ,
 				  /*byte2*/0,
 				  bp->bio_bcount,
-				  bp->bio_data,
+				  (u_int8_t *)bp->bio_data,
 				  /*sense_len*/SSD_FULL_SIZE,
 				  /*timeout*/softc->io_timeout);
 
Index: scsi/scsi_sa.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_sa.c,v
retrieving revision 1.107
diff -u -u -r1.107 scsi_sa.c
--- scsi/scsi_sa.c	5 Dec 2006 07:45:28 -0000	1.107
+++ scsi/scsi_sa.c	18 Jan 2007 02:05:36 -0000
@@ -1734,7 +1734,7 @@
 			scsi_sa_read_write(&start_ccb->csio, 0, sadone,
 			    MSG_SIMPLE_Q_TAG, (bp->bio_cmd == BIO_READ),
 			    FALSE, (softc->flags & SA_FLAG_FIXED) != 0,
-			    length, bp->bio_data, bp->bio_bcount, SSD_FULL_SIZE,
+			    length, (u_int8_t *)bp->bio_data, bp->bio_bcount, SSD_FULL_SIZE,
 			    IO_TIMEOUT);
 			start_ccb->ccb_h.ccb_pflags &= ~SA_POSITION_UPDATED;
 			Set_CCB_Type(start_ccb, SA_CCB_BUFFER_IO);
Index: scsi/scsi_ses.c
===================================================================
RCS file: /home/ncvs/src/sys/cam/scsi/scsi_ses.c,v
retrieving revision 1.33
diff -u -u -r1.33 scsi_ses.c
--- scsi/scsi_ses.c	5 Dec 2006 07:45:28 -0000	1.33
+++ scsi/scsi_ses.c	18 Jan 2007 02:05:36 -0000
@@ -676,7 +676,7 @@
 	}
 
 	ccb = cam_periph_getccb(ssc->periph, 1);
-	cam_fill_csio(&ccb->csio, 0, sesdone, ddf, MSG_SIMPLE_Q_TAG, dptr,
+	cam_fill_csio(&ccb->csio, 0, sesdone, ddf, MSG_SIMPLE_Q_TAG, (u_int8_t *)dptr,
 	    dlen, sizeof (struct scsi_sense_data), cdbl, 60 * 1000);
 	bcopy(cdb, ccb->csio.cdb_io.cdb_bytes, cdbl);
 
@@ -728,7 +728,7 @@
 static enctyp
 ses_type(void *buf, int buflen)
 {
-	unsigned char *iqd = buf;
+	char *iqd = buf;
 
 	if (buflen < 8+SEN_ID_LEN)
 		return (SES_NONE);
@@ -762,7 +762,7 @@
 		return (SES_NONE);
 	}
 
-	if (STRNCMP((char *)&iqd[SAFTE_START], "SAF-TE", SAFTE_LEN - 2) == 0) {
+	if (STRNCMP(&iqd[SAFTE_START], "SAF-TE", SAFTE_LEN - 2) == 0) {
 		return (SES_SAFT);
 	}
 	return (SES_NONE);


More information about the freebsd-scsi mailing list