Module Name:    src
Committed By:   christos
Date:           Fri Mar  9 15:41:16 UTC 2012

Modified Files:
        src/common/lib/libc/inet: inet_addr.c
        src/common/lib/libc/quad: ashldi3.c ashrdi3.c lshrdi3.c qdivrem.c
            quad.h
        src/common/lib/libc/stdlib: _strtol.h _strtoul.h
        src/common/lib/libc/string: bcmp.c popcount64.c
        src/common/lib/libc/sys: cpuset.c

Log Message:
Casts and type changes to fix portability issues.
- int -> size_t
- adjust width of RHS of shift
- adjust widths of types


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/inet/inet_addr.c
cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/quad/ashldi3.c \
    src/common/lib/libc/quad/ashrdi3.c src/common/lib/libc/quad/lshrdi3.c \
    src/common/lib/libc/quad/qdivrem.c
cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/quad/quad.h
cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/stdlib/_strtol.h
cvs rdiff -u -r1.1 -r1.2 src/common/lib/libc/stdlib/_strtoul.h
cvs rdiff -u -r1.6 -r1.7 src/common/lib/libc/string/bcmp.c \
    src/common/lib/libc/string/popcount64.c
cvs rdiff -u -r1.17 -r1.18 src/common/lib/libc/sys/cpuset.c

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

Modified files:

Index: src/common/lib/libc/inet/inet_addr.c
diff -u src/common/lib/libc/inet/inet_addr.c:1.2 src/common/lib/libc/inet/inet_addr.c:1.3
--- src/common/lib/libc/inet/inet_addr.c:1.2	Sat Feb 16 12:37:13 2008
+++ src/common/lib/libc/inet/inet_addr.c	Fri Mar  9 10:41:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: inet_addr.c,v 1.2 2008/02/16 17:37:13 apb Exp $	*/
+/*	$NetBSD: inet_addr.c,v 1.3 2012/03/09 15:41:16 christos Exp $	*/
 
 /*
  * Copyright (c) 1983, 1990, 1993
@@ -77,7 +77,7 @@
 static const char sccsid[] = "@(#)inet_addr.c	8.1 (Berkeley) 6/17/93";
 static const char rcsid[] = "Id: inet_addr.c,v 1.2.206.2 2004/03/17 00:29:45 marka Exp";
 #else
-__RCSID("$NetBSD: inet_addr.c,v 1.2 2008/02/16 17:37:13 apb Exp $");
+__RCSID("$NetBSD: inet_addr.c,v 1.3 2012/03/09 15:41:16 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -125,7 +125,8 @@ inet_addr(const char *cp) {
 int
 inet_aton(const char *cp, struct in_addr *addr) {
 	uint32_t val;
-	int base, n;
+	int base;
+	size_t n;
 	char c;
 	uint8_t parts[4];
 	uint8_t *pp = parts;

Index: src/common/lib/libc/quad/ashldi3.c
diff -u src/common/lib/libc/quad/ashldi3.c:1.2 src/common/lib/libc/quad/ashldi3.c:1.3
--- src/common/lib/libc/quad/ashldi3.c:1.2	Sun Mar 15 18:31:12 2009
+++ src/common/lib/libc/quad/ashldi3.c	Fri Mar  9 10:41:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ashldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $	*/
+/*	$NetBSD: ashldi3.c,v 1.3 2012/03/09 15:41:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)ashldi3.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: ashldi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
+__RCSID("$NetBSD: ashldi3.c,v 1.3 2012/03/09 15:41:16 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -57,7 +57,7 @@ __ashldi3(quad_t a, qshift_t shift)
 		return(a);
 	aa.q = a;
 	if (shift >= INT_BITS) {
-		aa.ul[H] = aa.ul[L] << (shift - INT_BITS);
+		aa.ul[H] = aa.ul[L] << (unsigned int)(shift - INT_BITS);
 		aa.ul[L] = 0;
 	} else {
 		aa.ul[H] = (aa.ul[H] << shift) |
Index: src/common/lib/libc/quad/ashrdi3.c
diff -u src/common/lib/libc/quad/ashrdi3.c:1.2 src/common/lib/libc/quad/ashrdi3.c:1.3
--- src/common/lib/libc/quad/ashrdi3.c:1.2	Sun Mar 15 18:31:12 2009
+++ src/common/lib/libc/quad/ashrdi3.c	Fri Mar  9 10:41:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ashrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $	*/
+/*	$NetBSD: ashrdi3.c,v 1.3 2012/03/09 15:41:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)ashrdi3.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: ashrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
+__RCSID("$NetBSD: ashrdi3.c,v 1.3 2012/03/09 15:41:16 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -72,7 +72,7 @@ __ashrdi3(quad_t a, qshift_t shift)
 		aa.ul[H] = s;
 	} else {
 		aa.ul[L] = (aa.ul[L] >> shift) |
-		    (aa.ul[H] << (INT_BITS - shift));
+		    (aa.ul[H] << (unsigned int)(INT_BITS - shift));
 		/* LINTED inherits machine dependency */
 		aa.sl[H] >>= shift;
 	}
Index: src/common/lib/libc/quad/lshrdi3.c
diff -u src/common/lib/libc/quad/lshrdi3.c:1.2 src/common/lib/libc/quad/lshrdi3.c:1.3
--- src/common/lib/libc/quad/lshrdi3.c:1.2	Sun Mar 15 18:31:12 2009
+++ src/common/lib/libc/quad/lshrdi3.c	Fri Mar  9 10:41:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: lshrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $	*/
+/*	$NetBSD: lshrdi3.c,v 1.3 2012/03/09 15:41:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)lshrdi3.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: lshrdi3.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
+__RCSID("$NetBSD: lshrdi3.c,v 1.3 2012/03/09 15:41:16 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -60,7 +60,7 @@ __lshrdi3(quad_t a, qshift_t shift)
 		aa.ul[H] = 0;
 	} else {
 		aa.ul[L] = (aa.ul[L] >> shift) |
-		    (aa.ul[H] << (INT_BITS - shift));
+		    (aa.ul[H] << (unsigned int)(INT_BITS - shift));
 		aa.ul[H] >>= shift;
 	}
 	return (aa.q);
Index: src/common/lib/libc/quad/qdivrem.c
diff -u src/common/lib/libc/quad/qdivrem.c:1.2 src/common/lib/libc/quad/qdivrem.c:1.3
--- src/common/lib/libc/quad/qdivrem.c:1.2	Sun Mar 15 18:31:12 2009
+++ src/common/lib/libc/quad/qdivrem.c	Fri Mar  9 10:41:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: qdivrem.c,v 1.2 2009/03/15 22:31:12 cegger Exp $	*/
+/*	$NetBSD: qdivrem.c,v 1.3 2012/03/09 15:41:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)qdivrem.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: qdivrem.c,v 1.2 2009/03/15 22:31:12 cegger Exp $");
+__RCSID("$NetBSD: qdivrem.c,v 1.3 2012/03/09 15:41:16 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -49,10 +49,10 @@ __RCSID("$NetBSD: qdivrem.c,v 1.2 2009/0
 
 #include "quad.h"
 
-#define	B	((int)1 << HALF_BITS)	/* digit base */
+#define	B	((int)1 << (unsigned int)HALF_BITS)	/* digit base */
 
 /* Combine two `digits' to make a single two-digit number. */
-#define	COMBINE(a, b) (((u_int)(a) << HALF_BITS) | (b))
+#define	COMBINE(a, b) (((u_int)(a) << (unsigned int)HALF_BITS) | (b))
 
 /* select a type for digits in base B: use unsigned short if they fit */
 #if UINT_MAX == 0xffffffffU && USHRT_MAX >= 0xffff
@@ -173,7 +173,7 @@ __qdivrem(u_quad_t uq, u_quad_t vq, u_qu
 	 * D1: choose multiplier 1 << d to ensure v[1] >= B/2.
 	 */
 	d = 0;
-	for (t = v[1]; t < B / 2; t <<= 1)
+	for (t = v[1]; t < B / 2; t <<= (unsigned int)1)
 		d++;
 	if (d > 0) {
 		shl(&u[0], m + n, d);		/* u <<= d */
@@ -254,7 +254,7 @@ __qdivrem(u_quad_t uq, u_quad_t vq, u_qu
 		if (d) {
 			for (i = m + n; i > m; --i)
 				u[i] = (digit)(((u_int)u[i] >> d) |
-				    LHALF((u_int)u[i - 1] << (HALF_BITS - d)));
+				    LHALF((u_int)u[i - 1] << (unsigned int)(HALF_BITS - d)));
 			u[i] = 0;
 		}
 		tmp.ul[H] = COMBINE(uspace[1], uspace[2]);

Index: src/common/lib/libc/quad/quad.h
diff -u src/common/lib/libc/quad/quad.h:1.4 src/common/lib/libc/quad/quad.h:1.5
--- src/common/lib/libc/quad/quad.h:1.4	Fri Jul  8 22:36:01 2011
+++ src/common/lib/libc/quad/quad.h	Fri Mar  9 10:41:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quad.h,v 1.4 2011/07/09 02:36:01 matt Exp $	*/
+/*	$NetBSD: quad.h,v 1.5 2012/03/09 15:41:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -94,8 +94,8 @@ union uu {
  * (sizeof(int)*CHAR_BIT/2).
  */
 #define	HHALF(x)	((u_int)(x) >> HALF_BITS)
-#define	LHALF(x)	((u_int)(x) & (((int)1 << HALF_BITS) - 1))
-#define	LHUP(x)		((u_int)(x) << HALF_BITS)
+#define	LHALF(x)	((u_int)(x) & (((int)1 << (u_int)HALF_BITS) - 1))
+#define	LHUP(x)		((u_int)(x) << (u_int)HALF_BITS)
 
 /*
  * XXX

Index: src/common/lib/libc/stdlib/_strtol.h
diff -u src/common/lib/libc/stdlib/_strtol.h:1.2 src/common/lib/libc/stdlib/_strtol.h:1.3
--- src/common/lib/libc/stdlib/_strtol.h:1.2	Wed May 20 18:03:29 2009
+++ src/common/lib/libc/stdlib/_strtol.h	Fri Mar  9 10:41:16 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtol.h,v 1.2 2009/05/20 22:03:29 christos Exp $ */
+/* $NetBSD: _strtol.h,v 1.3 2012/03/09 15:41:16 christos Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -109,7 +109,7 @@ _FUNCNAME(const char *nptr, char **endpt
 	 * Set any if any `digits' consumed; make it negative to indicate
 	 * overflow.
 	 */
-	cutoff = (neg ? __INT_MIN : __INT_MAX);
+	cutoff = (__INT)(neg ? __INT_MIN : __INT_MAX);
 	cutlim = (int)(cutoff % base);
 	cutoff /= base;
 	if (neg) {

Index: src/common/lib/libc/stdlib/_strtoul.h
diff -u src/common/lib/libc/stdlib/_strtoul.h:1.1 src/common/lib/libc/stdlib/_strtoul.h:1.2
--- src/common/lib/libc/stdlib/_strtoul.h:1.1	Wed Aug 20 08:42:26 2008
+++ src/common/lib/libc/stdlib/_strtoul.h	Fri Mar  9 10:41:16 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoul.h,v 1.1 2008/08/20 12:42:26 joerg Exp $ */
+/* $NetBSD: _strtoul.h,v 1.2 2012/03/09 15:41:16 christos Exp $ */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -91,7 +91,7 @@ _FUNCNAME(const char *nptr, char **endpt
 	/*
 	 * See strtol for comments as to the logic used.
 	 */
-	cutoff = __UINT_MAX / (__UINT)base;
+	cutoff = (__UINT)(__UINT_MAX / (__UINT)base);
 	cutlim = (int)(__UINT_MAX % (__UINT)base);
 	for (acc = 0, any = 0;; c = *s++) {
 		if (isdigit(c))

Index: src/common/lib/libc/string/bcmp.c
diff -u src/common/lib/libc/string/bcmp.c:1.6 src/common/lib/libc/string/bcmp.c:1.7
--- src/common/lib/libc/string/bcmp.c:1.6	Sat Apr 25 08:20:48 2009
+++ src/common/lib/libc/string/bcmp.c	Fri Mar  9 10:41:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: bcmp.c,v 1.6 2009/04/25 12:20:48 skrll Exp $	*/
+/*	$NetBSD: bcmp.c,v 1.7 2012/03/09 15:41:16 christos Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)bcmp.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: bcmp.c,v 1.6 2009/04/25 12:20:48 skrll Exp $");
+__RCSID("$NetBSD: bcmp.c,v 1.7 2012/03/09 15:41:16 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -66,5 +66,5 @@ bcmp(const void *b1, const void *b2, siz
 		if (*p1++ != *p2++)
 			break;
 	while (--length);
-	return(length);
+	return length != 0;
 }
Index: src/common/lib/libc/string/popcount64.c
diff -u src/common/lib/libc/string/popcount64.c:1.6 src/common/lib/libc/string/popcount64.c:1.7
--- src/common/lib/libc/string/popcount64.c:1.6	Sun Aug 21 17:25:04 2011
+++ src/common/lib/libc/string/popcount64.c	Fri Mar  9 10:41:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: popcount64.c,v 1.6 2011/08/21 21:25:04 dholland Exp $	*/
+/*	$NetBSD: popcount64.c,v 1.7 2012/03/09 15:41:16 christos Exp $	*/
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: popcount64.c,v 1.6 2011/08/21 21:25:04 dholland Exp $");
+__RCSID("$NetBSD: popcount64.c,v 1.7 2012/03/09 15:41:16 christos Exp $");
 
 #if !defined(_KERNEL) && !defined(_STANDALONE)
 #include <limits.h>
@@ -64,10 +64,12 @@ popcount64(uint64_t v)
 {
 	unsigned int c;
 
-	v = v - ((v >> 1) & 0x5555555555555555ULL);
-	v = (v & 0x3333333333333333ULL) + ((v >> 2) & 0x3333333333333333ULL);
-	v = ((v + (v >> 4)) & 0x0f0f0f0f0f0f0f0fULL) * 0x0101010101010101ULL;
-	c = v >> 56;
+	v = v - ((v >> 1) & (uint64_t)0x5555555555555555ULL);
+	v = (v & (uint64_t)0x3333333333333333ULL) +
+	    ((v >> 2) & (uint64_t)0x3333333333333333ULL);
+	v = ((v + (v >> 4)) & (uint64_t)0x0f0f0f0f0f0f0f0fULL) *
+	    (uint64_t)0x0101010101010101ULL;
+	c = (unsigned int)(v >> 56);
 
 	return c;
 }

Index: src/common/lib/libc/sys/cpuset.c
diff -u src/common/lib/libc/sys/cpuset.c:1.17 src/common/lib/libc/sys/cpuset.c:1.18
--- src/common/lib/libc/sys/cpuset.c:1.17	Sun Aug  7 09:33:02 2011
+++ src/common/lib/libc/sys/cpuset.c	Fri Mar  9 10:41:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpuset.c,v 1.17 2011/08/07 13:33:02 rmind Exp $	*/
+/*	$NetBSD: cpuset.c,v 1.18 2012/03/09 15:41:16 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #ifndef _STANDALONE
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: cpuset.c,v 1.17 2011/08/07 13:33:02 rmind Exp $");
+__RCSID("$NetBSD: cpuset.c,v 1.18 2012/03/09 15:41:16 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -93,7 +93,7 @@ _cpuset_isset(cpuid_t i, const cpuset_t 
 		errno = EINVAL;
 		return -1;
 	}
-	return ((1 << (i & CPUSET_MASK)) & c->bits[j]) != 0;
+	return ((1 << (unsigned int)(i & CPUSET_MASK)) & c->bits[j]) != 0;
 }
 
 int
@@ -105,7 +105,7 @@ _cpuset_set(cpuid_t i, cpuset_t *c)
 		errno = EINVAL;
 		return -1;
 	}
-	c->bits[j] |= 1 << (i & CPUSET_MASK);
+	c->bits[j] |= 1 << (unsigned int)(i & CPUSET_MASK);
 	return 0;
 }
 
@@ -118,7 +118,7 @@ _cpuset_clr(cpuid_t i, cpuset_t *c)
 		errno = EINVAL;
 		return -1;
 	}
-	c->bits[j] &= ~(1 << (i & CPUSET_MASK));
+	c->bits[j] &= ~(1 << (unsigned int)(i & CPUSET_MASK));
 	return 0;
 }
 
@@ -132,7 +132,8 @@ _cpuset_create(void)
 		u_int nc;
 
 		len = sizeof(nc);
-		if (sysctl(mib, __arraycount(mib), &nc, &len, NULL, 0) == -1)
+		if (sysctl(mib, (unsigned int)__arraycount(mib), &nc, &len,
+		    NULL, 0) == -1)
 			return NULL;
 
 		cpuset_nentries = CPUSET_NENTRIES(nc);

Reply via email to