Module Name:    src
Committed By:   christos
Date:           Wed Mar 26 16:01:43 UTC 2014

Modified Files:
        src/sys/arch/prep/pci: pci_machdep.c
        src/sys/arch/prep/prep: ibm_machdep.c platform.c residual.c

Log Message:
kill sprintf


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/prep/pci/pci_machdep.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/prep/prep/ibm_machdep.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/prep/prep/platform.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/prep/prep/residual.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/prep/pci/pci_machdep.c
diff -u src/sys/arch/prep/pci/pci_machdep.c:1.38 src/sys/arch/prep/pci/pci_machdep.c:1.39
--- src/sys/arch/prep/pci/pci_machdep.c:1.38	Thu Oct 13 15:51:17 2011
+++ src/sys/arch/prep/pci/pci_machdep.c	Wed Mar 26 12:01:43 2014
@@ -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 @@ prep_pci_intr_map(const struct pci_attac
 		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;

Index: src/sys/arch/prep/prep/ibm_machdep.c
diff -u src/sys/arch/prep/prep/ibm_machdep.c:1.15 src/sys/arch/prep/prep/ibm_machdep.c:1.16
--- src/sys/arch/prep/prep/ibm_machdep.c:1.15	Mon Apr 28 16:23:33 2008
+++ src/sys/arch/prep/prep/ibm_machdep.c	Wed Mar 26 12:01:43 2014
@@ -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 @@ pci_intr_fixup_ibm_6015(void)
 
 	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 @@ pci_intr_fixup_ibm_6015(void)
 	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);

Index: src/sys/arch/prep/prep/platform.c
diff -u src/sys/arch/prep/prep/platform.c:1.26 src/sys/arch/prep/prep/platform.c:1.27
--- src/sys/arch/prep/prep/platform.c:1.26	Mon Jun 20 03:18:07 2011
+++ src/sys/arch/prep/prep/platform.c	Wed Mar 26 12:01:43 2014
@@ -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 @@ create_intr_map(void *v, prop_dictionary
 			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);
 	}

Index: src/sys/arch/prep/prep/residual.c
diff -u src/sys/arch/prep/prep/residual.c:1.16 src/sys/arch/prep/prep/residual.c:1.17
--- src/sys/arch/prep/prep/residual.c:1.16	Mon Apr 28 16:23:33 2008
+++ src/sys/arch/prep/prep/residual.c	Wed Mar 26 12:01:43 2014
@@ -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 @@ static void
 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 @@ large_vendor_pcibridge_subr(struct _L4_P
 
 	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 @@ large_vendor_pcibridge_subr(struct _L4_P
 		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 @@ large_vendor_isaintr_subr(struct _L4_PPC
 	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++) {

Reply via email to