Module Name: src
Committed By: christos
Date: Wed Mar 26 18:04:34 UTC 2014
Modified Files:
src/sys/arch/atari/atari: machdep.c
src/sys/arch/atari/dev: clock.c ite.c
src/sys/arch/atari/pci: pci_machdep.c
src/sys/arch/atari/stand/ahdilabel: ahdilabel.c
src/sys/arch/atari/stand/installboot: installboot.c
src/sys/arch/atari/stand/tostools/aptck: diskio.c
src/sys/arch/atari/stand/tostools/libtos: diskio.c
Log Message:
kill sprintf
To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/sys/arch/atari/atari/machdep.c
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/atari/dev/clock.c
cvs rdiff -u -r1.74 -r1.75 src/sys/arch/atari/dev/ite.c
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/atari/pci/pci_machdep.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/atari/stand/ahdilabel/ahdilabel.c
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/atari/stand/installboot/installboot.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/atari/stand/tostools/aptck/diskio.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/atari/stand/tostools/libtos/diskio.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/atari/atari/machdep.c
diff -u src/sys/arch/atari/atari/machdep.c:1.176 src/sys/arch/atari/atari/machdep.c:1.177
--- src/sys/arch/atari/atari/machdep.c:1.176 Mon Mar 24 14:39:57 2014
+++ src/sys/arch/atari/atari/machdep.c Wed Mar 26 14:04:33 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.176 2014/03/24 18:39:57 christos Exp $ */
+/* $NetBSD: machdep.c,v 1.177 2014/03/26 18:04:33 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.176 2014/03/24 18:39:57 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.177 2014/03/26 18:04:33 christos Exp $");
#include "opt_ddb.h"
#include "opt_compat_netbsd.h"
@@ -268,7 +268,7 @@ identifycpu(void)
__asm(".word 0x4e7a,0x0808;"
"movl %%d0,%0" : "=d"(pcr) : : "d0");
- sprintf(cputxt, "68%s060 rev.%d",
+ snprintf(cputxt, sizeof(cputxt), "68%s060 rev.%d",
pcr & 0x10000 ? "LC/EC" : "", (pcr >> 8) & 0xff);
cpu = cputxt;
mmu = "/MMU";
Index: src/sys/arch/atari/dev/clock.c
diff -u src/sys/arch/atari/dev/clock.c:1.57 src/sys/arch/atari/dev/clock.c:1.58
--- src/sys/arch/atari/dev/clock.c:1.57 Mon Mar 24 14:39:57 2014
+++ src/sys/arch/atari/dev/clock.c Wed Mar 26 14:04:33 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: clock.c,v 1.57 2014/03/24 18:39:57 christos Exp $ */
+/* $NetBSD: clock.c,v 1.58 2014/03/26 18:04:33 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.57 2014/03/24 18:39:57 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.58 2014/03/26 18:04:33 christos Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -519,7 +519,7 @@ rtcread(dev_t dev, struct uio *uio, int
MC146818_GETTOD(RTC, &clkregs);
splx(s);
- sprintf(buffer, "%4d%02d%02d%02d%02d.%02d\n",
+ snprintf(buffer, sizeof(buffer), "%4d%02d%02d%02d%02d.%02d\n",
clkregs[MC_YEAR] + GEMSTARTOFTIME,
clkregs[MC_MONTH], clkregs[MC_DOM],
clkregs[MC_HOUR], clkregs[MC_MIN], clkregs[MC_SEC]);
Index: src/sys/arch/atari/dev/ite.c
diff -u src/sys/arch/atari/dev/ite.c:1.74 src/sys/arch/atari/dev/ite.c:1.75
--- src/sys/arch/atari/dev/ite.c:1.74 Mon Mar 24 14:39:57 2014
+++ src/sys/arch/atari/dev/ite.c Wed Mar 26 14:04:33 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ite.c,v 1.74 2014/03/24 18:39:57 christos Exp $ */
+/* $NetBSD: ite.c,v 1.75 2014/03/26 18:04:33 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ite.c,v 1.74 2014/03/24 18:39:57 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ite.c,v 1.75 2014/03/26 18:04:33 christos Exp $");
#include "opt_ddb.h"
@@ -1681,7 +1681,7 @@ iteputchar(register int c, struct ite_so
break;
case 6:
/* cursor position report */
- sprintf (sc->argbuf, "\033[%d;%dR",
+ snprintf (sc->argbuf, sizeof(sc->argbuf), "\033[%d;%dR",
sc->cury + 1, sc->curx + 1);
ite_sendstr (sc->argbuf);
break;
Index: src/sys/arch/atari/pci/pci_machdep.c
diff -u src/sys/arch/atari/pci/pci_machdep.c:1.52 src/sys/arch/atari/pci/pci_machdep.c:1.53
--- src/sys/arch/atari/pci/pci_machdep.c:1.52 Fri Jul 1 16:34:06 2011
+++ src/sys/arch/atari/pci/pci_machdep.c Wed Mar 26 14:04:33 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.c,v 1.52 2011/07/01 20:34:06 dyoung Exp $ */
+/* $NetBSD: pci_machdep.c,v 1.53 2014/03/26 18:04:33 christos Exp $ */
/*
* Copyright (c) 1996 Leo Weppelman. All rights reserved.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.52 2011/07/01 20:34:06 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.53 2014/03/26 18:04:33 christos Exp $");
#include "opt_mbtype.h"
@@ -680,7 +680,7 @@ pci_intr_string(pci_chipset_tag_t pc, pc
if (ih == -1)
panic("pci_intr_string: bogus handle 0x%x", ih);
- sprintf(irqstr, "irq %d", ih);
+ snprintf(irqstr, sizeof(irqstr), "irq %d", ih);
return irqstr;
}
Index: src/sys/arch/atari/stand/ahdilabel/ahdilabel.c
diff -u src/sys/arch/atari/stand/ahdilabel/ahdilabel.c:1.8 src/sys/arch/atari/stand/ahdilabel/ahdilabel.c:1.9
--- src/sys/arch/atari/stand/ahdilabel/ahdilabel.c:1.8 Sat Mar 14 17:04:06 2009
+++ src/sys/arch/atari/stand/ahdilabel/ahdilabel.c Wed Mar 26 14:04:33 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ahdilabel.c,v 1.8 2009/03/14 21:04:06 dsl Exp $ */
+/* $NetBSD: ahdilabel.c,v 1.9 2014/03/26 18:04:33 christos Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
int main (int, char*[]);
void show_parts (struct ahdi_ptable*, int, int, int);
int get_input (char *, int);
-char *sec_to_cts (struct ahdi_ptable*, u_int32_t, char *);
+char *sec_to_cts (struct ahdi_ptable*, u_int32_t, char *, size_t);
u_int32_t read_sector (struct ahdi_ptable*, char *, int, int);
void change_part (struct ahdi_ptable*, int, int);
@@ -296,7 +296,7 @@ get_input (char *buf, int len)
}
char *
-sec_to_cts (struct ahdi_ptable *ptable, u_int32_t sector, char *cts)
+sec_to_cts (struct ahdi_ptable *ptable, u_int32_t sector, char *cts, size_t len)
{
u_int32_t cylinder, track;
@@ -304,7 +304,7 @@ sec_to_cts (struct ahdi_ptable *ptable,
sector -= cylinder * ptable->secpercyl;
track = sector / ptable->nsectors;
sector -= track * ptable->nsectors;
- sprintf (cts, "%u/%u/%u", cylinder, track, sector);
+ snprintf (cts, len, "%u/%u/%u", cylinder, track, sector);
return (cts);
}
@@ -388,21 +388,21 @@ change_part (struct ahdi_ptable *ptable,
}
printf ("root [%8u (%s)] ", ptable->parts[part].root,
- sec_to_cts (ptable, ptable->parts[part].root, &cts[0]));
+ sec_to_cts (ptable, ptable->parts[part].root, cts, sizeof(cts)));
if (get_input (&buf[0], BUFLEN)) {
sector = read_sector (ptable, buf, part, PART_ROOT);
ptable->parts[part].root = sector;
}
printf ("start [%8u (%s)] ", ptable->parts[part].start,
- sec_to_cts (ptable, ptable->parts[part].start, &cts[0]));
+ sec_to_cts (ptable, ptable->parts[part].start, cts, sizeof(cts)));
if (get_input (&buf[0], BUFLEN)) {
sector = read_sector (ptable, buf, part, PART_START);
ptable->parts[part].start = sector;
}
printf ("size [%8u (%s) (%4uM)] ", ptable->parts[part].size,
- sec_to_cts (ptable, ptable->parts[part].size, &cts[0]),
+ sec_to_cts (ptable, ptable->parts[part].size, cts[0], sizeof(cts)),
(ptable->parts[part].size + (BLPM >> 1)) / BLPM);
if (get_input (&buf[0], BUFLEN)) {
sector = read_sector (ptable, buf, part, PART_END);
Index: src/sys/arch/atari/stand/installboot/installboot.c
diff -u src/sys/arch/atari/stand/installboot/installboot.c:1.25 src/sys/arch/atari/stand/installboot/installboot.c:1.26
--- src/sys/arch/atari/stand/installboot/installboot.c:1.25 Fri Nov 4 20:34:01 2011
+++ src/sys/arch/atari/stand/installboot/installboot.c Wed Mar 26 14:04:33 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: installboot.c,v 1.25 2011/11/05 00:34:01 christos Exp $ */
+/* $NetBSD: installboot.c,v 1.26 2014/03/26 18:04:33 christos Exp $ */
/*
* Copyright (c) 1995 Waldi Ravens
@@ -130,16 +130,18 @@ main(int argc, char *argv[])
usage();
/* get disk label */
- dn = alloca(sizeof(_PATH_DEV) + strlen(argv[0]) + 8);
+ size_t dnlen = sizeof(_PATH_DEV) + strlen(argv[0]) + 8;
+ dn = alloca(dnlen);
if (!strchr(argv[0], '/')) {
- sprintf(dn, "%sr%s%c", _PATH_DEV, argv[0], RAW_PART + 'a');
+ snprintf(dn, dnlen, "%sr%s%c", _PATH_DEV, argv[0],
+ RAW_PART + 'a');
fd = open(dn, O_RDONLY);
if (fd < 0 && errno == ENOENT) {
- sprintf(dn, "%sr%s", _PATH_DEV, argv[0]);
+ snprintf(dn, dnlen, "%sr%s", _PATH_DEV, argv[0]);
fd = open(dn, O_RDONLY);
}
} else {
- sprintf(dn, "%s", argv[0]);
+ snprintf(dn, dnlen, "%s", argv[0]);
fd = open(dn, O_RDONLY);
}
if (fd < 0)
@@ -226,10 +228,11 @@ install_fd(char *devnm, struct disklabel
machpath = milanpath;
else
machpath = stdpath;
- xxboot = alloca(strlen(mdecpath) + strlen(machpath) + 8);
- sprintf(xxboot, "%s%sfdboot", mdecpath, machpath);
- bootxx = alloca(strlen(mdecpath) + strlen(machpath) + 8);
- sprintf(bootxx, "%s%sbootxx", mdecpath, machpath);
+ size_t xxboolen = strlen(mdecpath) + strlen(machpath) + 8);
+ xxboot = alloca(xxbootlen);
+ snprintf(xxboot, xxbootlen, "%s%sfdboot", mdecpath, machpath);
+ bootxx = alloca(xxbootlen);
+ snprintf(bootxx, xxbootlen, "%s%sbootxx", mdecpath, machpath);
/* first used partition (a, b or c) */ /* XXX */
for (rootpart = label->d_partitions; ; ++rootpart) {
@@ -287,19 +290,22 @@ install_sd(char *devnm, struct disklabel
else
machpath = stdpath;
if (bbsec) {
- xxb00t = alloca(strlen(mdecpath) + strlen(machpath) + 14);
- sprintf(xxb00t, "%s%ssdb00t.ahdi", mdecpath, machpath);
- xxboot = alloca(strlen(mdecpath) + strlen(machpath) + 14);
- sprintf(xxboot, "%s%sxxboot.ahdi", mdecpath, machpath);
+ size_t xxb00tlen = strlen(mdecpath) + strlen(machpath) + 14;
+ xxb00t = alloca(xxb00tlen);
+ snprintf(xxb00t, xxb00tlen, "%s%ssdb00t.ahdi", mdecpath, machpath);
+ xxboot = alloca(xxb00tlen);
+ snprintf(xxboot, xxb00tlen, "%s%sxxboot.ahdi", mdecpath, machpath);
magic = AHDIMAGIC;
} else {
+ size_t xxbootlen = strlen(mdecpath) + strlen(machpath) + 8;
xxb00t = NULL;
- xxboot = alloca(strlen(mdecpath) + strlen(machpath) + 8);
- sprintf(xxboot, "%s%ssdboot", mdecpath, machpath);
+ xxboot = alloca(xxbootlen);
+ snprintf(xxboot, xxbootlen, "%s%ssdboot", mdecpath, machpath);
magic = NBDAMAGIC;
}
- bootxx = alloca(strlen(mdecpath) + strlen(machpath) + 8);
- sprintf(bootxx, "%s%sbootxx", mdecpath, machpath);
+ size_t bootxxlen = strlen(mdecpath) + strlen(machpath) + 8;
+ bootxx = alloca(bootxxlen);
+ snprintf(bootxx, bootxxlen, "%s%sbootxx", mdecpath, machpath);
trackpercyl = secpertrack = 0;
if (xxb00t)
@@ -360,19 +366,22 @@ install_wd(char *devnm, struct disklabel
else
machpath = stdpath;
if (bbsec) {
- xxb00t = alloca(strlen(mdecpath) + strlen(machpath) + 14);
- sprintf(xxb00t, "%s%swdb00t.ahdi", mdecpath, machpath);
- xxboot = alloca(strlen(mdecpath) + strlen(machpath) + 14);
- sprintf(xxboot, "%s%sxxboot.ahdi", mdecpath, machpath);
+ size_t xxb00tlen = strlen(mdecpath) + strlen(machpath) + 14;
+ xxb00t = alloca(xxb00tlen);
+ snprintf(xxb00t, xxb00tlen, "%s%swdb00t.ahdi", mdecpath, machpath);
+ xnxboot = alloca(xxb00tlen);
+ snprintf(xxboot, xxb00tlen, "%s%sxxboot.ahdi", mdecpath, machpath);
magic = AHDIMAGIC;
} else {
+ size_t xxbootlen = strlen(mdecpath) + strlen(machpath) + 8;
xxb00t = NULL;
- xxboot = alloca(strlen(mdecpath) + strlen(machpath) + 8);
- sprintf(xxboot, "%s%swdboot", mdecpath, machpath);
+ xxboot = alloca(xxbootlen);
+ snprintf(xxboot, xxbootlen, "%s%swdboot", mdecpath, machpath);
magic = NBDAMAGIC;
}
- bootxx = alloca(strlen(mdecpath) + strlen(machpath) + 8);
- sprintf(bootxx, "%s%sbootxx", mdecpath, machpath);
+ size_t bootxxlen = strlen(mdecpath) + strlen(machpath) + 8;
+ bootxx = alloca(bootxxlen);
+ snprintf(bootxx, bootxxlen, "%s%sbootxx", mdecpath, machpath);
if (xxb00t)
mkahdiboot(&ahdiboot, xxb00t, devnm, bbsec);
Index: src/sys/arch/atari/stand/tostools/aptck/diskio.c
diff -u src/sys/arch/atari/stand/tostools/aptck/diskio.c:1.5 src/sys/arch/atari/stand/tostools/aptck/diskio.c:1.6
--- src/sys/arch/atari/stand/tostools/aptck/diskio.c:1.5 Wed Mar 18 06:22:26 2009
+++ src/sys/arch/atari/stand/tostools/aptck/diskio.c Wed Mar 26 14:04:34 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: diskio.c,v 1.5 2009/03/18 10:22:26 cegger Exp $ */
+/* $NetBSD: diskio.c,v 1.6 2014/03/26 18:04:34 christos Exp $ */
/*
* Copyright (c) 1995 Waldi Ravens.
@@ -237,18 +237,18 @@ setnames(disk_t *dd)
error(-1, "invalid %s target `%d'", bs, u);
return(-1);
}
- sprintf(us, " target %d", u);
+ snprintf(us, sizeof(us), " target %d", u);
if (l < 0 || l > 7 || (b == IDE && l > 0)) {
error(-1, "invalid %s lun `%d'", bs, l);
return(-1);
}
if (b == IDE) {
- sprintf(sn, "i%d", u);
+ snprintf(sn, sizeof(sn), "i%d", u);
ls[0] = '\0';
} else {
- sprintf(sn, "%c%d%d", tolower(*bs), u, l);
- sprintf(ls, " lun %d", l);
+ snprintf(sn, sizeof(sn), "%c%d%d", tolower(*bs), u, l);
+ snprintf(ls, sizeof(ls), " lun %d", l);
}
dd->fname = strbd(bs, us, ls, NULL);
Index: src/sys/arch/atari/stand/tostools/libtos/diskio.c
diff -u src/sys/arch/atari/stand/tostools/libtos/diskio.c:1.3 src/sys/arch/atari/stand/tostools/libtos/diskio.c:1.4
--- src/sys/arch/atari/stand/tostools/libtos/diskio.c:1.3 Wed Mar 18 06:22:26 2009
+++ src/sys/arch/atari/stand/tostools/libtos/diskio.c Wed Mar 26 14:04:34 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: diskio.c,v 1.3 2009/03/18 10:22:26 cegger Exp $ */
+/* $NetBSD: diskio.c,v 1.4 2014/03/26 18:04:34 christos Exp $ */
/*
* Copyright (c) 1995 Waldi Ravens.
@@ -237,18 +237,18 @@ setnames(disk_t *dd)
error(-1, "invalid %s target `%d'", bs, u);
return(-1);
}
- sprintf(us, " target %d", u);
+ snprintf(us, sizeof(us), " target %d", u);
if (l < 0 || l > 7 || (b == IDE && l > 0)) {
error(-1, "invalid %s lun `%d'", bs, l);
return(-1);
}
if (b == IDE) {
- sprintf(sn, "i%d", u);
+ snprintf(sn, sizeof(sn), "i%d", u);
ls[0] = '\0';
} else {
- sprintf(sn, "%c%d%d", tolower(*bs), u, l);
- sprintf(ls, " lun %d", l);
+ snprintf(sn, sizeof(sn), "%c%d%d", tolower(*bs), u, l);
+ snprintf(ls, sizeof(ls), " lun %d", l);
}
dd->fname = strbd(bs, us, ls, NULL);