Source-Changes-HG archive

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

[src/trunk]: src/sys kill sprintf



details:   https://anonhg.NetBSD.org/src/rev/1b1d32169d96
branches:  trunk
changeset: 327908:1b1d32169d96
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Mar 20 20:42:08 2014 +0000

description:
kill sprintf

diffstat:

 sys/external/bsd/ipf/netinet/fil.c           |  25 +++------
 sys/external/bsd/ipf/netinet/ip_compat.h     |   5 +-
 sys/external/bsd/ipf/netinet/ip_fil_compat.c |  14 ++---
 sys/external/bsd/ipf/netinet/ip_ftp_pxy.c    |  69 ++++-----------------------
 sys/external/bsd/ipf/netinet/ip_htable.c     |  10 +--
 sys/external/bsd/ipf/netinet/ip_irc_pxy.c    |  11 +---
 sys/external/bsd/ipf/netinet/ip_lookup.c     |  10 +--
 sys/external/bsd/ipf/netinet/ip_pool.c       |  16 +----
 sys/external/bsd/ipf/netinet/ip_rpcb_pxy.c   |  29 ++---------
 sys/external/bsd/ipf/netinet/radix_ipf.c     |  10 ++--
 sys/lib/libsa/bootp.c                        |   4 +-
 sys/rump/dev/lib/libugenhc/ugenhc.c          |  14 ++--
 sys/rump/librump/rumpkern/rump.c             |   7 +-
 sys/rump/librump/rumpvfs/devnodes.c          |  22 ++++----
 sys/rump/net/lib/libshmif/if_shmem.c         |   6 +-
 sys/rump/net/lib/libvirtif/if_virt.c         |   6 +-
 16 files changed, 80 insertions(+), 178 deletions(-)

diffs (truncated from 748 to 300 lines):

diff -r 4593fc505208 -r 1b1d32169d96 sys/external/bsd/ipf/netinet/fil.c
--- a/sys/external/bsd/ipf/netinet/fil.c        Thu Mar 20 20:41:11 2014 +0000
+++ b/sys/external/bsd/ipf/netinet/fil.c        Thu Mar 20 20:42:08 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fil.c,v 1.13 2013/11/27 22:18:06 christos Exp $        */
+/*     $NetBSD: fil.c,v 1.14 2014/03/20 20:43:12 christos Exp $        */
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -138,7 +138,7 @@
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.13 2013/11/27 22:18:06 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fil.c,v 1.14 2014/03/20 20:43:12 christos Exp $");
 #else
 static const char sccsid[] = "@(#)fil.c        1.36 6/5/96 (C) 1993-2000 Darren Reed";
 static const char rcsid[] = "@(#)Id: fil.c,v 1.1.1.2 2012/07/22 13:45:07 darrenr Exp $";
@@ -4196,14 +4196,14 @@
        fiop->f_features = ipf_features;
 
 #ifdef IPFILTER_COMPAT
-       sprintf(fiop->f_version, "IP Filter: v%d.%d.%d",
-               (rev / 1000000) % 100,
-               (rev / 10000) % 100,
-               (rev / 100) % 100);
+       snprintf(fiop->f_version, sizeof(fiop->f_version),
+                "IP Filter: v%d.%d.%d", (rev / 1000000) % 100,
+                (rev / 10000) % 100, (rev / 100) % 100);
 #else
        rev = rev;
        (void) strncpy(fiop->f_version, ipfilter_version,
                       sizeof(fiop->f_version));
+        fiop->f_version[sizeof(fiop->f_version) - 1] = '\0';
 #endif
 }
 
@@ -5392,11 +5392,7 @@
        char name[FR_GROUPLEN];
        iphtable_t *iph;
 
-#if defined(SNPRINTF) && defined(_KERNEL)
-       SNPRINTF(name, sizeof(name), "%d", fr->fr_arg);
-#else
-       (void) sprintf(name, "%d", fr->fr_arg);
-#endif
+       (void) snprintf(name, sizeof(name), "%d", fr->fr_arg);
        iph = ipf_lookup_find_htable(softc, IPL_LOGIPF, name);
        if (iph == NULL) {
                IPFERROR(38);
@@ -5932,12 +5928,9 @@
        unit = ifp->if_unit;
        space = LIFNAMSIZ - (s - buffer);
        if ((space > 0) && (unit >= 0)) {
-#  if defined(SNPRINTF) && defined(_KERNEL)
-               SNPRINTF(temp, sizeof(temp), "%d", unit);
-#  else
-               (void) sprintf(temp, "%d", unit);
-#  endif
+               snprintf(temp, sizeof(temp), "%d", unit);
                (void) strncpy(s, temp, space);
+               s[space - 1] = '\0';
        }
 # endif
        return buffer;
diff -r 4593fc505208 -r 1b1d32169d96 sys/external/bsd/ipf/netinet/ip_compat.h
--- a/sys/external/bsd/ipf/netinet/ip_compat.h  Thu Mar 20 20:41:11 2014 +0000
+++ b/sys/external/bsd/ipf/netinet/ip_compat.h  Thu Mar 20 20:42:08 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_compat.h,v 1.6 2013/01/09 13:23:20 christos Exp $   */
+/*     $NetBSD: ip_compat.h,v 1.7 2014/03/20 20:43:12 christos Exp $   */
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -235,7 +235,6 @@
 #  include <inet/ip_ire.h>
 # endif
 # if SOLARIS2 >= 8
-#  define SNPRINTF     snprintf
 
 #  include <inet/ip_if.h>
 #  define      ipif_local_addr ipif_lcl_addr
@@ -431,7 +430,6 @@
 
 # ifdef _KERNEL
 #  define      FASTROUTE_RECURSION     1
-#  define SNPRINTF     sprintf
 #  if (HPUXREV >= 1111)
 #   define     IPL_SELECT
 #   ifdef      IPL_SELECT
@@ -1173,7 +1171,6 @@
 #   include "bpfilter.h"
 #  endif
 #  if (OpenBSD >= 200311)
-#   define SNPRINTF    snprintf
 #   if defined(USE_INET6)
 #    include "netinet6/in6_var.h"
 #    include "netinet6/nd6.h"
diff -r 4593fc505208 -r 1b1d32169d96 sys/external/bsd/ipf/netinet/ip_fil_compat.c
--- a/sys/external/bsd/ipf/netinet/ip_fil_compat.c      Thu Mar 20 20:41:11 2014 +0000
+++ b/sys/external/bsd/ipf/netinet/ip_fil_compat.c      Thu Mar 20 20:42:08 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_fil_compat.c,v 1.3 2012/07/22 14:27:51 darrenr Exp $        */
+/*     $NetBSD: ip_fil_compat.c,v 1.4 2014/03/20 20:43:12 christos Exp $       */
 
 /*
  * Copyright (C) 2002-2012 by Darren Reed.
@@ -3526,10 +3526,8 @@
        old->f_running = fiop->f_running;
        old->f_logging = fiop->f_logging;
        old->f_features = fiop->f_features;
-       sprintf(old->f_version, "IP Filter: v%d.%d.%d",
-               (rev / 1000000) % 100,
-               (rev / 10000) % 100,
-               (rev / 100) % 100);
+       snprintf(old->f_version, sizeof(old->f_version), "IP Filter: v%d.%d.%d",
+               (rev / 1000000) % 100, (rev / 10000) % 100, (rev / 100) % 100);
 }
 
 
@@ -3589,10 +3587,8 @@
        old->f_running = fiop->f_running;
        old->f_logging = fiop->f_logging;
        old->f_features = fiop->f_features;
-       sprintf(old->f_version, "IP Filter: v%d.%d.%d",
-               (rev / 1000000) % 100,
-               (rev / 10000) % 100,
-               (rev / 100) % 100);
+       snprintf(old->f_version, sizeof(old->f_version), "IP Filter: v%d.%d.%d",
+               (rev / 1000000) % 100, (rev / 10000) % 100, (rev / 100) % 100);
 }
 
 
diff -r 4593fc505208 -r 1b1d32169d96 sys/external/bsd/ipf/netinet/ip_ftp_pxy.c
--- a/sys/external/bsd/ipf/netinet/ip_ftp_pxy.c Thu Mar 20 20:41:11 2014 +0000
+++ b/sys/external/bsd/ipf/netinet/ip_ftp_pxy.c Thu Mar 20 20:42:08 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_ftp_pxy.c,v 1.4 2012/07/30 19:27:46 pgoyette Exp $  */
+/*     $NetBSD: ip_ftp_pxy.c,v 1.5 2014/03/20 20:43:12 christos Exp $  */
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -12,7 +12,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: ip_ftp_pxy.c,v 1.4 2012/07/30 19:27:46 pgoyette Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ip_ftp_pxy.c,v 1.5 2014/03/20 20:43:12 christos Exp $");
 
 #define        IPF_FTP_PROXY
 
@@ -391,14 +391,8 @@
        a4 = a1 & 0xff;
        a1 >>= 24;
        olen = s - f->ftps_rptr;
-       /* DO NOT change this to snprintf! */
-#if defined(SNPRINTF) && defined(_KERNEL)
-       SNPRINTF(newbuf, sizeof(newbuf), "%s %u,%u,%u,%u,%u,%u\r\n",
+       snprintf(newbuf, sizeof(newbuf), "%s %u,%u,%u,%u,%u,%u\r\n",
                 "PORT", a1, a2, a3, a4, a5, a6);
-#else
-       (void) sprintf(newbuf, "%s %u,%u,%u,%u,%u,%u\r\n",
-                      "PORT", a1, a2, a3, a4, a5, a6);
-#endif
 
        nlen = strlen(newbuf);
        inc = nlen - olen;
@@ -806,15 +800,9 @@
        a4 = a1 & 0xff;
        a1 >>= 24;
 
-#if defined(SNPRINTF) && defined(_KERNEL)
-       SNPRINTF(newbuf, sizeof(newbuf), "%s %s%u,%u,%u,%u,%u,%u%s\r\n",
+       snprintf(newbuf, sizeof(newbuf), "%s %s%u,%u,%u,%u,%u,%u%s\r\n",
                "227 Entering Passive Mode", brackets[0], a1, a2, a3, a4,
                a5, a6, brackets[1]);
-#else
-       (void) sprintf(newbuf, "%s %s%u,%u,%u,%u,%u,%u%s\r\n",
-               "227 Entering Passive Mode", brackets[0], a1, a2, a3, a4,
-               a5, a6, brackets[1]);
-#endif
        return ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (a5 << 8 | a6),
                                   newbuf, s);
 }
@@ -1781,20 +1769,13 @@
        a4 = a1 & 0xff;
        a1 >>= 24;
        olen = s - f->ftps_rptr;
-       /* DO NOT change this to snprintf! */
        /*
         * While we could force the use of | as a delimiter here, it makes
         * sense to preserve whatever character is being used by the systems
         * involved in the communication.
         */
-#if defined(SNPRINTF) && defined(_KERNEL)
-       SNPRINTF(newbuf, sizeof(newbuf), "%s %c1%c%u.%u.%u.%u%c%u%c\r\n",
+       snprintf(newbuf, sizeof(newbuf), "%s %c1%c%u.%u.%u.%u%c%u%c\r\n",
                 "EPRT", delim, delim, a1, a2, a3, a4, delim, port, delim);
-#else
-       (void) sprintf(newbuf, "%s %c1%c%u.%u.%u.%u%c%u%c\r\n",
-                      "EPRT", delim, delim, a1, a2, a3, a4, delim, port,
-                       delim);
-#endif
 
        nlen = strlen(newbuf);
        inc = nlen - olen;
@@ -1892,13 +1873,8 @@
        }
        s += 2;
 
-#if defined(SNPRINTF) && defined(_KERNEL)
-       SNPRINTF(newbuf, sizeof(newbuf), "%s (|||%u|)\r\n",
+       snprintf(newbuf, sizeof(newbuf), "%s (|||%u|)\r\n",
                 "229 Entering Extended Passive Mode", ap);
-#else
-       (void) sprintf(newbuf, "%s (|||%u|)\r\n",
-                      "229 Entering Extended Passive Mode", ap);
-#endif
 
        return ipf_p_ftp_pasvreply(softf, fin, ip, nat, ftp, (u_int)ap,
                                   newbuf, s);
@@ -2038,47 +2014,26 @@
         */
        s = newbuf;
        left = sizeof(newbuf);
-#if defined(SNPRINTF) && defined(_KERNEL)
-       SNPRINTF(newbuf, left, "EPRT %c2%c", delim, delim);
+       snprintf(newbuf, left, "EPRT %c2%c", delim, delim);
        left -= strlen(s) + 1;
        s += strlen(s);
        a = ntohl(a6->i6[0]);
-       SNPRINTF(s, left, "%x:%x:", a >> 16, a & 0xffff);
+       snprintf(s, left, "%x:%x:", a >> 16, a & 0xffff);
        left -= strlen(s);
        s += strlen(s);
        a = ntohl(a6->i6[1]);
-       SNPRINTF(s, left, "%x:%x:", a >> 16, a & 0xffff);
+       snprintf(s, left, "%x:%x:", a >> 16, a & 0xffff);
        left -= strlen(s);
        s += strlen(s);
        a = ntohl(a6->i6[2]);
-       SNPRINTF(s, left, "%x:%x:", a >> 16, a & 0xffff);
+       snprintf(s, left, "%x:%x:", a >> 16, a & 0xffff);
        left -= strlen(s);
        s += strlen(s);
        a = ntohl(a6->i6[3]);
-       SNPRINTF(s, left, "%x:%x", a >> 16, a & 0xffff);
+       snprintf(s, left, "%x:%x", a >> 16, a & 0xffff);
        left -= strlen(s);
        s += strlen(s);
-       sprintf(s, "|%d|\r\n", port);
-#else
-       (void) sprintf(s, "EPRT %c2%c", delim, delim);
-       s += strlen(s);
-       a = ntohl(a6->i6[0]);
-       sprintf(s, "%x:%x:", a >> 16, a & 0xffff);
-       s += strlen(s);
-       a = ntohl(a6->i6[1]);
-       sprintf(s, "%x:%x:", a >> 16, a & 0xffff);
-       left -= strlen(s);
-       s += strlen(s);
-       a = ntohl(a6->i6[2]);
-       sprintf(s, "%x:%x:", a >> 16, a & 0xffff);
-       left -= strlen(s);
-       s += strlen(s);
-       a = ntohl(a6->i6[3]);
-       sprintf(s, "%x:%x", a >> 16, a & 0xffff);
-       left -= strlen(s);
-       s += strlen(s);
-       sprintf(s, "|%d|\r\n", port);
-#endif
+       snprintf(s, left, "|%d|\r\n", port);
        nlen = strlen(newbuf);
        inc = nlen - olen;
        if ((inc + fin->fin_plen) > 65535) {
diff -r 4593fc505208 -r 1b1d32169d96 sys/external/bsd/ipf/netinet/ip_htable.c
--- a/sys/external/bsd/ipf/netinet/ip_htable.c  Thu Mar 20 20:41:11 2014 +0000
+++ b/sys/external/bsd/ipf/netinet/ip_htable.c  Thu Mar 20 20:42:08 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_htable.c,v 1.5 2014/02/27 01:30:18 joerg Exp $      */
+/*     $NetBSD: ip_htable.c,v 1.6 2014/03/20 20:43:12 christos Exp $   */
 
 /*
  * Copyright (C) 2012 by Darren Reed.
@@ -60,7 +60,7 @@
 #if !defined(lint)
 #if defined(__NetBSD__)
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_htable.c,v 1.5 2014/02/27 01:30:18 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_htable.c,v 1.6 2014/03/20 20:43:12 christos Exp $");
 #else
 static const char rcsid[] = "@(#)Id: ip_htable.c,v 1.1.1.2 2012/07/22 13:45:19 darrenr Exp";
 #endif
@@ -326,11 +326,7 @@
                i = IPHASH_ANON;
                do {
                        i++;
-#if defined(SNPRINTF) && defined(_KERNEL)
-                       SNPRINTF(name, sizeof(name), "%u", i);
-#else



Home | Main Index | Thread Index | Old Index