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/4ff1b72072b7
branches: trunk
changeset: 328072:4ff1b72072b7
user: christos <christos%NetBSD.org@localhost>
date: Tue Mar 25 16:19:13 2014 +0000
description:
kill sprintf
diffstat:
sys/compat/ndis/kern_ndis.c | 18 ++++++++++--------
sys/compat/ndis/subr_ndis.c | 15 ++++++++-------
sys/compat/ndis/subr_ntoskrnl.c | 6 +++---
sys/dev/ata/ata_raid_intel.c | 6 +++---
sys/dev/ata/ata_raid_jmicron.c | 6 +++---
sys/dev/ata/ata_raid_nvidia.c | 6 +++---
sys/dev/ata/ata_raid_via.c | 18 +++++++++---------
sys/dev/firmload.c | 11 ++++-------
sys/dev/ic/ncr53c9xvar.h | 9 +++++----
sys/dev/ic/sunscpal.c | 6 ++----
sys/dev/pci/cxgb/cxgb_l2t.c | 4 ++--
sys/dev/pci/cxgb/cxgb_offload.c | 19 ++++++++++++-------
sys/dev/pci/hdaudio/hdafg.c | 10 ++++++----
sys/dev/pci/if_kse.c | 7 ++++---
sys/dev/pci/if_wm.c | 7 ++++---
sys/dev/pci/ixgbe/ixv.c | 8 ++++----
sys/dev/pci/n8/common/api/n8_callback.c | 4 ++--
sys/dev/pci/n8/common/api/n8_daemon_sks.c | 18 +++++++++---------
sys/dev/pci/n8/common/api/n8_sks.c | 6 +++---
sys/dev/pci/n8/common/api/n8_system.c | 13 +++++++------
sys/dev/pci/n8/include_public/n8_pub_service.h | 2 +-
sys/dev/pci/n8/include_public/n8_pub_sks.h | 2 +-
sys/dev/raidframe/rf_disks.c | 7 ++++---
sys/dev/raidframe/rf_general.h | 4 ++--
24 files changed, 111 insertions(+), 101 deletions(-)
diffs (truncated from 792 to 300 lines):
diff -r 70f772e18824 -r 4ff1b72072b7 sys/compat/ndis/kern_ndis.c
--- a/sys/compat/ndis/kern_ndis.c Tue Mar 25 16:17:33 2014 +0000
+++ b/sys/compat/ndis/kern_ndis.c Tue Mar 25 16:19:13 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_ndis.c,v 1.25 2014/03/23 02:55:26 christos Exp $ */
+/* $NetBSD: kern_ndis.c,v 1.26 2014/03/25 16:23:58 christos Exp $ */
/*-
* Copyright (c) 2003
@@ -37,7 +37,7 @@
__FBSDID("$FreeBSD: src/sys/compat/ndis/kern_ndis.c,v 1.60.2.5 2005/04/01 17:14:20 wpaul Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: kern_ndis.c,v 1.25 2014/03/23 02:55:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ndis.c,v 1.26 2014/03/25 16:23:58 christos Exp $");
#endif
#include <sys/param.h>
@@ -920,17 +920,18 @@
"NDIS API Version", "0x00050001", CTLFLAG_RD);
/* Bus type (PCI, PCMCIA, etc...) */
- sprintf(buf, "%d", (int)sc->ndis_iftype);
+ snprintf(buf, sizeof(buf), "%d", (int)sc->ndis_iftype);
ndis_add_sysctl(sc, "BusType", "Bus Type", buf, CTLFLAG_RD);
if (sc->ndis_res_io != NULL) {
- sprintf(buf, "0x%lx", rman_get_start(sc->ndis_res_io));
+ snprintf(buf, sizeof(buf), "0x%lx",
+ rman_get_start(sc->ndis_res_io));
ndis_add_sysctl(sc, "IOBaseAddress",
"Base I/O Address", buf, CTLFLAG_RD);
}
if (sc->ndis_irq != NULL) {
- sprintf(buf, "%lu", rman_get_start(sc->ndis_irq));
+ snprintf(buf, sizeof(buf), "%lu", rman_get_start(sc->ndis_irq));
ndis_add_sysctl(sc, "InterruptNumber",
"Interrupt Number", buf, CTLFLAG_RD);
}
@@ -1015,17 +1016,18 @@
/*"NDIS API Version"*/ "Version", "0x00050001", CTLFLAG_RD);
/* Bus type (PCI, PCMCIA, etc...) */
- sprintf(buf, "%d", (int)sc->ndis_iftype);
+ snprintf(buf, sizeof(buf), "%d", (int)sc->ndis_iftype);
ndis_add_sysctl(sc, "BusType", "Bus Type", buf, CTLFLAG_RD);
if (sc->ndis_res_io != NULL) {
- sprintf(buf, "0x%lx", (long unsigned int)rman_get_start(sc->ndis_res_io));
+ snprintf(buf, sizeof(buf), "0x%lx",
+ (long unsigned int)rman_get_start(sc->ndis_res_io));
ndis_add_sysctl(sc, "IOBaseAddress",
/*"Base I/O Address"*/ "Base I/O", buf, CTLFLAG_RD);
}
if (sc->ndis_irq != NULL) {
- sprintf(buf, "%lu", (long unsigned int)rman_get_start(sc->ndis_irq));
+ snprintf(buf, sizeof(buf), "%lu", (long unsigned int)rman_get_start(sc->ndis_irq));
ndis_add_sysctl(sc, "InterruptNumber",
"Interrupt Number", buf, CTLFLAG_RD);
}
diff -r 70f772e18824 -r 4ff1b72072b7 sys/compat/ndis/subr_ndis.c
--- a/sys/compat/ndis/subr_ndis.c Tue Mar 25 16:17:33 2014 +0000
+++ b/sys/compat/ndis/subr_ndis.c Tue Mar 25 16:19:13 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_ndis.c,v 1.27 2014/03/23 09:31:15 christos Exp $ */
+/* $NetBSD: subr_ndis.c,v 1.28 2014/03/25 16:23:58 christos Exp $ */
/*-
* Copyright (c) 2003
@@ -37,7 +37,7 @@
__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ndis.c,v 1.67.2.7 2005/03/31 21:50:11 wpaul Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: subr_ndis.c,v 1.27 2014/03/23 09:31:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_ndis.c,v 1.28 2014/03/25 16:23:58 christos Exp $");
#endif
/*
@@ -160,7 +160,7 @@
static ndis_status ndis_encode_parm(ndis_miniport_block *,
struct sysctl_oid *, ndis_parm_type, ndis_config_parm **);
static ndis_status ndis_decode_parm(ndis_miniport_block *,
- ndis_config_parm *, char *);
+ ndis_config_parm *, char *, size_t);
#else /* __NetBSD__ */
static ndis_status ndis_encode_parm(ndis_miniport_block *,
void *, ndis_parm_type, ndis_config_parm **);
@@ -853,7 +853,8 @@
#ifdef __FreeBSD__
static ndis_status
-ndis_decode_parm(ndis_miniport_block *block, ndis_config_parm *parm, char *val)
+ndis_decode_parm(ndis_miniport_block *block, ndis_config_parm *parm, char *val,
+ size_t len)
{
ndis_unicode_string *ustr;
char *astr = NULL;
@@ -868,10 +869,10 @@
free(astr, M_DEVBUF);
break;
case ndis_parm_int:
- sprintf(val, "%d", parm->ncp_parmdata.ncp_intdata);
+ snprintf(val, len, "%d", parm->ncp_parmdata.ncp_intdata);
break;
case ndis_parm_hexint:
- sprintf(val, "%xu", parm->ncp_parmdata.ncp_intdata);
+ snprintf(val, len, "%xu", parm->ncp_parmdata.ncp_intdata);
break;
default:
return(NDIS_STATUS_FAILURE);
@@ -910,7 +911,7 @@
/* Decode the parameter into a string. */
memset(val, 0, sizeof(val));
- *status = ndis_decode_parm(block, parm, val);
+ *status = ndis_decode_parm(block, parm, val, sizeof(val));
if (*status != NDIS_STATUS_SUCCESS) {
free(keystr, M_DEVBUF);
return;
diff -r 70f772e18824 -r 4ff1b72072b7 sys/compat/ndis/subr_ntoskrnl.c
--- a/sys/compat/ndis/subr_ntoskrnl.c Tue Mar 25 16:17:33 2014 +0000
+++ b/sys/compat/ndis/subr_ntoskrnl.c Tue Mar 25 16:19:13 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_ntoskrnl.c,v 1.23 2014/03/23 09:31:15 christos Exp $ */
+/* $NetBSD: subr_ntoskrnl.c,v 1.24 2014/03/25 16:23:58 christos Exp $ */
/*-
* Copyright (c) 2003
@@ -37,7 +37,7 @@
__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ntoskrnl.c,v 1.43.2.5 2005/03/31 04:24:36 wpaul Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: subr_ntoskrnl.c,v 1.23 2014/03/23 09:31:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_ntoskrnl.c,v 1.24 2014/03/25 16:23:58 christos Exp $");
#endif
#ifdef __FreeBSD__
@@ -2384,7 +2384,7 @@
tc->tc_thrctx = thrctx;
tc->tc_thrfunc = thrfunc;
- sprintf(tname, "windows kthread %d", ntoskrnl_kth);
+ snprintf(tname, sizeof(tname), "windows kthread %d", ntoskrnl_kth);
#ifdef __FreeBSD__
error = kthread_create(ntoskrnl_thrfunc, tc, &p,
RFHIGHPID, NDIS_KSTACK_PAGES, tname);
diff -r 70f772e18824 -r 4ff1b72072b7 sys/dev/ata/ata_raid_intel.c
--- a/sys/dev/ata/ata_raid_intel.c Tue Mar 25 16:17:33 2014 +0000
+++ b/sys/dev/ata/ata_raid_intel.c Tue Mar 25 16:19:13 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_intel.c,v 1.6 2010/07/06 18:09:04 bsh Exp $ */
+/* $NetBSD: ata_raid_intel.c,v 1.7 2014/03/25 16:19:13 christos Exp $ */
/*-
* Copyright (c) 2000-2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.6 2010/07/06 18:09:04 bsh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_intel.c,v 1.7 2014/03/25 16:19:13 christos Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -79,7 +79,7 @@
case INTEL_T_RAID5:
return "RAID5";
default:
- sprintf(buffer, "UNKNOWN 0x%02x", type);
+ snprintf(buffer, sizeof(buffer), "UNKNOWN 0x%02x", type);
return buffer;
}
}
diff -r 70f772e18824 -r 4ff1b72072b7 sys/dev/ata/ata_raid_jmicron.c
--- a/sys/dev/ata/ata_raid_jmicron.c Tue Mar 25 16:17:33 2014 +0000
+++ b/sys/dev/ata/ata_raid_jmicron.c Tue Mar 25 16:19:13 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_jmicron.c,v 1.4 2009/05/11 17:14:31 cegger Exp $ */
+/* $NetBSD: ata_raid_jmicron.c,v 1.5 2014/03/25 16:19:13 christos Exp $ */
/*-
* Copyright (c) 2000-2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.4 2009/05/11 17:14:31 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_jmicron.c,v 1.5 2014/03/25 16:19:13 christos Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -82,7 +82,7 @@
case JM_T_JBOD:
return "JBOD";
default:
- sprintf(buffer, "UNKNOWN 0x%02x", type);
+ snprintf(buffer, sizeof(buffer), "UNKNOWN 0x%02x", type);
return buffer;
}
}
diff -r 70f772e18824 -r 4ff1b72072b7 sys/dev/ata/ata_raid_nvidia.c
--- a/sys/dev/ata/ata_raid_nvidia.c Tue Mar 25 16:17:33 2014 +0000
+++ b/sys/dev/ata/ata_raid_nvidia.c Tue Mar 25 16:19:13 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_nvidia.c,v 1.1 2008/08/20 15:00:34 tacha Exp $ */
+/* $NetBSD: ata_raid_nvidia.c,v 1.2 2014/03/25 16:19:13 christos Exp $ */
/*-
* Copyright (c) 2000 - 2008 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.1 2008/08/20 15:00:34 tacha Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_nvidia.c,v 1.2 2014/03/25 16:19:13 christos Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -76,7 +76,7 @@
case NV_T_RAID5: return "RAID5";
case NV_T_RAID01: return "RAID0+1";
default:
- sprintf(buffer, "UNKNOWN 0x%02x", type);
+ snprintf(buffer, sizeof(buffer), "UNKNOWN 0x%02x", type);
return buffer;
}
}
diff -r 70f772e18824 -r 4ff1b72072b7 sys/dev/ata/ata_raid_via.c
--- a/sys/dev/ata/ata_raid_via.c Tue Mar 25 16:17:33 2014 +0000
+++ b/sys/dev/ata/ata_raid_via.c Tue Mar 25 16:19:13 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ata_raid_via.c,v 1.6 2008/09/19 16:49:27 christos Exp $ */
+/* $NetBSD: ata_raid_via.c,v 1.7 2014/03/25 16:19:13 christos Exp $ */
/*-
* Copyright (c) 2000,2001,2002 Søren Schmidt <sos%FreeBSD.org@localhost>
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_raid_via.c,v 1.6 2008/09/19 16:49:27 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_raid_via.c,v 1.7 2014/03/25 16:19:13 christos Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -71,13 +71,13 @@
static char buffer[16];
switch (type) {
- case VIA_T_RAID0: return "RAID0";
- case VIA_T_RAID1: return "RAID1";
- case VIA_T_RAID5: return "RAID5";
- case VIA_T_RAID01: return "RAID0+1";
- case VIA_T_SPAN: return "SPAN";
- default:
- sprintf(buffer, "UNKNOWN 0x%02x", type);
+ case VIA_T_RAID0: return "RAID0";
+ case VIA_T_RAID1: return "RAID1";
+ case VIA_T_RAID5: return "RAID5";
+ case VIA_T_RAID01: return "RAID0+1";
+ case VIA_T_SPAN: return "SPAN";
+ default:
+ snprintf(buffer, sizeof(buffer), "UNKNOWN 0x%02x", type);
return buffer;
}
}
diff -r 70f772e18824 -r 4ff1b72072b7 sys/dev/firmload.c
--- a/sys/dev/firmload.c Tue Mar 25 16:17:33 2014 +0000
+++ b/sys/dev/firmload.c Tue Mar 25 16:19:13 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: firmload.c,v 1.18 2014/02/25 18:30:09 pooka Exp $ */
+/* $NetBSD: firmload.c,v 1.19 2014/03/25 16:19:13 christos Exp $ */
/*-
* Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: firmload.c,v 1.18 2014/02/25 18:30:09 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: firmload.c,v 1.19 2014/03/25 16:19:13 christos Exp $");
/*
* The firmload API provides an interface for device drivers to access
@@ -185,11 +185,8 @@
prefix++;
*prefixp = prefix;
- /*
- * This sprintf() is safe because of the maxprefix calculation
- * performed above.
- */
- sprintf(&pnbuf[i], "/%s/%s", drvname, imgname);
+ KASSERT(MAXPATHLEN >= i);
+ snprintf(pnbuf + i, MAXPATHLEN - i, "/%s/%s", drvname, imgname);
return (pnbuf);
}
Home |
Main Index |
Thread Index |
Old Index