Source-Changes-HG archive

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

[src/trunk]: src/sys/arch kill sprintf



details:   https://anonhg.NetBSD.org/src/rev/9a3aedf5f9bd
branches:  trunk
changeset: 328112:9a3aedf5f9bd
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 26 17:41:15 2014 +0000

description:
kill sprintf

diffstat:

 sys/arch/evbmips/loongson/loongson_intr.c |  9 +++++----
 sys/arch/evbmips/malta/pci/pcib.c         |  8 ++++----
 sys/arch/landisk/landisk/shpcic_machdep.c |  6 +++---
 sys/arch/landisk/stand/boot/boot2.c       |  5 +++--
 sys/arch/landisk/stand/boot/cons.c        |  6 +++---
 sys/arch/mac68k/mac68k/pram.c             |  7 ++++---
 sys/arch/macppc/macppc/cpu.c              |  6 +++---
 sys/arch/mips/alchemy/dev/aupci.c         |  6 +++---
 sys/arch/mips/mips/trap.c                 |  6 +++---
 sys/arch/mips/ralink/ralink_mainbus.c     |  6 +++---
 sys/arch/mvmeppc/mvmeppc/machdep.c        |  9 +++++----
 sys/arch/mvmeppc/mvmeppc/platform_160x.c  |  8 ++++----
 sys/arch/newsmips/stand/boot/boot.c       |  7 ++++---
 sys/arch/newsmips/stand/bootxx/bootxx.c   |  5 +++--
 14 files changed, 50 insertions(+), 44 deletions(-)

diffs (truncated from 388 to 300 lines):

diff -r 2947d20ccead -r 9a3aedf5f9bd sys/arch/evbmips/loongson/loongson_intr.c
--- a/sys/arch/evbmips/loongson/loongson_intr.c Wed Mar 26 17:38:09 2014 +0000
+++ b/sys/arch/evbmips/loongson/loongson_intr.c Wed Mar 26 17:41:15 2014 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: loongson_intr.c,v 1.2 2012/10/27 17:17:50 chs Exp $      */
+/*      $NetBSD: loongson_intr.c,v 1.3 2014/03/26 17:41:15 christos Exp $      */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: loongson_intr.c,v 1.2 2012/10/27 17:17:50 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: loongson_intr.c,v 1.3 2014/03/26 17:41:15 christos Exp $");
 
 #define __INTR_PRIVATE
 
@@ -126,7 +126,7 @@
                static char irqstr[8];
                for (irq = 0; irq < BONITO_NISA; irq++) {
                        i = BONITO_ISA_IRQ(irq);
-                       sprintf(irqstr, "irq %d", irq);
+                       snprintf(irqstr, sizeof(irqstr), "irq %d", irq);
                        DPRINTF(("attach %d %d %s\n", i, irq, irqstr));
                        evcnt_attach_dynamic(&bonito_intrhead[i].intr_count,
                            EVCNT_TYPE_INTR, NULL, "isa", irqstr);
@@ -334,7 +334,8 @@
 {
        static char irqstr[12]; /* 8 + 2 + NULL + sanity */
        if (BONITO_IRQ_IS_ISA(irq)) {
-               sprintf(irqstr, "isa irq %d", BONITO_IRQ_TO_ISA(irq));
+               snprintf(irqstr, sizeof(irqstr), "isa irq %d",
+                   BONITO_IRQ_TO_ISA(irq));
                return irqstr;
        }
        return sys_platform->irq_map[irq].name;
diff -r 2947d20ccead -r 9a3aedf5f9bd sys/arch/evbmips/malta/pci/pcib.c
--- a/sys/arch/evbmips/malta/pci/pcib.c Wed Mar 26 17:38:09 2014 +0000
+++ b/sys/arch/evbmips/malta/pci/pcib.c Wed Mar 26 17:41:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcib.c,v 1.16 2012/10/27 17:17:51 chs Exp $    */
+/*     $NetBSD: pcib.c,v 1.17 2014/03/26 17:41:15 christos Exp $       */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.16 2012/10/27 17:17:51 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcib.c,v 1.17 2014/03/26 17:41:15 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -306,7 +306,7 @@
 #if 0
                char irqstr[8];         /* 4 + 2 + NULL + sanity */
 
-               sprintf(irqstr, "irq %d", i);
+               snprintf(irqstr, sizeof(irqstr), "irq %d", i);
                evcnt_attach_dynamic(&sc->sc_intrtab[i].intr_count,
                    EVCNT_TYPE_INTR, NULL, "pcib", irqstr);
 #else
@@ -469,7 +469,7 @@
        if (irq == 0 || irq >= ICU_LEN || irq == 2)
                panic("pcib_isa_intr_string: bogus isa irq 0x%x", irq);
 
-       sprintf(irqstr, "isa irq %d", irq);
+       snprintf(irqstr, sizeof(irqstr), "isa irq %d", irq);
        return (irqstr);
 }
 
diff -r 2947d20ccead -r 9a3aedf5f9bd sys/arch/landisk/landisk/shpcic_machdep.c
--- a/sys/arch/landisk/landisk/shpcic_machdep.c Wed Mar 26 17:38:09 2014 +0000
+++ b/sys/arch/landisk/landisk/shpcic_machdep.c Wed Mar 26 17:41:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: shpcic_machdep.c,v 1.5 2012/10/27 17:17:58 chs Exp $   */
+/*     $NetBSD: shpcic_machdep.c,v 1.6 2014/03/26 17:47:10 christos Exp $      */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: shpcic_machdep.c,v 1.5 2012/10/27 17:17:58 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: shpcic_machdep.c,v 1.6 2014/03/26 17:47:10 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -125,7 +125,7 @@
        if (ih == 0)
                panic("pci_intr_string: bogus handle 0x%x", ih);
 
-       sprintf(irqstr, "irq %d", ih);
+       snprintf(irqstr, sizeof(irqstr), "irq %d", ih);
 
        return (irqstr);
 }
diff -r 2947d20ccead -r 9a3aedf5f9bd sys/arch/landisk/stand/boot/boot2.c
--- a/sys/arch/landisk/stand/boot/boot2.c       Wed Mar 26 17:38:09 2014 +0000
+++ b/sys/arch/landisk/stand/boot/boot2.c       Wed Mar 26 17:41:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot2.c,v 1.3 2011/12/25 06:09:09 tsutsui Exp $        */
+/*     $NetBSD: boot2.c,v 1.4 2014/03/26 17:47:10 christos Exp $       */
 
 /*
  * Copyright (c) 2003
@@ -183,7 +183,8 @@
        const char *file;
 
        if (parsebootfile(filename, &devname, &unit, &partition, &file) == 0) {
-               sprintf(buf, "%s%d%c:%s", devname, unit, 'a' + partition, file);
+               snprintf(buf, sizeof(buf), "%s%d%c:%s", devname, unit,
+                   'a' + partition, file);
                return (buf);
        }
        return ("(invalid)");
diff -r 2947d20ccead -r 9a3aedf5f9bd sys/arch/landisk/stand/boot/cons.c
--- a/sys/arch/landisk/stand/boot/cons.c        Wed Mar 26 17:38:09 2014 +0000
+++ b/sys/arch/landisk/stand/boot/cons.c        Wed Mar 26 17:41:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cons.c,v 1.1 2006/09/01 21:26:18 uwe Exp $     */
+/*     $NetBSD: cons.c,v 1.2 2014/03/26 17:47:10 christos Exp $        */
 
 /*-
  * Copyright (c) 2005 NONAKA Kimihiro
@@ -137,8 +137,8 @@
                        char numbuf[20];
                        int len, j;
 
-                       sprintf(numbuf, "%d ", i / POLL_FREQ);
-                       len = strlen(numbuf);
+                       len = snprintf(numbuf, sizeof(numbuf),
+                           "%d ", i / POLL_FREQ);
                        for (j = 0; j < len; j++)
                                numbuf[len + j] = '\b';
                        numbuf[len + j] = '\0';
diff -r 2947d20ccead -r 9a3aedf5f9bd sys/arch/mac68k/mac68k/pram.c
--- a/sys/arch/mac68k/mac68k/pram.c     Wed Mar 26 17:38:09 2014 +0000
+++ b/sys/arch/mac68k/mac68k/pram.c     Wed Mar 26 17:41:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pram.c,v 1.22 2006/06/21 00:02:26 rjs Exp $    */
+/*     $NetBSD: pram.c,v 1.23 2014/03/26 17:46:04 christos Exp $       */
 
 /*-
  * Copyright (C) 1993  Allen K. Briggs, Chris P. Caputo,
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pram.c,v 1.22 2006/06/21 00:02:26 rjs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pram.c,v 1.23 2014/03/26 17:46:04 christos Exp $");
 
 #include "opt_adb.h"
 
@@ -121,7 +121,8 @@
     t=0;
   }
 
-  sprintf(s,"%s %ld, %ld   %ld:%ld:%ld",monstr[month],day,year,hour,minute,seconds);
+  snprintf(s, sizeof(s), "%s %ld, %ld   %ld:%ld:%ld",
+      monstr[month], day, year, hour, minute, seconds);
 
   return s;
 }
diff -r 2947d20ccead -r 9a3aedf5f9bd sys/arch/macppc/macppc/cpu.c
--- a/sys/arch/macppc/macppc/cpu.c      Wed Mar 26 17:38:09 2014 +0000
+++ b/sys/arch/macppc/macppc/cpu.c      Wed Mar 26 17:41:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.59 2012/10/27 17:18:00 chs Exp $     */
+/*     $NetBSD: cpu.c,v 1.60 2014/03/26 17:45:16 christos Exp $        */
 
 /*-
  * Copyright (c) 2001 Tsubai Masanari.
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.59 2012/10/27 17:18:00 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.60 2014/03/26 17:45:16 christos Exp $");
 
 #include "opt_ppcparam.h"
 #include "opt_multiprocessor.h"
@@ -221,7 +221,7 @@
                h->hatch_running = -1;
 
                /* see if there's an OF property for the reset register */
-               sprintf(cpupath, "/cpus/@%x", ci->ci_cpuid);
+               snprintf(cpupath, sizeof(cpupath), "/cpus/@%x", ci->ci_cpuid);
                node = OF_finddevice(cpupath);
                if (node == -1) {
                        printf(": no OF node for CPU %d?\n", ci->ci_cpuid);
diff -r 2947d20ccead -r 9a3aedf5f9bd sys/arch/mips/alchemy/dev/aupci.c
--- a/sys/arch/mips/alchemy/dev/aupci.c Wed Mar 26 17:38:09 2014 +0000
+++ b/sys/arch/mips/alchemy/dev/aupci.c Wed Mar 26 17:41:15 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: aupci.c,v 1.13 2012/01/27 18:52:58 para Exp $ */
+/* $NetBSD: aupci.c,v 1.14 2014/03/26 17:42:00 christos Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -35,7 +35,7 @@
 #include "pci.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aupci.c,v 1.13 2012/01/27 18:52:58 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aupci.c,v 1.14 2014/03/26 17:42:00 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -400,7 +400,7 @@
 {
        static char     name[16];
 
-       sprintf(name, "irq %u", (unsigned)ih);
+       snprintf(name, sizeof(name), "irq %u", (unsigned)ih);
        return (name);
 }
 
diff -r 2947d20ccead -r 9a3aedf5f9bd sys/arch/mips/mips/trap.c
--- a/sys/arch/mips/mips/trap.c Wed Mar 26 17:38:09 2014 +0000
+++ b/sys/arch/mips/mips/trap.c Wed Mar 26 17:41:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: trap.c,v 1.235 2012/02/19 21:06:20 rmind Exp $ */
+/*     $NetBSD: trap.c,v 1.236 2014/03/26 17:42:00 christos Exp $      */
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.235 2012/02/19 21:06:20 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.236 2014/03/26 17:42:00 christos Exp $");
 
 #include "opt_cputype.h"       /* which mips CPU levels do we support? */
 #include "opt_ddb.h"
@@ -1192,7 +1192,7 @@
        for (i = 0; names[i].name; i++)
                if (names[i].addr == (void*)addr)
                        return (names[i].name);
-       sprintf(buf, "%#"PRIxVADDR, addr);
+       snprintf(buf, sizeof(buf), "%#"PRIxVADDR, addr);
        return (buf);
 }
 
diff -r 2947d20ccead -r 9a3aedf5f9bd sys/arch/mips/ralink/ralink_mainbus.c
--- a/sys/arch/mips/ralink/ralink_mainbus.c     Wed Mar 26 17:38:09 2014 +0000
+++ b/sys/arch/mips/ralink/ralink_mainbus.c     Wed Mar 26 17:41:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ralink_mainbus.c,v 1.2 2011/07/28 15:38:49 matt Exp $  */
+/*     $NetBSD: ralink_mainbus.c,v 1.3 2014/03/26 17:42:00 christos Exp $      */
 /*-
  * Copyright (c) 2011 CradlePoint Technology, Inc.
  * All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ralink_mainbus.c,v 1.2 2011/07/28 15:38:49 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ralink_mainbus.c,v 1.3 2014/03/26 17:42:00 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -129,7 +129,7 @@
        struct mainbus_attach_args * const ma = aux;
        char devname[16];
 
-       sprintf(devname, "%s%d", cf->cf_name, cf->cf_unit);
+       snprintf(devname, sizeof(devname), "%s%d", cf->cf_name, cf->cf_unit);
        if (strcmp(ma->ma_name, devname) != 0)
                return 0;
 
diff -r 2947d20ccead -r 9a3aedf5f9bd sys/arch/mvmeppc/mvmeppc/machdep.c
--- a/sys/arch/mvmeppc/mvmeppc/machdep.c        Wed Mar 26 17:38:09 2014 +0000
+++ b/sys/arch/mvmeppc/mvmeppc/machdep.c        Wed Mar 26 17:41:15 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.30 2012/10/13 17:58:54 jdc Exp $ */
+/*     $NetBSD: machdep.c,v 1.31 2014/03/26 17:44:36 christos Exp $    */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.30 2012/10/13 17:58:54 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.31 2014/03/26 17:44:36 christos Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_mvmetype.h"
@@ -123,7 +123,7 @@
                extern void _mvmeppc_unsup_board(const char *, const char *);
                char msg[80];
 
-               sprintf(msg, "Unsupported model: MVME%04x",
+               snprintf(msg, sizeof(msg), "Unsupported model: MVME%04x",
                    bootinfo.bi_modelnumber);



Home | Main Index | Thread Index | Old Index