Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/dreamcast/dev kill sprintf
details: https://anonhg.NetBSD.org/src/rev/fee96bb9f7e9
branches: trunk
changeset: 794842:fee96bb9f7e9
user: christos <christos%NetBSD.org@localhost>
date: Wed Mar 26 16:08:45 2014 +0000
description:
kill sprintf
diffstat:
sys/arch/dreamcast/dev/maple/maple.c | 62 +++++++++++++++++---------------
sys/arch/dreamcast/dev/maple/mlcd.c | 7 ++-
sys/arch/dreamcast/dev/maple/mmemcard.c | 7 ++-
sys/arch/dreamcast/dev/pvr.c | 6 +-
4 files changed, 43 insertions(+), 39 deletions(-)
diffs (truncated from 327 to 300 lines):
diff -r f6e0bf5ebfb8 -r fee96bb9f7e9 sys/arch/dreamcast/dev/maple/maple.c
--- a/sys/arch/dreamcast/dev/maple/maple.c Wed Mar 26 16:07:15 2014 +0000
+++ b/sys/arch/dreamcast/dev/maple/maple.c Wed Mar 26 16:08:45 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: maple.c,v 1.48 2014/03/16 05:20:23 dholland Exp $ */
+/* $NetBSD: maple.c,v 1.49 2014/03/26 16:08:45 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: maple.c,v 1.48 2014/03/16 05:20:23 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: maple.c,v 1.49 2014/03/26 16:08:45 christos Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -111,7 +111,7 @@
static int maplematch(device_t, cfdata_t, void *);
static void mapleattach(device_t, device_t, void *);
static void maple_scanbus(struct maple_softc *);
-static char * maple_unit_name(char *, int port, int subunit);
+static char * maple_unit_name(char *, size_t, int port, int subunit);
static void maple_begin_txbuf(struct maple_softc *);
static int maple_end_txbuf(struct maple_softc *);
static void maple_queue_command(struct maple_softc *, struct maple_unit *,
@@ -280,7 +280,7 @@
{
char buf[16];
printf("%s: queued to probe 1\n",
- maple_unit_name(buf, u->port, u->subunit));
+ maple_unit_name(buf, sizeof(buf), u->port, u->subunit));
}
#endif
TAILQ_INSERT_TAIL(&sc->sc_probeq, u, u_q);
@@ -351,12 +351,11 @@
}
static char *
-maple_unit_name(char *buf, int port, int subunit)
+maple_unit_name(char *buf, size_t len, int port, int subunit)
{
-
- sprintf(buf, "maple%c", port + 'A');
+ int l = snprintf(buf, len, "maple%c", port + 'A');
if (subunit)
- sprintf(buf+6, "%d", subunit);
+ snprintf(buf + l, len - l, "%d", subunit);
return buf;
}
@@ -472,8 +471,8 @@
char buf[16];
if (u->u_retrycnt)
- printf("%s: retrycnt %d\n",
- maple_unit_name(buf, u->port, u->subunit), u->u_retrycnt);
+ printf("%s: retrycnt %d\n", maple_unit_name(buf, sizeof(buf),
+ u->port, u->subunit), u->u_retrycnt);
#endif
u->u_retrycnt = 0;
u->u_command = command;
@@ -524,7 +523,7 @@
{
char buf[16];
printf("%s: unit_map 0x%x -> 0x%x (units 0x%x)\n",
- maple_unit_name(buf, u->port, u->subunit),
+ maple_unit_name(buf, sizeof(buf), u->port, u->subunit),
sc->sc_port_unit_map[port], unit_map, units);
}
#endif
@@ -550,7 +549,8 @@
{
char buf[16];
printf("%s: queued to probe 2\n",
- maple_unit_name(buf, u1->port, u1->subunit));
+ maple_unit_name(buf, sizeof(buf),
+ u1->port, u1->subunit));
}
#endif
TAILQ_INSERT_HEAD(&sc->sc_probeq, u1, u_q);
@@ -579,7 +579,7 @@
{
char buf[16];
printf("%s: queued to ping\n",
- maple_unit_name(buf, u->port, u->subunit));
+ maple_unit_name(buf, sizeof(buf), u->port, u->subunit));
}
#endif
TAILQ_INSERT_TAIL(&sc->sc_pingq, u, u_q);
@@ -598,7 +598,8 @@
subunit = ma->ma_unit->subunit;
if (pnp != NULL)
- printf("%s at %s", maple_unit_name(buf, port, subunit), pnp);
+ printf("%s at %s", maple_unit_name(buf, sizeof(buf), port,
+ subunit), pnp);
printf(" port %d", port);
@@ -679,7 +680,8 @@
maple_print_unit(&ma, device_xname(sc->sc_dev));
printf("\n");
strcpy(oldxname, device_xname(sc->sc_dev));
- maple_unit_name(sc->sc_dev->dv_xname, u->port, u->subunit);
+ maple_unit_name(sc->sc_dev->dv_xname, sizeof(sc->sc_dev->dv_xname),
+ u->port, u->subunit);
for (f = 0; f < MAPLE_NFUNC; f++) {
u->u_func[f].f_callback = NULL;
@@ -723,7 +725,7 @@
char buf[16];
#if defined(MAPLE_DEBUG) && MAPLE_DEBUG > 1
- printf("%s: remove\n", maple_unit_name(buf, u->port, u->subunit));
+ printf("%s: remove\n", maple_unit_name(buf, sizeof(buf), u->port, u->subunit));
#endif
maple_remove_from_queues(sc, u);
port = u->port;
@@ -738,7 +740,7 @@
if ((dev = fn->f_dev) != NULL) {
#if defined(MAPLE_DEBUG) && MAPLE_DEBUG > 1
printf("%s: detaching func %d\n",
- maple_unit_name(buf, port, u->subunit),
+ maple_unit_name(buf, sizeof(buf), port, u->subunit),
fn->f_funcno);
#endif
@@ -763,7 +765,7 @@
*/
if ((error = config_detach(fn->f_dev, DETACH_FORCE))) {
printf("%s: failed to detach %s (func %d), errno %d\n",
- maple_unit_name(buf, port, u->subunit),
+ maple_unit_name(buf, sizeof(buf), port, u->subunit),
device_xname(fn->f_dev), fn->f_funcno, error);
}
}
@@ -781,7 +783,7 @@
if (u1 == u) {
#if defined(MAPLE_DEBUG) && MAPLE_DEBUG > 1
printf("%s: abort retry\n",
- maple_unit_name(buf, port, u->subunit));
+ maple_unit_name(buf, sizeof(buf), port, u->subunit));
#endif
SIMPLEQ_REMOVE(&sc->sc_retryq, u, maple_unit,
u_dmaq);
@@ -801,7 +803,7 @@
{
char buf2[16];
printf("%s: queued to probe 3\n",
- maple_unit_name(buf2, port, u->subunit));
+ maple_unit_name(buf2, sizeof(buf2), port, u->subunit));
}
#endif
TAILQ_INSERT_TAIL(&sc->sc_probeq, u, u_q);
@@ -843,7 +845,7 @@
{char buf[16];
if (fn->f_cmdstat != MAPLE_CMDSTAT_NONE)
panic("maple_command: %s func %d: requesting more than one commands",
- maple_unit_name(buf, u->port, u->subunit), func);
+ maple_unit_name(buf, sizeof(buf), u->port, u->subunit), func);
}
#endif
fn->f_command = command;
@@ -1129,7 +1131,7 @@
if (u->u_queuestat != MAPLE_QUEUE_NONE) {
char buf[16];
printf("%s: dequeued\n",
- maple_unit_name(buf, u->port, u->subunit));
+ maple_unit_name(buf, sizeof(buf), u->port, u->subunit));
}
#endif
@@ -1150,7 +1152,7 @@
if (u->u_retrycnt == 0) {
char buf[16];
printf("%s: retrying: %#x, %#x, %p\n",
- maple_unit_name(buf, u->port, u->subunit),
+ maple_unit_name(buf, sizeof(buf), u->port, u->subunit),
u->u_command, u->u_datalen, u->u_dataaddr);
}
#endif
@@ -1253,7 +1255,7 @@
/* detach */
#if defined(MAPLE_DEBUG) && MAPLE_DEBUG > 2
printf("%s: func: %d: periodic response %d\n",
- maple_unit_name(buf, u->port, u->subunit),
+ maple_unit_name(buf, sizeof(buf), u->port, u->subunit),
u->u_dma_func,
response);
#endif
@@ -1279,13 +1281,13 @@
if (u->subunit != 0 &&
++u->u_proberetry > MAPLE_PROBERETRY_MAX) {
printf("%s: no response\n",
- maple_unit_name(buf,
+ maple_unit_name(buf, sizeof(buf),
u->port, u->subunit));
} else {
/* probe again */
#if defined(MAPLE_DEBUG) && MAPLE_DEBUG > 2
printf("%s: queued to probe 4\n",
- maple_unit_name(buf, u->port, u->subunit));
+ maple_unit_name(buf, sizeof(buf), u->port, u->subunit));
#endif
TAILQ_INSERT_TAIL(&sc->sc_probeq, u,
u_q);
@@ -1312,7 +1314,7 @@
/* detach */
#if defined(MAPLE_DEBUG) && MAPLE_DEBUG > 1
printf("%s: ping response %d\n",
- maple_unit_name(buf, u->port,
+ maple_unit_name(buf, sizeof(buf), u->port,
u->subunit),
response);
#endif
@@ -1329,7 +1331,7 @@
*/
#ifdef MAPLE_DEBUG
printf("%s: switching ping method\n",
- maple_unit_name(buf,
+ maple_unit_name(buf, sizeof(buf),
u->port, u->subunit));
#endif
u->u_ping_stat
@@ -1369,7 +1371,7 @@
/* detach */
#if defined(MAPLE_DEBUG) && MAPLE_DEBUG > 1
printf("%s: command response %d\n",
- maple_unit_name(buf, u->port,
+ maple_unit_name(buf, sizeof(buf), u->port,
u->subunit),
response);
#endif
@@ -1388,7 +1390,7 @@
/* detached right now */
#ifdef MAPLE_DEBUG
printf("%s: unknown function: function %d, response %d\n",
- maple_unit_name(buf, u->port, u->subunit),
+ maple_unit_name(buf, sizeof(buf), u->port, u->subunit),
func_code, response);
#endif
continue;
diff -r f6e0bf5ebfb8 -r fee96bb9f7e9 sys/arch/dreamcast/dev/maple/mlcd.c
--- a/sys/arch/dreamcast/dev/maple/mlcd.c Wed Mar 26 16:07:15 2014 +0000
+++ b/sys/arch/dreamcast/dev/maple/mlcd.c Wed Mar 26 16:08:45 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mlcd.c,v 1.16 2014/03/16 05:20:23 dholland Exp $ */
+/* $NetBSD: mlcd.c,v 1.17 2014/03/26 16:08:45 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mlcd.c,v 1.16 2014/03/16 05:20:23 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mlcd.c,v 1.17 2014/03/26 16:08:45 christos Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -275,7 +275,8 @@
M_WAITOK|M_ZERO);
for (i = 0; i < sc->sc_npt; i++) {
- sprintf(sc->sc_pt[i].pt_name, "%s.%d", device_xname(self), i);
+ snprintf(sc->sc_pt[i].pt_name, sizeof(sc->sc_pt[i].pt_name),
+ "%s.%d", device_xname(self), i);
}
maple_set_callback(parent, sc->sc_unit, MAPLE_FN_LCD,
diff -r f6e0bf5ebfb8 -r fee96bb9f7e9 sys/arch/dreamcast/dev/maple/mmemcard.c
--- a/sys/arch/dreamcast/dev/maple/mmemcard.c Wed Mar 26 16:07:15 2014 +0000
+++ b/sys/arch/dreamcast/dev/maple/mmemcard.c Wed Mar 26 16:08:45 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mmemcard.c,v 1.21 2014/03/16 05:20:23 dholland Exp $ */
+/* $NetBSD: mmemcard.c,v 1.22 2014/03/26 16:08:45 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mmemcard.c,v 1.21 2014/03/16 05:20:23 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mmemcard.c,v 1.22 2014/03/26 16:08:45 christos Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -298,7 +298,8 @@
M_WAITOK|M_ZERO);
for (i = 0; i < sc->sc_npt; i++) {
- sprintf(sc->sc_pt[i].pt_name, "%s.%d", device_xname(self), i);
+ snprintf(sc->sc_pt[i].pt_name, sizeof(sc->sc_pt[i].pt_name),
+ "%s.%d", device_xname(self), i);
}
maple_set_callback(parent, sc->sc_unit, MAPLE_FN_MEMCARD,
Home |
Main Index |
Thread Index |
Old Index