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/cf7534af0276
branches: trunk
changeset: 328100:cf7534af0276
user: christos <christos%NetBSD.org@localhost>
date: Wed Mar 26 15:55:43 2014 +0000
description:
kill sprintf
diffstat:
sys/arch/prep/pci/pci_machdep.c | 8 ++++----
sys/arch/prep/prep/ibm_machdep.c | 8 ++++----
sys/arch/prep/prep/platform.c | 8 ++++----
sys/arch/prep/prep/residual.c | 25 ++++++++++++-------------
sys/arch/sparc/sparc/cpu.c | 7 ++++---
sys/arch/sparc/sparc/pci_machdep.c | 6 +++---
sys/arch/sparc/sparc/promlib.c | 9 +++++----
sys/arch/sparc/stand/common/mmu.c | 9 +++++----
8 files changed, 41 insertions(+), 39 deletions(-)
diffs (288 lines):
diff -r 78271fb0c186 -r cf7534af0276 sys/arch/prep/pci/pci_machdep.c
--- a/sys/arch/prep/pci/pci_machdep.c Wed Mar 26 15:55:31 2014 +0000
+++ b/sys/arch/prep/pci/pci_machdep.c Wed Mar 26 15:55:43 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.c,v 1.38 2011/10/13 19:51:17 matt Exp $ */
+/* $NetBSD: pci_machdep.c,v 1.39 2014/03/26 16:01:43 christos Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.38 2011/10/13 19:51:17 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.39 2014/03/26 16:01:43 christos Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -208,11 +208,11 @@
goto bad;
}
- sprintf(key, "devfunc-%d", dev);
+ snprintf(key, sizeof(key), "devfunc-%d", dev);
devsub = prop_dictionary_get(dict, key);
if (devsub == NULL)
goto bad;
- sprintf(key, "pin-%c", 'A' + (pin-1));
+ snprintf(key, sizeof(key), "pin-%c", 'A' + (pin-1));
pinsub = prop_dictionary_get(devsub, key);
if (pinsub == NULL)
goto bad;
diff -r 78271fb0c186 -r cf7534af0276 sys/arch/prep/prep/ibm_machdep.c
--- a/sys/arch/prep/prep/ibm_machdep.c Wed Mar 26 15:55:31 2014 +0000
+++ b/sys/arch/prep/prep/ibm_machdep.c Wed Mar 26 15:55:43 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ibm_machdep.c,v 1.15 2008/04/28 20:23:33 martin Exp $ */
+/* $NetBSD: ibm_machdep.c,v 1.16 2014/03/26 16:01:43 christos Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
intr_num = prop_number_create_integer(13);
for (j = 0; j < 4; j++) {
- sprintf(key, "pin-%c", 'A' + j);
+ snprintf(key, sizeof(key), "pin-%c", 'A' + j);
prop_dictionary_set(sub, key, intr_num);
}
prop_object_release(intr_num);
@@ -71,9 +71,9 @@
for (i = 13; i < 20; i++) {
sub = prop_dictionary_create_with_capacity(4);
intr_num = prop_number_create_integer(15);
- sprintf(key, "devfunc-%d", i);
+ snprintf(key, sizeof(key), "devfunc-%d", i);
for (j = 0; j < 4; j++) {
- sprintf(key, "pin-%c", 'A' + j);
+ snprintf(key, sizeof(key), "pin-%c", 'A' + j);
prop_dictionary_set(sub, key, intr_num);
}
prop_dictionary_set(dict, key, sub);
diff -r 78271fb0c186 -r cf7534af0276 sys/arch/prep/prep/platform.c
--- a/sys/arch/prep/prep/platform.c Wed Mar 26 15:55:31 2014 +0000
+++ b/sys/arch/prep/prep/platform.c Wed Mar 26 15:55:43 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: platform.c,v 1.26 2011/06/20 07:18:07 matt Exp $ */
+/* $NetBSD: platform.c,v 1.27 2014/03/26 16:01:43 christos Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: platform.c,v 1.26 2011/06/20 07:18:07 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: platform.c,v 1.27 2014/03/26 16:01:43 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -266,11 +266,11 @@
else
intr_num = prop_number_create_integer(
(line & 0x7fff) + offset);
- sprintf(key, "pin-%c", 'A' + j);
+ snprintf(key, sizeof(key), "pin-%c", 'A' + j);
prop_dictionary_set(sub, key, intr_num);
prop_object_release(intr_num);
}
- sprintf(key, "devfunc-%d", dev);
+ snprintf(key, sizeof(key), "devfunc-%d", dev);
prop_dictionary_set(dict, key, sub);
prop_object_release(sub);
}
diff -r 78271fb0c186 -r cf7534af0276 sys/arch/prep/prep/residual.c
--- a/sys/arch/prep/prep/residual.c Wed Mar 26 15:55:31 2014 +0000
+++ b/sys/arch/prep/prep/residual.c Wed Mar 26 15:55:43 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: residual.c,v 1.16 2008/04/28 20:23:33 martin Exp $ */
+/* $NetBSD: residual.c,v 1.17 2014/03/26 16:01:43 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: residual.c,v 1.16 2008/04/28 20:23:33 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: residual.c,v 1.17 2014/03/26 16:01:43 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -913,7 +913,7 @@
large_vendor_pcibridge_subr(struct _L4_PPCPack *p, void *v, int size)
{
int i, numslots;
- char tmpstr[30], *t;
+ char tmpstr[30];
PCIInfoPack *pi = v;
static const unsigned char *intrtype[] =
{ "8259", "MPIC", "RS6k BUID %d" };
@@ -934,7 +934,7 @@
printf(" PCI Bridge Slot Data\n");
for (i = 0; i < numslots; i++) {
- int j, first;
+ int j, first, l;
if (pi->map[i].slotnum)
printf(" PCI Slot %d", pi->map[i].slotnum);
@@ -954,19 +954,17 @@
if (first)
continue; /* there were no valid intrs */
printf(" interrupt line(s) %s routed to", tmpstr);
- sprintf(tmpstr, intrtype[pi->map[i].intrctrltype - 1],
+ snprintf(tmpstr, sizeof(tmpstr),
+ intrtype[pi->map[i].intrctrltype - 1],
pi->map[i].intrctrlnum);
printf(" %s line(s) ", tmpstr);
- for (j = 0, first = 1, t = tmpstr; j < MAX_PCI_INTRS; j++) {
+ for (j = 0, first = 1, l = 0; j < MAX_PCI_INTRS; j++) {
int line = bswap16(pi->map[i].intr[j]);
if (pi->map[i].intr[j] != 0xFFFF) {
- if (first)
- first = 0;
- else
- *t++ = '/';
- t += sprintf(t, "%d(%c)", line & 0x7fff,
- line & 0x8000 ? 'E' : 'L');
+ l += snprintf(tmpstr + l, sizeof(tmpstr) - l,
+ "%s%d(%c)", l == 0 ? "/" : "",
+ line & 0x7fff, line & 0x8000 ? 'E' : 'L');
}
}
printf("%s\n", tmpstr);
@@ -1059,7 +1057,8 @@
static const unsigned char *inttype[] =
{ "8259", "MPIC", "RS6k BUID %d" };
- sprintf(tmpstr, inttype[p->PPCData[0] - 1], p->PPCData[1]);
+ snprintf(tmpstr, sizeof(tmpstr), inttype[p->PPCData[0] - 1],
+ p->PPCData[1]);
printf(" ISA interrupts routed to %s lines\n\t", tmpstr);
for (i = 0; i < 16; i++) {
diff -r 78271fb0c186 -r cf7534af0276 sys/arch/sparc/sparc/cpu.c
--- a/sys/arch/sparc/sparc/cpu.c Wed Mar 26 15:55:31 2014 +0000
+++ b/sys/arch/sparc/sparc/cpu.c Wed Mar 26 15:55:43 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.c,v 1.241 2014/03/24 20:06:32 christos Exp $ */
+/* $NetBSD: cpu.c,v 1.242 2014/03/26 15:55:43 christos Exp $ */
/*
* Copyright (c) 1996
@@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.241 2014/03/24 20:06:32 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.242 2014/03/26 15:55:43 christos Exp $");
#include "opt_multiprocessor.h"
#include "opt_lockdebug.h"
@@ -954,7 +954,8 @@
sc->fpupresent = 1;
sc->fpu_name = fsrtoname(sc->cpu_impl, sc->cpu_vers, fpuvers);
if (sc->fpu_name == NULL) {
- sprintf(sc->fpu_namebuf, "version 0x%x", fpuvers);
+ snprintf(sc->fpu_namebuf, sizeof(sc->fpu_namebuf),
+ "version 0x%x", fpuvers);
sc->fpu_name = sc->fpu_namebuf;
}
}
diff -r 78271fb0c186 -r cf7534af0276 sys/arch/sparc/sparc/pci_machdep.c
--- a/sys/arch/sparc/sparc/pci_machdep.c Wed Mar 26 15:55:31 2014 +0000
+++ b/sys/arch/sparc/sparc/pci_machdep.c Wed Mar 26 15:55:43 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.c,v 1.18 2013/04/16 06:57:06 jdc Exp $ */
+/* $NetBSD: pci_machdep.c,v 1.19 2014/03/26 15:55:43 christos Exp $ */
/*
* Copyright (c) 1999, 2000 Matthew R. Green
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.18 2013/04/16 06:57:06 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.19 2014/03/26 15:55:43 christos Exp $");
#if defined(DEBUG) && !defined(SPARC_PCI_DEBUG)
#define SPARC_PCI_DEBUG
@@ -496,7 +496,7 @@
int pil;
pil = mspcic_assigned_interrupt(ih);
- sprintf(str, "line %d (pil %d)", ih, pil);
+ snprintf(str, sizeof(str), "line %d (pil %d)", ih, pil);
return str;
}
diff -r 78271fb0c186 -r cf7534af0276 sys/arch/sparc/sparc/promlib.c
--- a/sys/arch/sparc/sparc/promlib.c Wed Mar 26 15:55:31 2014 +0000
+++ b/sys/arch/sparc/sparc/promlib.c Wed Mar 26 15:55:43 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: promlib.c,v 1.43 2011/07/17 20:54:47 joerg Exp $ */
+/* $NetBSD: promlib.c,v 1.44 2014/03/26 15:55:43 christos Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.43 2011/07/17 20:54:47 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: promlib.c,v 1.44 2014/03/26 15:55:43 christos Exp $");
#if defined(_KERNEL_OPT)
#include "opt_sparc_arch.h"
@@ -149,8 +149,9 @@
char str[64];
int n;
- n = sprintf(str, "Operation not implemented on ROM version %d\r\n",
- promops.po_version);
+ n = snprintf(str, sizeof(str),
+ "Operation not implemented on ROM version %d\r\n",
+ promops.po_version);
/*
* Use PROM vector directly, in case we're called before prom_init().
diff -r 78271fb0c186 -r cf7534af0276 sys/arch/sparc/stand/common/mmu.c
--- a/sys/arch/sparc/stand/common/mmu.c Wed Mar 26 15:55:31 2014 +0000
+++ b/sys/arch/sparc/stand/common/mmu.c Wed Mar 26 15:55:43 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mmu.c,v 1.8 2008/04/28 20:23:36 martin Exp $ */
+/* $NetBSD: mmu.c,v 1.9 2014/03/26 15:55:44 christos Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@
char buf[32];
pmap_map = pmap_map_srmmu;
pmap_extract = pmap_extract_srmmu;
- sprintf(buf, "obmem %lx L!", (u_long)&obmem);
+ snprintf(buf, sizeof(buf), "obmem %lx L!", (u_long)&obmem);
prom_interpret(buf);
} else
return (ENOTSUP);
@@ -143,7 +143,8 @@
{
char buf[64];
- sprintf(buf, "%lx %x %lx %lx map-pages", pa, obmem, va, size);
+ snprintf(buf, sizeof(buf), "%lx %x %lx %lx map-pages",
+ pa, obmem, va, size);
if (boothowto & AB_VERBOSE)
printf("Mapping kernel: %s\n", buf);
@@ -158,7 +159,7 @@
u_int pte;
va &= -NBPG;
- sprintf(buf, "%lx pgmap@ %lx L!", va, (u_long)&pte);
+ snprintf(buf, sizeof(buf), "%lx pgmap@ %lx L!", va, (u_long)&pte);
prom_interpret(buf);
if ((pte & SRMMU_TETYPE) != SRMMU_TEPTE)
return (EFAULT);
Home |
Main Index |
Thread Index |
Old Index