Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Jul 2001 01:04:06 -0400 (EDT)
From:      Mike Barcroft <mike@q9media.com>
To:        Mike Heffner <mheffner@novacoxmail.com>
Cc:        audit@FreeBSD.org, Mike Heffner <mheffner@vt.edu>
Subject:   Re: src/bin/chio patch
Message-ID:  <200107030504.f63546R06427@coffee.q9media.com>

next in thread | raw e-mail | index | archive | help
> Unfortunately I had to revert the Makefile WARNS addition because I forgot to
> test on alpha first ;(  I'll try and look at cleaning up the alpha
> warnings tomorrow. Below is the compiler warnings from beast in case anyone
> wants to take a stab at it:
[warnings snipped.]

Sorry about that.  I should probably put a warning in my patch descriptions
that they need to be tested on an Alpha before committing.

I think I've corrected all the warnings in this patch.  Can you test it and
get back to me?  The patch is at the end of this message and also available
at: http://testbed.q9media.com/freebsd/chio.20010703.patch

Best regards,
Mike Barcroft

-----------------------------------------------------------------------

chio.20010703.patch

o Attempt to silence warnings generated on an Alpha.
o Set WARNS?=2


Index: chio/Makefile
===================================================================
RCS file: /home/ncvs/src/bin/chio/Makefile,v
retrieving revision 1.9
diff -u -r1.9 Makefile
--- chio/Makefile	2001/07/03 03:34:42	1.9
+++ chio/Makefile	2001/07/03 04:37:41
@@ -2,6 +2,7 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 PROG=	chio
+WARNS?=	2
 SRCS=	chio.c
 
 .include <bsd.prog.mk>
Index: chio/chio.c
===================================================================
RCS file: /home/ncvs/src/bin/chio/chio.c,v
retrieving revision 1.18
diff -u -r1.18 chio.c
--- chio/chio.c	2001/07/03 03:22:49	1.18
+++ chio/chio.c	2001/07/03 04:37:42
@@ -63,10 +63,11 @@
 static	const char * element_type_name __P((int et));
 static	int parse_special __P((char *));
 static	int is_special __P((char *));
-static	const char *bits_to_string __P((int, const char *));
+static	const char *bits_to_string __P((ces_status_flags, const char *));
 
 static	void find_element __P((char *, u_int16_t *, u_int16_t *));
-static	struct changer_element_status *get_element_status __P((u_int16_t, u_int16_t));
+static	struct changer_element_status *get_element_status
+	    __P((unsigned int, unsigned int));
 
 static	int do_move __P((const char *, int, char **));
 static	int do_exchange __P((const char *, int, char **));
@@ -689,7 +690,7 @@
 		/* Allocate storage for the status structures. */
 		cesr.cesr_element_status =
 		  (struct changer_element_status *) 
-		  calloc(count, sizeof(struct changer_element_status));
+		  calloc((size_t)count, sizeof(struct changer_element_status));
 		
 		if (!cesr.cesr_element_status)
 			errx(1, "can't allocate status storage");
@@ -845,8 +846,9 @@
 			goto usage;
 		}
 
-		strncpy(csvr.csvr_voltag.cv_volid, argv[2],
+		(void) memcpy(csvr.csvr_voltag.cv_volid, argv[2],
 		       sizeof(csvr.csvr_voltag.cv_volid));
+		csvr.csvr_voltag.cv_volid[strlen(argv[2]) + 1] = '\0';
 
 		if (argc == 4) {
 			csvr.csvr_voltag.cv_serial = atol(argv[3]);
@@ -944,7 +946,7 @@
 
 static const char *
 bits_to_string(v, cp)
-	int v;
+	ces_status_flags v;
 	const char *cp;
 {
 	const char *np;
@@ -1006,7 +1008,8 @@
 	}
 	++argv; --argc;
 
-	ces = get_element_status(type, element);	/* Get the status */
+	/* Get the status */
+	ces = get_element_status((unsigned int)type, (unsigned int)element);
 
 	if (NULL == ces)
 		errx(1, "%s: null element status pointer", cname);
@@ -1042,22 +1045,22 @@
  */
 static struct changer_element_status *
 get_element_status(type, element)
-	u_int16_t	type;
-	u_int16_t	element;
+	unsigned int	type;
+	unsigned int	element;
 {
 	struct changer_element_status_request cesr;
 	struct changer_element_status *ces;
 	
 	ces = (struct changer_element_status *)
-	    calloc(1, sizeof(struct changer_element_status));
+	    calloc((size_t)1, sizeof(struct changer_element_status));
 
 	if (NULL == ces)
 		errx(1, "can't allocate status storage");
 
 	(void)memset(&cesr, 0, sizeof(cesr));
 
-	cesr.cesr_element_type = type;
-	cesr.cesr_element_base = element;
+	cesr.cesr_element_type = (u_int16_t)type;
+	cesr.cesr_element_base = (u_int16_t)element;
 	cesr.cesr_element_count = 1;		/* Only this one element */
 	cesr.cesr_flags |= CESR_VOLTAGS;	/* Grab voltags as well */
 	cesr.cesr_element_status = ces;
@@ -1088,7 +1091,8 @@
 	struct changer_params cp;
 	struct changer_element_status_request cesr;
 	struct changer_element_status *ch_ces, *ces;
-	int elem, total_elem, found = 0;
+	int found = 0;
+	size_t elem, total_elem;
 
 	/*
 	 * Get the changer parameters, we're interested in the counts
@@ -1185,7 +1189,8 @@
 			continue;
 
 		/* Check to see if it is our target */
-		if (strcasecmp(voltag, ces->ces_pvoltag.cv_volid) == 0) {
+		if (strcasecmp(voltag,
+		    (const char *)ces->ces_pvoltag.cv_volid) == 0) {
 			*et = ces->ces_type;
 			*eu = ces->ces_addr;
 			++found;

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200107030504.f63546R06427>