Module Name: src Committed By: christos Date: Wed Mar 26 16:08:45 UTC 2014
Modified Files: src/sys/arch/dreamcast/dev: pvr.c src/sys/arch/dreamcast/dev/maple: maple.c mlcd.c mmemcard.c Log Message: kill sprintf To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/arch/dreamcast/dev/pvr.c cvs rdiff -u -r1.48 -r1.49 src/sys/arch/dreamcast/dev/maple/maple.c cvs rdiff -u -r1.16 -r1.17 src/sys/arch/dreamcast/dev/maple/mlcd.c cvs rdiff -u -r1.21 -r1.22 src/sys/arch/dreamcast/dev/maple/mmemcard.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/dreamcast/dev/pvr.c diff -u src/sys/arch/dreamcast/dev/pvr.c:1.34 src/sys/arch/dreamcast/dev/pvr.c:1.35 --- src/sys/arch/dreamcast/dev/pvr.c:1.34 Wed Jan 11 16:17:33 2012 +++ src/sys/arch/dreamcast/dev/pvr.c Wed Mar 26 12:08:45 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: pvr.c,v 1.34 2012/01/11 21:17:33 macallan Exp $ */ +/* $NetBSD: pvr.c,v 1.35 2014/03/26 16:08:45 christos Exp $ */ /*- * Copyright (c) 2001 Marcus Comstedt. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: pvr.c,v 1.34 2012/01/11 21:17:33 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pvr.c,v 1.35 2014/03/26 16:08:45 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -260,7 +260,7 @@ pvr_getdevconfig(struct fb_devconfig *dc dc->dc_wsscrdescr.textops = &dc->dc_rinfo.ri_ops; dc->dc_wsscrdescr.capabilities = dc->dc_rinfo.ri_caps; - sprintf(dc->dc_wsscrname, "%dx%d", + snprintf(dc->dc_wsscrname, sizeof(dc->dc_wsscrname), "%dx%d", dc->dc_wsscrdescr.ncols, dc->dc_wsscrdescr.nrows); } Index: src/sys/arch/dreamcast/dev/maple/maple.c diff -u src/sys/arch/dreamcast/dev/maple/maple.c:1.48 src/sys/arch/dreamcast/dev/maple/maple.c:1.49 --- src/sys/arch/dreamcast/dev/maple/maple.c:1.48 Sun Mar 16 01:20:23 2014 +++ src/sys/arch/dreamcast/dev/maple/maple.c Wed Mar 26 12:08:45 2014 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: maple.c,v 1. 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 @@ maple_scanbus(struct maple_softc *sc) { 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 @@ maple_run_polling(device_t dev) } 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 @@ maple_write_command(struct maple_softc * 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 @@ maple_check_subunit_change(struct maple_ { 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 @@ maple_check_subunit_change(struct maple_ { 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 @@ out: { 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 @@ maple_print_unit(void *aux, const char * 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_attach_unit(struct maple_softc *sc 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 @@ maple_detach_unit_nofix(struct maple_sof 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 @@ maple_detach_unit_nofix(struct maple_sof 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 @@ maple_detach_unit_nofix(struct maple_sof */ 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 @@ maple_detach_unit_nofix(struct maple_sof 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 @@ maple_detach_unit_nofix(struct maple_sof { 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 @@ maple_command(device_t dev, struct maple {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 @@ maple_remove_from_queues(struct maple_so 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 @@ maple_retry(struct maple_softc *sc, stru 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 @@ maple_check_responses(struct maple_softc /* 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 @@ maple_check_responses(struct maple_softc 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 @@ maple_check_responses(struct maple_softc /* 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 @@ maple_check_responses(struct maple_softc */ #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 @@ maple_check_responses(struct maple_softc /* 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 @@ maple_check_responses(struct maple_softc /* 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; Index: src/sys/arch/dreamcast/dev/maple/mlcd.c diff -u src/sys/arch/dreamcast/dev/maple/mlcd.c:1.16 src/sys/arch/dreamcast/dev/maple/mlcd.c:1.17 --- src/sys/arch/dreamcast/dev/maple/mlcd.c:1.16 Sun Mar 16 01:20:23 2014 +++ src/sys/arch/dreamcast/dev/maple/mlcd.c Wed Mar 26 12:08:45 2014 @@ -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 @@ mlcdattach(device_t parent, device_t sel 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, Index: src/sys/arch/dreamcast/dev/maple/mmemcard.c diff -u src/sys/arch/dreamcast/dev/maple/mmemcard.c:1.21 src/sys/arch/dreamcast/dev/maple/mmemcard.c:1.22 --- src/sys/arch/dreamcast/dev/maple/mmemcard.c:1.21 Sun Mar 16 01:20:23 2014 +++ src/sys/arch/dreamcast/dev/maple/mmemcard.c Wed Mar 26 12:08:45 2014 @@ -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 @@ mmemattach(device_t parent, device_t sel 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,