Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc Fix signed/unsigned comparison warnings.



details:   https://anonhg.NetBSD.org/src/rev/fe58498bb9cb
branches:  trunk
changeset: 539224:fe58498bb9cb
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Mon Nov 11 17:56:11 2002 +0000

description:
Fix signed/unsigned comparison warnings.

diffstat:

 lib/libc/gen/humanize_number.c |  12 +++++++-----
 lib/libc/net/hesiod.c          |   6 +++---
 lib/libc/net/inet_net_ntop.c   |  12 ++++++------
 lib/libc/net/inet_neta.c       |   6 +++---
 lib/libc/net/inet_ntop.c       |   6 +++---
 lib/libc/net/inet_pton.c       |   8 ++++----
 lib/libc/net/linkaddr.c        |   6 +++---
 lib/libc/stdlib/malloc.c       |   4 ++--
 8 files changed, 31 insertions(+), 29 deletions(-)

diffs (256 lines):

diff -r 841e11c9be73 -r fe58498bb9cb lib/libc/gen/humanize_number.c
--- a/lib/libc/gen/humanize_number.c    Mon Nov 11 17:26:19 2002 +0000
+++ b/lib/libc/gen/humanize_number.c    Mon Nov 11 17:56:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: humanize_number.c,v 1.3 2002/09/27 18:37:45 drochner Exp $     */
+/*     $NetBSD: humanize_number.c,v 1.4 2002/11/11 18:00:43 thorpej Exp $      */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 #ifndef __lint
 __COPYRIGHT("@(#) Copyright (c) 2002\n\
        The NetBSD Foundation, inc. All rights reserved.\n");
-__RCSID("$NetBSD: humanize_number.c,v 1.3 2002/09/27 18:37:45 drochner Exp $");
+__RCSID("$NetBSD: humanize_number.c,v 1.4 2002/11/11 18:00:43 thorpej Exp $");
 #endif /* !__lint */
 
 #include <assert.h>
@@ -62,6 +62,7 @@
 
        _DIAGASSERT(buf != NULL);
        _DIAGASSERT(suffix != NULL);
+       _DIAGASSERT(scale >= 0);
 
        if (flags & HN_DIVISOR_1000) {
                /* SI for decimal multiplies */
@@ -76,7 +77,7 @@
                prefixes = " KMGTPE";
        }
 
-       if (scale >= strlen(prefixes) && scale != HN_AUTOSCALE &&
+       if ((size_t) scale >= strlen(prefixes) && scale != HN_AUTOSCALE &&
            scale != HN_GETSCALE)
                return (-1);
 
@@ -107,8 +108,9 @@
                divisor = 1024;
 
        max = 100;
-       for (i = 0; i < len - suffixlen - baselen + ((flags & HN_NOSPACE) ?
-           1 : 0); i++)
+       for (i = 0;
+            (size_t) i < len - suffixlen - baselen + ((flags & HN_NOSPACE) ?
+            1 : 0); i++)
                max *= 10;
 
        if ((scale & HN_AUTOSCALE) || (scale & HN_GETSCALE)) {
diff -r 841e11c9be73 -r fe58498bb9cb lib/libc/net/hesiod.c
--- a/lib/libc/net/hesiod.c     Mon Nov 11 17:26:19 2002 +0000
+++ b/lib/libc/net/hesiod.c     Mon Nov 11 17:56:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hesiod.c,v 1.19 2002/08/16 11:49:57 itojun Exp $       */
+/*     $NetBSD: hesiod.c,v 1.20 2002/11/11 17:56:11 thorpej Exp $      */
 
 /* Copyright (c) 1996 by Internet Software Consortium.
  *
@@ -52,7 +52,7 @@
     "#Id: hesiod_p.h,v 1.1 1996/12/08 21:39:37 ghudson Exp #");
 __IDSTRING(rcsid_hescompat_c,
     "#Id: hescompat.c,v 1.1.2.1 1996/12/16 08:37:45 ghudson Exp #");
-__RCSID("$NetBSD: hesiod.c,v 1.19 2002/08/16 11:49:57 itojun Exp $");
+__RCSID("$NetBSD: hesiod.c,v 1.20 2002/11/11 17:56:11 thorpej Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -192,7 +192,7 @@
        struct hesiod_p *ctx = (struct hesiod_p *) context;
        char             bindname[MAXDNAME], *p, *ret, **rhs_list = NULL;
        const char      *rhs;
-       int              len;
+       size_t           len;
 
        _DIAGASSERT(context != NULL);
        _DIAGASSERT(name != NULL);
diff -r 841e11c9be73 -r fe58498bb9cb lib/libc/net/inet_net_ntop.c
--- a/lib/libc/net/inet_net_ntop.c      Mon Nov 11 17:26:19 2002 +0000
+++ b/lib/libc/net/inet_net_ntop.c      Mon Nov 11 17:56:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inet_net_ntop.c,v 1.17 2002/08/16 12:23:20 itojun Exp $        */
+/*     $NetBSD: inet_net_ntop.c,v 1.18 2002/11/11 18:02:14 thorpej Exp $       */
 
 /*
  * Copyright (c) 1996,1999 by Internet Software Consortium.
@@ -22,7 +22,7 @@
 #if 0
 static const char rcsid[] = "Id: inet_net_ntop.c,v 1.8 2001/09/27 15:08:36 marka Exp ";
 #else
-__RCSID("$NetBSD: inet_net_ntop.c,v 1.17 2002/08/16 12:23:20 itojun Exp $");
+__RCSID("$NetBSD: inet_net_ntop.c,v 1.18 2002/11/11 18:02:14 thorpej Exp $");
 #endif
 #endif
 
@@ -107,7 +107,7 @@
                return (NULL);
        }
        if (bits == 0) {
-               if (ep - dst < sizeof "0")
+               if ((size_t) (ep - dst) < sizeof "0")
                        goto emsgsize;
                *dst++ = '0';
                *dst = '\0';
@@ -115,7 +115,7 @@
 
        /* Format whole octets. */
        for (b = bits / 8; b > 0; b--) {
-               if (ep - dst <= sizeof "255.")
+               if ((size_t) (ep - dst) <= sizeof "255.")
                        goto emsgsize;
                advance = snprintf(dst, (size_t)(ep - dst), "%u", *src++);
                if (advance <= 0 || advance >= ep - dst)
@@ -132,7 +132,7 @@
        /* Format partial octet. */
        b = bits % 8;
        if (b > 0) {
-               if (ep - dst <= sizeof ".255")
+               if ((size_t) (ep - dst) <= sizeof ".255")
                        goto emsgsize;
                if (dst != odst) {
                        if (dst + 1 >= ep)
@@ -147,7 +147,7 @@
        }
 
        /* Format CIDR /width. */
-       if (ep - dst <= sizeof "/32")
+       if ((size_t) (ep - dst) <= sizeof "/32")
                goto emsgsize;
        advance = snprintf(dst, (size_t)(ep - dst), "/%u", bits);
        if (advance <= 0 || advance >= ep - dst)
diff -r 841e11c9be73 -r fe58498bb9cb lib/libc/net/inet_neta.c
--- a/lib/libc/net/inet_neta.c  Mon Nov 11 17:26:19 2002 +0000
+++ b/lib/libc/net/inet_neta.c  Mon Nov 11 17:56:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inet_neta.c,v 1.14 2002/08/16 12:10:37 itojun Exp $    */
+/*     $NetBSD: inet_neta.c,v 1.15 2002/11/11 18:02:37 thorpej Exp $   */
 
 /*
  * Copyright (c) 1996 by Internet Software Consortium.
@@ -22,7 +22,7 @@
 #if 0
 static const char rcsid[] = "Id: inet_neta.c,v 8.2 1996/08/08 06:54:44 vixie Exp ";
 #else
-__RCSID("$NetBSD: inet_neta.c,v 1.14 2002/08/16 12:10:37 itojun Exp $");
+__RCSID("$NetBSD: inet_neta.c,v 1.15 2002/11/11 18:02:37 thorpej Exp $");
 #endif
 #endif
 
@@ -78,7 +78,7 @@
 
                src <<= 8;
                if (b || src) {
-                       if (ep - dst < sizeof "255.")
+                       if ((size_t) (ep - dst) < sizeof "255.")
                                goto emsgsize;
                        advance = snprintf(dst, (size_t)(ep - dst), "%u", b);
                        if (advance <= 0 || advance >= ep - dst)
diff -r 841e11c9be73 -r fe58498bb9cb lib/libc/net/inet_ntop.c
--- a/lib/libc/net/inet_ntop.c  Mon Nov 11 17:26:19 2002 +0000
+++ b/lib/libc/net/inet_ntop.c  Mon Nov 11 17:56:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inet_ntop.c,v 1.12 2002/08/23 16:10:42 itojun Exp $    */
+/*     $NetBSD: inet_ntop.c,v 1.13 2002/11/11 18:03:10 thorpej Exp $   */
 
 /* Copyright (c) 1996 by Internet Software Consortium.
  *
@@ -21,7 +21,7 @@
 #if 0
 static char rcsid[] = "Id: inet_ntop.c,v 8.7 1996/08/05 08:41:18 vixie Exp ";
 #else
-__RCSID("$NetBSD: inet_ntop.c,v 1.12 2002/08/23 16:10:42 itojun Exp $");
+__RCSID("$NetBSD: inet_ntop.c,v 1.13 2002/11/11 18:03:10 thorpej Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -109,7 +109,7 @@
 
        l = snprintf(tmp, sizeof(tmp), "%u.%u.%u.%u",
            src[0], src[1], src[2], src[3]);
-       if (l <= 0 || l >= size) {
+       if (l <= 0 || (socklen_t) l >= size) {
                errno = ENOSPC;
                return (NULL);
        }
diff -r 841e11c9be73 -r fe58498bb9cb lib/libc/net/inet_pton.c
--- a/lib/libc/net/inet_pton.c  Mon Nov 11 17:26:19 2002 +0000
+++ b/lib/libc/net/inet_pton.c  Mon Nov 11 17:56:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inet_pton.c,v 1.16 2000/02/07 18:51:02 itojun Exp $    */
+/*     $NetBSD: inet_pton.c,v 1.17 2002/11/11 18:04:18 thorpej Exp $   */
 
 /* Copyright (c) 1996 by Internet Software Consortium.
  *
@@ -21,7 +21,7 @@
 #if 0
 static char rcsid[] = "Id: inet_pton.c,v 8.7 1996/08/05 08:31:35 vixie Exp ";
 #else
-__RCSID("$NetBSD: inet_pton.c,v 1.16 2000/02/07 18:51:02 itojun Exp $");
+__RCSID("$NetBSD: inet_pton.c,v 1.17 2002/11/11 18:04:18 thorpej Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -103,8 +103,8 @@
        int pton;
 {
        u_int32_t val;
-       u_int digit;
-       int base, n;
+       u_int digit, base;
+       int n;
        unsigned char c;
        u_int parts[4];
        register u_int *pp = parts;
diff -r 841e11c9be73 -r fe58498bb9cb lib/libc/net/linkaddr.c
--- a/lib/libc/net/linkaddr.c   Mon Nov 11 17:26:19 2002 +0000
+++ b/lib/libc/net/linkaddr.c   Mon Nov 11 17:56:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linkaddr.c,v 1.11 1999/09/20 04:39:15 lukem Exp $      */
+/*     $NetBSD: linkaddr.c,v 1.12 2002/11/11 18:07:52 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1990, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)linkaddr.c 8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: linkaddr.c,v 1.11 1999/09/20 04:39:15 lukem Exp $");
+__RCSID("$NetBSD: linkaddr.c,v 1.12 2002/11/11 18:07:52 thorpej Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -128,7 +128,7 @@
        } while (cp < cplim); 
        sdl->sdl_alen = cp - LLADDR(sdl);
        newaddr = cp - (char *)(void *)sdl;
-       if (newaddr > sizeof(*sdl))
+       if ((size_t) newaddr > sizeof(*sdl))
                sdl->sdl_len = newaddr;
        return;
 }
diff -r 841e11c9be73 -r fe58498bb9cb lib/libc/stdlib/malloc.c
--- a/lib/libc/stdlib/malloc.c  Mon Nov 11 17:26:19 2002 +0000
+++ b/lib/libc/stdlib/malloc.c  Mon Nov 11 17:56:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: malloc.c,v 1.38 2001/05/06 04:48:41 christos Exp $     */
+/*     $NetBSD: malloc.c,v 1.39 2002/11/11 18:09:29 thorpej Exp $      */
 
 /*
  * ----------------------------------------------------------------------------
@@ -134,7 +134,7 @@
  * How many bits per u_int in the bitmap.
  * Change only if not 8 bits/byte
  */
-#define        MALLOC_BITS     (8*sizeof(u_int))
+#define        MALLOC_BITS     ((int)(8*sizeof(u_int)))
 
 /*
  * Magic values to put in the page_directory



Home | Main Index | Thread Index | Old Index