Module Name:    src
Committed By:   christos
Date:           Fri Nov 21 20:46:56 UTC 2014

Modified Files:
        src/usr.bin/config: mkmakefile.c sem.c sem.h

Log Message:
Use proper index types, delete casts, use correct sizeof() in allocations.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/config/mkmakefile.c
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/config/sem.c
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/config/sem.h

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/mkmakefile.c
diff -u src/usr.bin/config/mkmakefile.c:1.33 src/usr.bin/config/mkmakefile.c:1.34
--- src/usr.bin/config/mkmakefile.c:1.33	Sun Nov 16 19:53:15 2014
+++ src/usr.bin/config/mkmakefile.c	Fri Nov 21 15:46:56 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkmakefile.c,v 1.33 2014/11/17 00:53:15 uebayasi Exp $	*/
+/*	$NetBSD: mkmakefile.c,v 1.34 2014/11/21 20:46:56 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: mkmakefile.c,v 1.33 2014/11/17 00:53:15 uebayasi Exp $");
+__RCSID("$NetBSD: mkmakefile.c,v 1.34 2014/11/21 20:46:56 christos Exp $");
 
 #include <sys/param.h>
 #include <ctype.h>
@@ -364,18 +364,18 @@ static void weighattr(struct attr *a);
 static int attrcmp(const void *l, const void *r);
 
 struct attr **attrbuf;
-int attridx;
+size_t attridx;
 
 static void
 emitallkobjs(FILE *fp)
 {
-	int i;
+	size_t i;
 
-	attrbuf = emalloc((size_t)nattrs * sizeof(attrbuf));
+	attrbuf = emalloc(nattrs * sizeof(*attrbuf));
 
 	ht_enumerate(attrtab, emitallkobjsweighcb, NULL);
 	ht_enumerate(attrtab, emitallkobjscb, NULL);
-	qsort(attrbuf, (size_t)attridx, sizeof(struct attr *), attrcmp);
+	qsort(attrbuf, attridx, sizeof(struct attr *), attrcmp);
 
 	fputs("OBJS= \\\n", fp);
 	for (i = 0; i < attridx; i++)
@@ -398,7 +398,7 @@ emitallkobjscb(const char *name, void *v
 	/* XXX nattrs tracking is not exact yet */
 	if (attridx == nattrs) {
 		nattrs *= 2;
-		attrbuf = erealloc(attrbuf, (size_t)nattrs * sizeof(attrbuf));
+		attrbuf = erealloc(attrbuf, nattrs * sizeof(*attrbuf));
 	}
 	return 0;
 }

Index: src/usr.bin/config/sem.c
diff -u src/usr.bin/config/sem.c:1.70 src/usr.bin/config/sem.c:1.71
--- src/usr.bin/config/sem.c:1.70	Sat Nov 15 03:21:38 2014
+++ src/usr.bin/config/sem.c	Fri Nov 21 15:46:56 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.c,v 1.70 2014/11/15 08:21:38 uebayasi Exp $	*/
+/*	$NetBSD: sem.c,v 1.71 2014/11/21 20:46:56 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: sem.c,v 1.70 2014/11/15 08:21:38 uebayasi Exp $");
+__RCSID("$NetBSD: sem.c,v 1.71 2014/11/21 20:46:56 christos Exp $");
 
 #include <sys/param.h>
 #include <ctype.h>
@@ -69,7 +69,7 @@ const char *s_none;
 static struct hashtab *cfhashtab;	/* for config lookup */
 struct hashtab *devitab;		/* etc */
 struct attr allattr;
-int nattrs;
+size_t nattrs;
 
 static struct attr errattr;
 static struct devbase errdev;

Index: src/usr.bin/config/sem.h
diff -u src/usr.bin/config/sem.h:1.18 src/usr.bin/config/sem.h:1.19
--- src/usr.bin/config/sem.h:1.18	Sat Nov 15 03:21:38 2014
+++ src/usr.bin/config/sem.h	Fri Nov 21 15:46:56 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: sem.h,v 1.18 2014/11/15 08:21:38 uebayasi Exp $	*/
+/*	$NetBSD: sem.h,v 1.19 2014/11/21 20:46:56 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -88,4 +88,4 @@ int		has_attr(struct attrlist *, const c
 extern const char *s_qmark;
 extern const char *s_none;
 extern const char *s_ifnet;
-extern int nattrs;
+extern size_t nattrs;

Reply via email to