Module Name:    src
Committed By:   lukem
Date:           Sat Apr 11 12:41:11 UTC 2009

Modified Files:
        src/usr.bin/config: hash.c mkheaders.c mkioconf.c mkmakefile.c pack.c
            scan.l sem.c

Log Message:
Fix WARNS=4 issues (-Wcast-qual -Wsign-compare -Wshadow)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/config/hash.c src/usr.bin/config/pack.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/config/mkheaders.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/config/mkioconf.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/config/mkmakefile.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/config/scan.l
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/config/sem.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/config/hash.c
diff -u src/usr.bin/config/hash.c:1.5 src/usr.bin/config/hash.c:1.6
--- src/usr.bin/config/hash.c:1.5	Wed Dec 27 17:50:27 2006
+++ src/usr.bin/config/hash.c	Sat Apr 11 12:41:10 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.5 2006/12/27 17:50:27 alc Exp $	*/
+/*	$NetBSD: hash.c,v 1.6 2009/04/11 12:41:10 lukem Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -209,7 +209,7 @@
 void
 ht_free(struct hashtab *ht)
 {
-	int i;
+	size_t i;
 	struct hashent *hp;
 	struct hashenthead *hpp;
 
@@ -305,7 +305,7 @@
 {
 	struct hashent *hp;
 	struct hashenthead *hpp;
-	u_int i;
+	size_t i;
 	int rval = 0;
 	
 	for (i = 0; i < ht->ht_size; i++) {
Index: src/usr.bin/config/pack.c
diff -u src/usr.bin/config/pack.c:1.5 src/usr.bin/config/pack.c:1.6
--- src/usr.bin/config/pack.c:1.5	Sat Jan 13 23:47:36 2007
+++ src/usr.bin/config/pack.c	Sat Apr 11 12:41:10 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pack.c,v 1.5 2007/01/13 23:47:36 christos Exp $	*/
+/*	$NetBSD: pack.c,v 1.6 2009/04/11 12:41:10 lukem Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -288,9 +288,9 @@
 static int
 samelocs(const void *ptr, int off, int len)
 {
-	const char **p, **q;
+	const char * const *p, * const *q;
 
-	for (p = &locators.vec[off], q = (const char **)ptr; --len >= 0;)
+	for (p = &locators.vec[off], q = (const char * const *)ptr; --len >= 0;)
 		if (*p++ != *q++)
 			return (0);	/* different */
 	return (1);			/* same */
@@ -323,10 +323,10 @@
 	const struct pspec *p1, *p2;
 	int l1, l2;
 
-	p1 = (*(const struct devi **)a)->i_pspec;
+	p1 = (*(const struct devi * const *)a)->i_pspec;
 	l1 = p1 != NULL ? p1->p_iattr->a_loclen : 0;
 
-	p2 = (*(const struct devi **)b)->i_pspec;
+	p2 = (*(const struct devi * const *)b)->i_pspec;
 	l2 = p2 != NULL ? p2->p_iattr->a_loclen : 0;
 
 	return (l2 - l1);

Index: src/usr.bin/config/mkheaders.c
diff -u src/usr.bin/config/mkheaders.c:1.14 src/usr.bin/config/mkheaders.c:1.15
--- src/usr.bin/config/mkheaders.c:1.14	Sun Dec 28 01:23:46 2008
+++ src/usr.bin/config/mkheaders.c	Sat Apr 11 12:41:10 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkheaders.c,v 1.14 2008/12/28 01:23:46 christos Exp $	*/
+/*	$NetBSD: mkheaders.c,v 1.15 2009/04/11 12:41:10 lukem Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -72,9 +72,9 @@
  */
 
 /* Unlikely constant for undefined options */
-#define UNDEFINED ('n' << 24 | 0 << 20 | 't' << 12 | 0xdef)
+#define UNDEFINED ('n' << 24 | 0 << 20 | 't' << 12 | 0xdefU)
 /* Value for defined options with value UNDEFINED */
-#define	DEFINED (0xdef1 << 16 | 'n' << 8 | 0xed)
+#define	DEFINED (0xdef1U << 16 | 'n' << 8 | 0xed)
 
 /*
  * Make the various config-generated header files.
@@ -346,7 +346,7 @@
 static int
 emitlocs(void)
 {
-	char *tfname;
+	const char *tfname;
 	int rval;
 	FILE *tfp;
 	

Index: src/usr.bin/config/mkioconf.c
diff -u src/usr.bin/config/mkioconf.c:1.13 src/usr.bin/config/mkioconf.c:1.14
--- src/usr.bin/config/mkioconf.c:1.13	Tue Jan 20 18:20:48 2009
+++ src/usr.bin/config/mkioconf.c	Sat Apr 11 12:41:10 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkioconf.c,v 1.13 2009/01/20 18:20:48 drochner Exp $	*/
+/*	$NetBSD: mkioconf.c,v 1.14 2009/04/11 12:41:10 lukem Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -124,8 +124,8 @@
 {
 	int n1, n2;
 
-	n1 = (*(const struct devi **)a)->i_cfindex;
-	n2 = (*(const struct devi **)b)->i_cfindex;
+	n1 = (*(const struct devi * const *)a)->i_cfindex;
+	n2 = (*(const struct devi * const *)b)->i_cfindex;
 	return (n1 - n2);
 }
 
@@ -353,7 +353,7 @@
 	const char *state, *basename, *attachment;
 	struct nvlist *nv;
 	struct attr *a;
-	char *loc;
+	const char *loc;
 	char locbuf[20];
 	const char *lastname = "";
 

Index: src/usr.bin/config/mkmakefile.c
diff -u src/usr.bin/config/mkmakefile.c:1.12 src/usr.bin/config/mkmakefile.c:1.13
--- src/usr.bin/config/mkmakefile.c:1.12	Fri Mar 13 20:44:59 2009
+++ src/usr.bin/config/mkmakefile.c	Sat Apr 11 12:41:10 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkmakefile.c,v 1.12 2009/03/13 20:44:59 cube Exp $	*/
+/*	$NetBSD: mkmakefile.c,v 1.13 2009/04/11 12:41:10 lukem Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -280,7 +280,7 @@
 emitdefs(FILE *fp)
 {
 	struct nvlist *nv;
-	char *sp;
+	const char *sp;
 
 	fprintf(fp, "KERNEL_BUILD=%s\n", conffile);
 	fputs("IDENT=", fp);

Index: src/usr.bin/config/scan.l
diff -u src/usr.bin/config/scan.l:1.11 src/usr.bin/config/scan.l:1.12
--- src/usr.bin/config/scan.l:1.11	Thu Oct  9 07:18:15 2008
+++ src/usr.bin/config/scan.l	Sat Apr 11 12:41:10 2009
@@ -1,5 +1,5 @@
 %{
-/*	$NetBSD: scan.l,v 1.11 2008/10/09 07:18:15 dholland Exp $	*/
+/*	$NetBSD: scan.l,v 1.12 2009/04/11 12:41:10 lukem Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -412,7 +412,7 @@
 	if (SLIST_EMPTY(&curdirs))
 		panic("curdirs is empty");
 	/* LINTED cast away const (pf_prefix is malloc'd for curdirs) */
-	free((void *)pf->pf_prefix);
+	free((void *)__UNCONST(pf->pf_prefix));
 	free(pf);
 }
 
@@ -559,7 +559,7 @@
 	}
 
 	len = e-p;
-	if (len > sizeof(curinclpath)-1)
+	if (len > (ptrdiff_t)sizeof(curinclpath)-1)
 		len = sizeof(curinclpath)-1;
 	strncpy(curinclpath, p, sizeof(curinclpath));
 	curinclpath[len] = '\0';

Index: src/usr.bin/config/sem.c
diff -u src/usr.bin/config/sem.c:1.32 src/usr.bin/config/sem.c:1.33
--- src/usr.bin/config/sem.c:1.32	Tue Jan 20 18:20:48 2009
+++ src/usr.bin/config/sem.c	Sat Apr 11 12:41:10 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.32 2009/01/20 18:20:48 drochner Exp $	*/
+/*	$NetBSD: sem.c,v 1.33 2009/04/11 12:41:10 lukem Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -713,7 +713,7 @@
 	int unit;
 	char buf[NAMESIZE];
 
-	if ((u_int)(part -= 'a') >= maxpartitions)
+	if ((part -= 'a') >= maxpartitions || part < 0)
 		panic("resolve");
 	if ((nv = *nvp) == NULL) {
 		dev_t	d = NODEV;
@@ -721,7 +721,7 @@
 		 * Apply default.  Easiest to do this by number.
 		 * Make sure to retain NODEVness, if this is dflt's disposition.
 		 */
-		if (dflt->nv_num != NODEV) {
+		if ((dev_t)dflt->nv_num != NODEV) {
 			maj = major(dflt->nv_num);
 			min = ((minor(dflt->nv_num) / maxpartitions) *
 			    maxpartitions) + part;
@@ -731,7 +731,7 @@
 			cp = NULL;
 		*nvp = nv = newnv(NULL, cp, NULL, d, NULL);
 	}
-	if (nv->nv_num != NODEV) {
+	if ((dev_t)nv->nv_num != NODEV) {
 		/*
 		 * By the numbers.  Find the appropriate major number
 		 * to make a name.
@@ -780,7 +780,7 @@
 		nv->nv_ifunit = unit;	/* XXX XXX XXX */
 	} else {
 		maj = dev2major(dev);
-		if (maj == NODEV) {
+		if (maj == NODEVMAJOR) {
 			cfgerror("%s: can't make %s device from `%s'",
 			    name, what, nv->nv_str);
 			return (1);
@@ -1464,24 +1464,24 @@
 
 void
 adddevm(const char *name, devmajor_t cmajor, devmajor_t bmajor,
-	struct nvlist *options)
+	struct nvlist *nv)
 {
 	struct devm *dm;
 
 	if (cmajor != NODEVMAJOR && (cmajor < 0 || cmajor >= 4096)) {
 		cfgerror("character major %d is invalid", cmajor);
-		nvfreel(options);
+		nvfreel(nv);
 		return;
 	}
 
 	if (bmajor != NODEVMAJOR && (bmajor < 0 || bmajor >= 4096)) {
 		cfgerror("block major %d is invalid", bmajor);
-		nvfreel(options);
+		nvfreel(nv);
 		return;
 	}
 	if (cmajor == NODEVMAJOR && bmajor == NODEVMAJOR) {
 		cfgerror("both character/block majors are not specified");
-		nvfreel(options);
+		nvfreel(nv);
 		return;
 	}
 
@@ -1491,7 +1491,7 @@
 	dm->dm_name = name;
 	dm->dm_cmajor = cmajor;
 	dm->dm_bmajor = bmajor;
-	dm->dm_opts = options;
+	dm->dm_opts = nv;
 
 	TAILQ_INSERT_TAIL(&alldevms, dm, dm_next);
 

Reply via email to