Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/3b00dafa21af
branches:  trunk
changeset: 794835:3b00dafa21af
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 26 08:40:58 2014 +0000

description:
kill sprintf

diffstat:

 sys/arch/sparc64/dev/pci_machdep.c  |   6 +++---
 sys/arch/sparc64/sparc64/autoconf.c |  17 +++++++++--------
 2 files changed, 12 insertions(+), 11 deletions(-)

diffs (78 lines):

diff -r bbee2e523bb8 -r 3b00dafa21af sys/arch/sparc64/dev/pci_machdep.c
--- a/sys/arch/sparc64/dev/pci_machdep.c        Wed Mar 26 08:29:41 2014 +0000
+++ b/sys/arch/sparc64/dev/pci_machdep.c        Wed Mar 26 08:40:58 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_machdep.c,v 1.75 2012/10/27 17:18:12 chs Exp $     */
+/*     $NetBSD: pci_machdep.c,v 1.76 2014/03/26 08:40:58 christos Exp $        */
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.75 2012/10/27 17:18:12 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.76 2014/03/26 08:40:58 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -371,7 +371,7 @@
 {
        static char str[16];
 
-       sprintf(str, "ivec %x", ih);
+       snprintf(str, sizeof(str), "ivec %x", ih);
        DPRINTF(SPDB_INTR, ("pci_intr_string: returning %s\n", str));
 
        return (str);
diff -r bbee2e523bb8 -r 3b00dafa21af sys/arch/sparc64/sparc64/autoconf.c
--- a/sys/arch/sparc64/sparc64/autoconf.c       Wed Mar 26 08:29:41 2014 +0000
+++ b/sys/arch/sparc64/sparc64/autoconf.c       Wed Mar 26 08:40:58 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.193 2014/02/21 18:00:09 palle Exp $ */
+/*     $NetBSD: autoconf.c,v 1.194 2014/03/26 08:40:58 christos Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.193 2014/02/21 18:00:09 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.194 2014/03/26 08:40:58 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -512,14 +512,14 @@
 {
        char *p;
        static char sbuf[10];
+       size_t len;
 
        freq /= 1000;
-       sprintf(sbuf, "%ld", freq / 1000);
+       len = snprintf(sbuf, sizeof(sbuf), "%ld", freq / 1000);
        freq %= 1000;
        if (freq) {
                freq += 1000;   /* now in 1000..1999 */
-               p = sbuf + strlen(sbuf);
-               sprintf(p, "%ld", freq);
+               snprintf(sbuf + len, sizeof(sbuf) - len, "%ld", freq);
                *p = '.';       /* now sbuf = %d.%3d */
        }
        return (sbuf);
@@ -807,10 +807,11 @@
                 * what we realy do here is to match "target" and "lun".
                 */
                if (wwn)
-                       sprintf(buf, "%s@w%016" PRIx64 ",%d", name, wwn,
-                           lun);
+                       snprintf(buf, sizeof(buf), "%s@w%016" PRIx64 ",%d",
+                           name, wwn, lun);
                else
-                       sprintf(buf, "%s@%d,%d", name, target, lun);
+                       snprintf(buf, sizeof(buf), "%s@%d,%d",
+                           name, target, lun);
                if (ofboottarget && strcmp(buf, ofboottarget) == 0) {
                        booted_device = dev;
                        if (ofbootpartition)



Home | Main Index | Thread Index | Old Index