Source-Changes-HG archive

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

[src/trunk]: src/sys/lib/libsa fix warnings, printf formats, etc.



details:   https://anonhg.NetBSD.org/src/rev/3fc6917a86ae
branches:  trunk
changeset: 840298:3fc6917a86ae
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Mar 31 20:08:45 2019 +0000

description:
fix warnings, printf formats, etc.

diffstat:

 sys/lib/libsa/Makefile      |    7 ++-
 sys/lib/libsa/alloc.c       |   10 +-
 sys/lib/libsa/arp.c         |   34 +++++-----
 sys/lib/libsa/atoi.c        |    4 +-
 sys/lib/libsa/bootcfg.c     |    9 +-
 sys/lib/libsa/bootcfg.h     |    5 +-
 sys/lib/libsa/bootp.c       |   37 +++++------
 sys/lib/libsa/bootp.h       |    4 +-
 sys/lib/libsa/bootparam.c   |  132 ++++++++++++++++++++++---------------------
 sys/lib/libsa/cd9660.c      |   23 ++++---
 sys/lib/libsa/checkpasswd.c |    6 +-
 sys/lib/libsa/dev_net.c     |    6 +-
 sys/lib/libsa/dosfs.c       |   20 +++---
 sys/lib/libsa/ether.c       |   12 ++--
 sys/lib/libsa/ext2fs.c      |   23 ++++---
 sys/lib/libsa/gets.c        |    4 +-
 sys/lib/libsa/ip.c          |    6 +-
 sys/lib/libsa/loadfile.c    |    4 +-
 sys/lib/libsa/minixfs3.c    |   10 ++-
 sys/lib/libsa/net.c         |    7 +-
 sys/lib/libsa/net.h         |    4 +-
 sys/lib/libsa/netif.c       |   36 ++++++------
 sys/lib/libsa/nfs.c         |   29 ++++-----
 sys/lib/libsa/qsort.c       |    8 +-
 sys/lib/libsa/rarp.c        |   16 ++--
 sys/lib/libsa/rpc.c         |   25 ++++----
 sys/lib/libsa/tftp.c        |   19 +++---
 sys/lib/libsa/udp.c         |   14 ++--
 sys/lib/libsa/ufs.c         |   10 +-
 29 files changed, 271 insertions(+), 253 deletions(-)

diffs (truncated from 1840 to 300 lines):

diff -r 68eda7afb56f -r 3fc6917a86ae sys/lib/libsa/Makefile
--- a/sys/lib/libsa/Makefile    Sun Mar 31 19:54:36 2019 +0000
+++ b/sys/lib/libsa/Makefile    Sun Mar 31 20:08:45 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.88 2018/06/05 00:57:47 christos Exp $
+#      $NetBSD: Makefile,v 1.89 2019/03/31 20:08:45 christos Exp $
 
 LIB=   sa
 LIBISPRIVATE?= yes
@@ -14,6 +14,11 @@
 
 #COPTS+= -ansi -pedantic -Wall
 
+# For testing
+# WARNS=5
+# COPTS+=-ffreestanding
+# CPPFLAGS+= -I${.CURDIR}/../../ -I${.CURDIR}
+
 .if defined(SA_EXTRADIR)
 .-include "${SA_EXTRADIR}/Makefile.inc"
 .endif
diff -r 68eda7afb56f -r 3fc6917a86ae sys/lib/libsa/alloc.c
--- a/sys/lib/libsa/alloc.c     Sun Mar 31 19:54:36 2019 +0000
+++ b/sys/lib/libsa/alloc.c     Sun Mar 31 20:08:45 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: alloc.c,v 1.27 2016/06/05 13:44:48 maxv Exp $  */
+/*     $NetBSD: alloc.c,v 1.28 2019/03/31 20:08:45 christos Exp $      */
 
 /*
  * Copyright (c) 1993
@@ -224,16 +224,16 @@
            ALIGN(sizeof(unsigned int)));
 #ifdef DEBUG
        if (size > (size_t)f->size) {
-               printf("dealloc %zu bytes @%lx, should be <=%u\n",
-                       size, (u_long)ptr, f->size);
+               printf("%s: %zu bytes @%p, should be <=%u\n", __func__,
+                       size, ptr, f->size);
        }
 
        if (ptr < (void *)HEAP_START)
-               printf("dealloc: %lx before start of heap.\n", (u_long)ptr);
+               printf("%s: %p before start of heap.\n", __func__, ptr);
 
 #ifdef HEAP_LIMIT
        if (ptr > (void *)HEAP_LIMIT)
-               printf("dealloc: %lx beyond end of heap.\n", (u_long)ptr);
+               printf("%s: %p beyond end of heap.\n", __func__, ptr);
 #endif
 #endif /* DEBUG */
        /* put into freelist */
diff -r 68eda7afb56f -r 3fc6917a86ae sys/lib/libsa/arp.c
--- a/sys/lib/libsa/arp.c       Sun Mar 31 19:54:36 2019 +0000
+++ b/sys/lib/libsa/arp.c       Sun Mar 31 20:08:45 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arp.c,v 1.34 2014/03/29 14:25:10 jakllsch Exp $        */
+/*     $NetBSD: arp.c,v 1.35 2019/03/31 20:08:45 christos Exp $        */
 
 /*
  * Copyright (c) 1992 Regents of the University of California.
@@ -50,6 +50,7 @@
 #ifdef _STANDALONE
 #include <lib/libkern/libkern.h>
 #else
+#include <arpa/inet.h>
 #include <string.h>
 #endif
 
@@ -97,6 +98,7 @@
 arpwhohas(struct iodesc *d, struct in_addr addr)
 {
        int i;
+       ssize_t ns;
        struct ether_arp *ah;
        struct arp_list *al;
        struct {
@@ -122,12 +124,12 @@
        /* Don't overflow cache */
        if (arp_num > ARP_NUM - 1) {
                arp_num = 1;    /* recycle */
-               printf("arpwhohas: overflowed arp_list!\n");
+               printf("%s: overflowed arp_list!\n", __func__);
        }
 
 #ifdef ARP_DEBUG
        if (debug)
-               printf("arpwhohas: send request for %s\n", inet_ntoa(addr));
+               printf("%s: send request for %s\n", __func__, inet_ntoa(addr));
 #endif
 
        (void)memset(&wbuf.data, 0, sizeof(wbuf.data));
@@ -145,21 +147,20 @@
        /* Store ip address in cache (incomplete entry). */
        al->addr = addr;
 
-       i = sendrecv(d,
+       ns = sendrecv(d,
            arpsend, &wbuf.data, sizeof(wbuf.data),
            arprecv, &rbuf.data, sizeof(rbuf.data));
-       if (i == -1) {
-               panic("arp: no response for %s",
-                         inet_ntoa(addr));
+       if (ns == -1) {
+               panic("%s: no response for %s", __func__, inet_ntoa(addr));
        }
 
        /* Store ethernet address in cache */
        ah = &rbuf.data.arp;
 #ifdef ARP_DEBUG
        if (debug) {
-               printf("arp: response from %s\n",
+               printf("%s: response from %s\n", __func__,
                    ether_sprintf(rbuf.eh.ether_shost));
-               printf("arp: cacheing %s --> %s\n",
+               printf("%s: cacheing %s --> %s\n", __func__,
                    inet_ntoa(addr), ether_sprintf(ah->arp_sha));
        }
 #endif
@@ -175,7 +176,7 @@
 
 #ifdef ARP_DEBUG
        if (debug)
-               printf("arpsend: called\n");
+               printf("%s: called\n", __func__);
 #endif
 
        return sendether(d, pkt, len, bcea, ETHERTYPE_ARP);
@@ -193,16 +194,15 @@
        u_int16_t etype;        /* host order */
 
 #ifdef ARP_DEBUG
-       if (debug)
-               printf("arprecv: ");
+       if (debug)
+               printf("%s: ", __func__);
 #endif
-
        n = readether(d, pkt, len, tleft, &etype);
        errno = 0;      /* XXX */
        if (n == -1 || (size_t)n < sizeof(struct ether_arp)) {
 #ifdef ARP_DEBUG
                if (debug)
-                       printf("bad len=%ld\n", (signed long) n);
+                       printf("bad len=%zd\n", n);
 #endif
                return -1;
        }
@@ -283,7 +283,7 @@
        {
 #ifdef ARP_DEBUG
                if (debug)
-                       printf("arp_reply: bad hrd/pro/hln/pln\n");
+                       printf("%s: bad hrd/pro/hln/pln\n", __func__);
 #endif
                return;
        }
@@ -291,7 +291,7 @@
        if (arp->arp_op != htons(ARPOP_REQUEST)) {
 #ifdef ARP_DEBUG
                if (debug)
-                       printf("arp_reply: not request!\n");
+                       printf("%s: not request!\n", __func__);
 #endif
                return;
        }
@@ -302,7 +302,7 @@
 
 #ifdef ARP_DEBUG
        if (debug) {
-               printf("arp_reply: to %s\n", ether_sprintf(arp->arp_sha));
+               printf("%s: to %s\n", __func__, ether_sprintf(arp->arp_sha));
        }
 #endif
 
diff -r 68eda7afb56f -r 3fc6917a86ae sys/lib/libsa/atoi.c
--- a/sys/lib/libsa/atoi.c      Sun Mar 31 19:54:36 2019 +0000
+++ b/sys/lib/libsa/atoi.c      Sun Mar 31 20:08:45 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: atoi.c,v 1.1 2014/08/10 07:40:49 isaki Exp $   */
+/*     $NetBSD: atoi.c,v 1.2 2019/03/31 20:08:45 christos Exp $        */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
        int ret;
 
        ret = 0;
-       c = (char *)in;
+       c = __UNCONST(in);
        if (*c == '-')
                c++;
        for (; isdigit(*c); c++)
diff -r 68eda7afb56f -r 3fc6917a86ae sys/lib/libsa/bootcfg.c
--- a/sys/lib/libsa/bootcfg.c   Sun Mar 31 19:54:36 2019 +0000
+++ b/sys/lib/libsa/bootcfg.c   Sun Mar 31 20:08:45 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootcfg.c,v 1.3 2018/04/02 09:44:19 nonaka Exp $       */
+/*     $NetBSD: bootcfg.c,v 1.4 2019/03/31 20:08:45 christos Exp $     */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -98,8 +98,9 @@
 perform_bootcfg(const char *conf, bootcfg_command command, const off_t maxsz)
 {
        char *bc, *c;
-       int cmenu, cbanner, len;
-       int fd, err, off;
+       int cmenu, cbanner;
+       ssize_t len, off;
+       int fd, err;
        struct stat st;
        char *next, *key, *value, *v2;
 
@@ -128,7 +129,7 @@
                return EFBIG;
        }
 
-       bc = alloc(st.st_size + 1);
+       bc = alloc((size_t)st.st_size + 1);
        if (bc == NULL) {
                printf("Could not allocate memory for boot configuration\n");
                close(fd);
diff -r 68eda7afb56f -r 3fc6917a86ae sys/lib/libsa/bootcfg.h
--- a/sys/lib/libsa/bootcfg.h   Sun Mar 31 19:54:36 2019 +0000
+++ b/sys/lib/libsa/bootcfg.h   Sun Mar 31 20:08:45 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootcfg.h,v 1.2 2018/04/02 09:44:19 nonaka Exp $       */
+/*     $NetBSD: bootcfg.h,v 1.3 2019/03/31 20:08:45 christos Exp $     */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -48,7 +48,8 @@
        int timeout;                            /* Timeout in seconds */
        int menuformat;                         /* Letters instead of numbers */
        int clear;                              /* Clear the screen? */
-} extern bootcfg_info;
+};
+extern struct bootcfg_def bootcfg_info;
 
 int perform_bootcfg(const char *, bootcfg_command, const off_t);
 void bootcfg_do_noop(const char *, char *);
diff -r 68eda7afb56f -r 3fc6917a86ae sys/lib/libsa/bootp.c
--- a/sys/lib/libsa/bootp.c     Sun Mar 31 19:54:36 2019 +0000
+++ b/sys/lib/libsa/bootp.c     Sun Mar 31 20:08:45 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootp.c,v 1.41 2016/06/25 04:53:32 isaki Exp $ */
+/*     $NetBSD: bootp.c,v 1.42 2019/03/31 20:08:45 christos Exp $      */
 
 /*
  * Copyright (c) 1992 Regents of the University of California.
@@ -134,18 +134,18 @@
 
 #ifdef BOOTP_DEBUG
        if (debug)
-               printf("bootp: socket=%d\n", sock);
+               printf("%s: socket=%d\n", __func__, sock);
 #endif
        if (!bot)
                bot = getsecs();
 
        if (!(d = socktodesc(sock))) {
-               printf("bootp: bad socket. %d\n", sock);
+               printf("%s: bad socket. %d\n", __func__, sock);
                return;
        }
 #ifdef BOOTP_DEBUG
        if (debug)
-               printf("bootp: d=%lx\n", (long)d);
+               printf("%s: d=%p\n", __func__, d);
 #endif
 
        bp = &wbuf.wbootp;
@@ -176,11 +176,9 @@
        dhcp_ok = 0;
 #endif
 
-       if (sendrecv(d,
-                   bootpsend, bp, sizeof(*bp),
-                   bootprecv, &rbuf.rbootp, sizeof(rbuf.rbootp))
-          == -1) {
-               printf("bootp: no reply\n");
+       if (sendrecv(d, bootpsend, bp, sizeof(*bp),
+           bootprecv, &rbuf.rbootp, sizeof(rbuf.rbootp)) == -1) {
+               printf("%s: no reply\n", __func__);
                return;
        }
 
@@ -287,7 +285,7 @@
 
 #ifdef BOOTP_DEBUG
        if (debug)
-               printf("bootpsend: d=%lx called.\n", (long)d);
+               printf("%s: d=%p called.\n", __func__, d);
 #endif
 
        bp = pkt;
@@ -295,7 +293,7 @@
 
 #ifdef BOOTP_DEBUG
        if (debug)



Home | Main Index | Thread Index | Old Index