Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/atari kill sprintf



details:   https://anonhg.NetBSD.org/src/rev/fb92c6066a87
branches:  trunk
changeset: 328118:fb92c6066a87
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 26 18:04:33 2014 +0000

description:
kill sprintf

diffstat:

 sys/arch/atari/atari/machdep.c                 |   6 +-
 sys/arch/atari/dev/clock.c                     |   6 +-
 sys/arch/atari/dev/ite.c                       |   6 +-
 sys/arch/atari/pci/pci_machdep.c               |   6 +-
 sys/arch/atari/stand/ahdilabel/ahdilabel.c     |  14 +++---
 sys/arch/atari/stand/installboot/installboot.c |  59 ++++++++++++++-----------
 sys/arch/atari/stand/tostools/aptck/diskio.c   |  10 ++--
 sys/arch/atari/stand/tostools/libtos/diskio.c  |  10 ++--
 8 files changed, 63 insertions(+), 54 deletions(-)

diffs (truncated from 343 to 300 lines):

diff -r 656466ab59fc -r fb92c6066a87 sys/arch/atari/atari/machdep.c
--- a/sys/arch/atari/atari/machdep.c    Wed Mar 26 18:03:47 2014 +0000
+++ b/sys/arch/atari/atari/machdep.c    Wed Mar 26 18:04:33 2014 +0000
@@ -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 @@
 
                        __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";
diff -r 656466ab59fc -r fb92c6066a87 sys/arch/atari/dev/clock.c
--- a/sys/arch/atari/dev/clock.c        Wed Mar 26 18:03:47 2014 +0000
+++ b/sys/arch/atari/dev/clock.c        Wed Mar 26 18:04:33 2014 +0000
@@ -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 @@
        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]);
diff -r 656466ab59fc -r fb92c6066a87 sys/arch/atari/dev/ite.c
--- a/sys/arch/atari/dev/ite.c  Wed Mar 26 18:03:47 2014 +0000
+++ b/sys/arch/atari/dev/ite.c  Wed Mar 26 18:04:33 2014 +0000
@@ -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 @@
                        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;
diff -r 656466ab59fc -r fb92c6066a87 sys/arch/atari/pci/pci_machdep.c
--- a/sys/arch/atari/pci/pci_machdep.c  Wed Mar 26 18:03:47 2014 +0000
+++ b/sys/arch/atari/pci/pci_machdep.c  Wed Mar 26 18:04:33 2014 +0000
@@ -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 @@
        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;
        
 }
diff -r 656466ab59fc -r fb92c6066a87 sys/arch/atari/stand/ahdilabel/ahdilabel.c
--- a/sys/arch/atari/stand/ahdilabel/ahdilabel.c        Wed Mar 26 18:03:47 2014 +0000
+++ b/sys/arch/atari/stand/ahdilabel/ahdilabel.c        Wed Mar 26 18:04:33 2014 +0000
@@ -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 @@
 }
 
 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 @@
        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 @@
        }
 
        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);
diff -r 656466ab59fc -r fb92c6066a87 sys/arch/atari/stand/installboot/installboot.c
--- a/sys/arch/atari/stand/installboot/installboot.c    Wed Mar 26 18:03:47 2014 +0000
+++ b/sys/arch/atari/stand/installboot/installboot.c    Wed Mar 26 18:04:33 2014 +0000
@@ -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 @@
                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 @@
                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 @@
        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 @@
        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);
diff -r 656466ab59fc -r fb92c6066a87 sys/arch/atari/stand/tostools/aptck/diskio.c
--- a/sys/arch/atari/stand/tostools/aptck/diskio.c      Wed Mar 26 18:03:47 2014 +0000
+++ b/sys/arch/atari/stand/tostools/aptck/diskio.c      Wed Mar 26 18:04:33 2014 +0000
@@ -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 @@
                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) {



Home | Main Index | Thread Index | Old Index