Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Oct 2011 01:36:17 -0400
From:      Eitan Adler <lists@eitanadler.com>
To:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   fix some warnings with sbin/camcontrol
Message-ID:  <CAF6rxgm3r%2BZ4gFXN_4=65ov268W_oFXix_wMZgZ4OT_pFPq6jg@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
The following patch reduced the number of warnings camcontrol produces
when compiled with clang to 29 from over 50

Index: camcontrol.c
===================================================================
--- camcontrol.c	(revision 226375)
+++ camcontrol.c	(working copy)
@@ -455,7 +455,7 @@
 			}
 			case DEV_MATCH_DEVICE: {
 				struct device_match_result *dev_result;
-				char vendor[16], product[48], revision[16];
+				unsigned char vendor[16], product[48], revision[16];
 				char tmpstr[256];

 				dev_result =
@@ -1456,12 +1456,12 @@
 	while (isspace(*tstr) && (*tstr != '\0'))
 		tstr++;

-	tmpstr = (char *)strtok(tstr, ":");
+	tmpstr = strtok(tstr, ":");
 	if ((tmpstr != NULL) && (*tmpstr != '\0')) {
 		*bus = strtol(tmpstr, NULL, 0);
 		*arglst |= CAM_ARG_BUS;
 		convs++;
-		tmpstr = (char *)strtok(NULL, ":");
+		tmpstr = strtok(NULL, ":");
 		if ((tmpstr != NULL) && (*tmpstr != '\0')) {
 			*target = strtol(tmpstr, NULL, 0);
 			*arglst |= CAM_ARG_TARGET;
@@ -2506,7 +2506,7 @@

 	if (((retval = cam_send_ccb(device, ccb)) < 0)
 	 || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) {
-		const char *warnstr = "error sending command";
+		const char * const warnstr = "error sending command";

 		if (retval < 0)
 			warn(warnstr);
@@ -4469,7 +4469,7 @@

 	if (((retval = cam_send_ccb(device, ccb)) < 0)
 	 || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) {
-		const char *warnstr = "error sending command";
+		const char * const warnstr = "error sending command";

 		if (retval < 0)
 			warn(warnstr);
@@ -4587,7 +4587,7 @@

 	if (((retval = cam_send_ccb(device, ccb)) < 0)
 	 || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) {
-		const char *warnstr = "error sending command";
+		const char * const warnstr = "error sending command";

 		if (retval < 0)
 			warn(warnstr);
@@ -4892,7 +4892,7 @@

 	if (((retval = cam_send_ccb(device, ccb)) < 0)
 	 || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) {
-		const char *warnstr = "error sending command";
+		const char * const warnstr = "error sending command";

 		if (retval < 0)
 			warn(warnstr);
@@ -4974,7 +4974,7 @@

 	if (((retval = cam_send_ccb(device, ccb)) < 0)
 	 || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) {
-		const char *warnstr = "error sending command";
+		const char * const warnstr = "error sending command";

 		if (retval < 0)
 			warn(warnstr);
@@ -5371,7 +5371,7 @@

 	if (((retval = cam_send_ccb(device, ccb)) < 0)
 	 || ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)) {
-		const char *warnstr = "error sending command";
+		const char * const warnstr = "error sending command";

 		if (retval < 0)
 			warn(warnstr);
@@ -5426,7 +5426,7 @@
 	for (i = 0; i < num_phys; i++) {
 		struct cam_devitem *item;
 		struct device_match_result *dev_match;
-		char vendor[16], product[48], revision[16];
+		unsigned char vendor[16], product[48], revision[16];
 		char tmpstr[256];
 		int j;

@@ -5451,7 +5451,7 @@
 		if (((retval = cam_send_ccb(device, ccb)) < 0)
 		 || (((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP)
 		  && (disresponse->function_result != SMP_FR_PHY_VACANT))) {
-			const char *warnstr = "error sending command";
+			const char * const warnstr = "error sending command";

 			if (retval < 0)
 				warn(warnstr);


-- 
Eitan Adler



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAF6rxgm3r%2BZ4gFXN_4=65ov268W_oFXix_wMZgZ4OT_pFPq6jg>