Module Name:    src
Committed By:   christos
Date:           Tue May 19 20:44:52 UTC 2009

Modified Files:
        src/libexec/ld.elf_so: Makefile load.c map_object.c paths.c rtld.c
            rtld.h xmalloc.c xprintf.c

Log Message:
warns=4


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/libexec/ld.elf_so/Makefile
cvs rdiff -u -r1.35 -r1.36 src/libexec/ld.elf_so/load.c
cvs rdiff -u -r1.37 -r1.38 src/libexec/ld.elf_so/map_object.c
cvs rdiff -u -r1.39 -r1.40 src/libexec/ld.elf_so/paths.c
cvs rdiff -u -r1.123 -r1.124 src/libexec/ld.elf_so/rtld.c
cvs rdiff -u -r1.79 -r1.80 src/libexec/ld.elf_so/rtld.h
cvs rdiff -u -r1.8 -r1.9 src/libexec/ld.elf_so/xmalloc.c
cvs rdiff -u -r1.19 -r1.20 src/libexec/ld.elf_so/xprintf.c

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

Modified files:

Index: src/libexec/ld.elf_so/Makefile
diff -u src/libexec/ld.elf_so/Makefile:1.88 src/libexec/ld.elf_so/Makefile:1.89
--- src/libexec/ld.elf_so/Makefile:1.88	Sun Mar 15 22:24:56 2009
+++ src/libexec/ld.elf_so/Makefile	Tue May 19 16:44:52 2009
@@ -1,6 +1,6 @@
-#	$NetBSD: Makefile,v 1.88 2009/03/16 02:24:56 lukem Exp $
+#	$NetBSD: Makefile,v 1.89 2009/05/19 20:44:52 christos Exp $
 
-WARNS?=2	# XXX: too many sign-compare issues in xmalloc.c
+WARNS?=4
 
 # We are not building this with PIE
 PIE_CFLAGS=

Index: src/libexec/ld.elf_so/load.c
diff -u src/libexec/ld.elf_so/load.c:1.35 src/libexec/ld.elf_so/load.c:1.36
--- src/libexec/ld.elf_so/load.c:1.35	Fri Dec  7 15:34:04 2007
+++ src/libexec/ld.elf_so/load.c	Tue May 19 16:44:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: load.c,v 1.35 2007/12/07 20:34:04 ad Exp $	 */
+/*	$NetBSD: load.c,v 1.36 2009/05/19 20:44:52 christos Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: load.c,v 1.35 2007/12/07 20:34:04 ad Exp $");
+__RCSID("$NetBSD: load.c,v 1.36 2009/05/19 20:44:52 christos Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -185,7 +185,8 @@
 {
 	Library_Xform *x = _rtld_xforms;
 	Obj_Entry *o = NULL;
-	size_t i, j;
+	size_t j;
+	ssize_t i;
 	bool got = false;
 	union {
 		int i;

Index: src/libexec/ld.elf_so/map_object.c
diff -u src/libexec/ld.elf_so/map_object.c:1.37 src/libexec/ld.elf_so/map_object.c:1.38
--- src/libexec/ld.elf_so/map_object.c:1.37	Mon Jan  5 23:01:46 2009
+++ src/libexec/ld.elf_so/map_object.c	Tue May 19 16:44:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: map_object.c,v 1.37 2009/01/06 04:01:46 mrg Exp $	 */
+/*	$NetBSD: map_object.c,v 1.38 2009/05/19 20:44:52 christos Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: map_object.c,v 1.37 2009/01/06 04:01:46 mrg Exp $");
+__RCSID("$NetBSD: map_object.c,v 1.38 2009/05/19 20:44:52 christos Exp $");
 #endif /* not lint */
 
 #include <errno.h>
@@ -91,7 +91,7 @@
 	size_t		 nclear;
 #endif
 
-	if (sb != NULL && sb->st_size < sizeof (Elf_Ehdr)) {
+	if (sb != NULL && sb->st_size < (off_t)sizeof (Elf_Ehdr)) {
 		_rtld_error("%s: unrecognized file format1", path);
 		return NULL;
 	}

Index: src/libexec/ld.elf_so/paths.c
diff -u src/libexec/ld.elf_so/paths.c:1.39 src/libexec/ld.elf_so/paths.c:1.40
--- src/libexec/ld.elf_so/paths.c:1.39	Wed Jun  4 20:03:20 2008
+++ src/libexec/ld.elf_so/paths.c	Tue May 19 16:44:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: paths.c,v 1.39 2008/06/05 00:03:20 ad Exp $	 */
+/*	$NetBSD: paths.c,v 1.40 2009/05/19 20:44:52 christos Exp $	 */
 
 /*
  * Copyright 1996 Matt Thomas <[email protected]>
@@ -30,7 +30,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: paths.c,v 1.39 2008/06/05 00:03:20 ad Exp $");
+__RCSID("$NetBSD: paths.c,v 1.40 2009/05/19 20:44:52 christos Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -357,7 +357,7 @@
 		(void)close(fd);
 		return;
 	}
-	if (sz >= sizeof(small)) {
+	if (sz >= (ssize_t)sizeof(small)) {
 		if (fstat(fd, &st) == -1) {
 			/* Complain */
 			xwarn("fstat: %s", fname);
@@ -414,8 +414,8 @@
 {
 	const char *node, *ep;
 	struct sysctlnode query, *result, *newresult;
-	int mib[CTL_MAXNAME], i, r;
-	size_t res_size, n;
+	int mib[CTL_MAXNAME], r;
+	size_t res_size, n, i;
 	u_int miblen = 0;
 
 	/* Start with 16 entries, will grow it up as needed. */
@@ -426,7 +426,7 @@
 
 	ep = name + strlen(name);
 	do {
-		i = -1;
+		i = ~0ul;
 		while (*name == '/' || *name == '.')
 			name++;
 		if (name >= ep)
@@ -463,7 +463,7 @@
 			}
 	} while (name < ep && miblen <= CTL_MAXNAME);
 
-	if (name < ep || i == -1)
+	if (name < ep || i == ~0ul)
 		goto bad;
 	r = SYSCTL_TYPE(result[i].sysctl_flags);
 

Index: src/libexec/ld.elf_so/rtld.c
diff -u src/libexec/ld.elf_so/rtld.c:1.123 src/libexec/ld.elf_so/rtld.c:1.124
--- src/libexec/ld.elf_so/rtld.c:1.123	Sun Oct 26 03:11:54 2008
+++ src/libexec/ld.elf_so/rtld.c	Tue May 19 16:44:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtld.c,v 1.123 2008/10/26 07:11:54 mrg Exp $	 */
+/*	$NetBSD: rtld.c,v 1.124 2009/05/19 20:44:52 christos Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.123 2008/10/26 07:11:54 mrg Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.124 2009/05/19 20:44:52 christos Exp $");
 #endif /* not lint */
 
 #include <err.h>
@@ -92,7 +92,7 @@
     .st_info	= ELF_ST_INFO(STB_GLOBAL, STT_NOTYPE),
     .st_shndx	= SHN_ABS,
 };
-int		_rtld_pagesz;	/* Page size, as provided by kernel */
+unsigned int	_rtld_pagesz;	/* Page size, as provided by kernel */
 
 Search_Path    *_rtld_default_paths;
 Search_Path    *_rtld_paths;
@@ -898,7 +898,7 @@
 
 			/* Search the object and all the libraries loaded by it. */
 			fake.next = NULL;
-			fake.obj = (Obj_Entry *)obj;
+			fake.obj = __UNCONST(obj);
 			fake.name = 0;
 			def = _rtld_symlook_needed(name, hash, &fake, &defobj,
 			    false);

Index: src/libexec/ld.elf_so/rtld.h
diff -u src/libexec/ld.elf_so/rtld.h:1.79 src/libexec/ld.elf_so/rtld.h:1.80
--- src/libexec/ld.elf_so/rtld.h:1.79	Sat Oct  4 05:37:12 2008
+++ src/libexec/ld.elf_so/rtld.h	Tue May 19 16:44:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtld.h,v 1.79 2008/10/04 09:37:12 skrll Exp $	 */
+/*	$NetBSD: rtld.h,v 1.80 2009/05/19 20:44:52 christos Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -51,7 +51,7 @@
 #endif
 #define _PATH_LD_HINTS			"/etc/ld.so.conf"
 
-extern int _rtld_pagesz;
+extern unsigned int _rtld_pagesz;
 
 #define round_down(x)	((x) & ~(_rtld_pagesz - 1))
 #define round_up(x)	round_down((x) + _rtld_pagesz - 1)

Index: src/libexec/ld.elf_so/xmalloc.c
diff -u src/libexec/ld.elf_so/xmalloc.c:1.8 src/libexec/ld.elf_so/xmalloc.c:1.9
--- src/libexec/ld.elf_so/xmalloc.c:1.8	Tue Jun  3 15:22:07 2008
+++ src/libexec/ld.elf_so/xmalloc.c	Tue May 19 16:44:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: xmalloc.c,v 1.8 2008/06/03 19:22:07 ad Exp $	*/
+/*	$NetBSD: xmalloc.c,v 1.9 2009/05/19 20:44:52 christos Exp $	*/
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -77,7 +77,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: xmalloc.c,v 1.8 2008/06/03 19:22:07 ad Exp $");
+__RCSID("$NetBSD: xmalloc.c,v 1.9 2009/05/19 20:44:52 christos Exp $");
 #endif /* not lint */
 
 #include <stdlib.h>
@@ -96,8 +96,9 @@
  * Pre-allocate mmap'ed pages
  */
 #define	NPOOLPAGES	(32*1024/pagesz)
-static caddr_t		pagepool_start, pagepool_end;
+static char 		*pagepool_start, *pagepool_end;
 static int		morepages(int);
+#define PAGEPOOL_SIZE	(size_t)(pagepool_end - pagepool_start)
 
 /*
  * The overhead on a block is at least 4 bytes.  When free, this space
@@ -125,7 +126,7 @@
 #define	ov_size		ovu.ovu_size
 };
 
-static void morecore(int);
+static void morecore(size_t);
 static void *imalloc(size_t);
 
 #define	MAGIC		0xef		/* magic # on accounting info */
@@ -145,8 +146,8 @@
 #define	NBUCKETS 30
 static	union overhead *nextf[NBUCKETS];
 
-static	int pagesz;			/* page size */
-static	int pagebucket;			/* page size bucket */
+static	size_t pagesz;			/* page size */
+static	size_t pagebucket;		/* page size bucket */
 
 #ifdef MSTATS
 /*
@@ -174,10 +175,10 @@
 static void *
 imalloc(size_t nbytes)
 {
-  	register union overhead *op;
-  	register int bucket;
-	register long n;
-	register unsigned amt;
+  	union overhead *op;
+  	size_t bucket;
+	size_t n, m;
+	unsigned amt;
 
 	/*
 	 * First time malloc is called, setup page size and
@@ -188,9 +189,11 @@
 		if (morepages(NPOOLPAGES) == 0)
 			return NULL;
 		op = (union overhead *)(pagepool_start);
-  		n = n - sizeof (*op) - (((char *)op - (char *)NULL) & (n - 1));
-		if (n < 0)
-			n += pagesz;
+		m = sizeof (*op) - (((char *)op - (char *)NULL) & (n - 1));
+		if (n < m)
+			n += pagesz - m;
+		else
+			n -= m;
   		if (n) {
 			pagepool_start += n;
 		}
@@ -258,12 +261,12 @@
  * Allocate more memory to the indicated bucket.
  */
 static void
-morecore(int bucket)
+morecore(size_t bucket)
 {
-  	register union overhead *op;
-	register int sz;		/* size of desired block */
-  	int amt;			/* amount to allocate */
-  	int nblks;			/* how many blocks we get */
+  	union overhead *op;
+	size_t sz;		/* size of desired block */
+  	size_t amt;		/* amount to allocate */
+  	size_t nblks;		/* how many blocks we get */
 
 	/*
 	 * sbrk_size <= 0 only for big, FLUFFY, requests (about
@@ -272,9 +275,6 @@
 	sz = 1 << (bucket + 3);
 #ifdef MALLOC_DEBUG
 	ASSERT(sz > 0);
-#else
-	if (sz <= 0)
-		return;
 #endif
 	if (sz < pagesz) {
 		amt = pagesz;
@@ -283,7 +283,7 @@
 		amt = sz + pagesz;
 		nblks = 1;
 	}
-	if (amt > pagepool_end - pagepool_start)
+	if (amt > PAGEPOOL_SIZE)
 		if (morepages(amt/pagesz + NPOOLPAGES) == 0)
 			return;
 	op = (union overhead *)pagepool_start;
@@ -304,8 +304,8 @@
 xfree(cp)
 	void *cp;
 {
-  	register int size;
-	register union overhead *op;
+  	int size;
+	union overhead *op;
 
   	if (cp == NULL)
   		return;
@@ -332,8 +332,8 @@
 static void *
 irealloc(void *cp, size_t nbytes)
 {
-  	register u_int onb;
-	register int i;
+  	size_t onb;
+	size_t i;
 	union overhead *op;
   	char *res;
 
@@ -388,8 +388,8 @@
  */
 mstats(char *s)
 {
-  	register int i, j;
-  	register union overhead *p;
+  	int i, j;
+  	union overhead *p;
   	int totfree = 0,
   	totused = 0;
 
@@ -423,7 +423,7 @@
 		xerr(1, "/dev/zero");
 #endif
 
-	if (pagepool_end - pagepool_start > pagesz) {
+	if (PAGEPOOL_SIZE > pagesz) {
 		caddr_t	addr = (caddr_t)
 			(((long)pagepool_start + pagesz - 1) & ~(pagesz - 1));
 		if (munmap(addr, pagepool_end - addr) != 0)

Index: src/libexec/ld.elf_so/xprintf.c
diff -u src/libexec/ld.elf_so/xprintf.c:1.19 src/libexec/ld.elf_so/xprintf.c:1.20
--- src/libexec/ld.elf_so/xprintf.c:1.19	Sat Nov 24 13:32:26 2007
+++ src/libexec/ld.elf_so/xprintf.c	Tue May 19 16:44:52 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: xprintf.c,v 1.19 2007/11/24 18:32:26 christos Exp $	 */
+/*	$NetBSD: xprintf.c,v 1.20 2009/05/19 20:44:52 christos Exp $	 */
 
 /*
  * Copyright 1996 Matt Thomas <[email protected]>
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: xprintf.c,v 1.19 2007/11/24 18:32:26 christos Exp $");
+__RCSID("$NetBSD: xprintf.c,v 1.20 2009/05/19 20:44:52 christos Exp $");
 #endif /* not lint */
 
 #include <string.h>
@@ -92,16 +92,18 @@
 				char digits[sizeof(int) * 3], *dp = digits;
 #define	SARG() \
 (size & SZ_LONG ? va_arg(ap, long) : \
-((size & SZ_SIZE_T ? va_arg(ap, size_t) : \
+((size & SZ_SIZE_T ? (long)va_arg(ap, size_t) : \
 va_arg(ap, int))))
 #define	UARG() \
 (size & SZ_LONG ? va_arg(ap, unsigned long) : \
 ((size & SZ_SIZE_T ? va_arg(ap, size_t) : \
 va_arg(ap, unsigned int))))
-#define	ARG()	(size & SZ_UNSIGNED ? UARG() : SARG())
 
 				if (fmt[1] == 'd') {
-					sval = ARG();
+					if (size & SZ_UNSIGNED)
+						sval = UARG();
+					else
+						sval = SARG();
 					if (sval < 0) {
 						if ((sval << 1) == 0) {
 							/*
@@ -126,7 +128,10 @@
 						uval = sval;
 					}
 				} else {
-					uval = ARG();
+					if (size & SZ_UNSIGNED)
+						uval = UARG();
+					else
+						uval = SARG();
 				}
 				do {
 					*dp++ = '0' + (uval % 10);

Reply via email to