Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/hpcmips - kill sprintf



details:   https://anonhg.NetBSD.org/src/rev/e4ef3ac18a5e
branches:  trunk
changeset: 328113:e4ef3ac18a5e
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Mar 26 17:53:36 2014 +0000

description:
- kill sprintf
- fix unused

diffstat:

 sys/arch/hpcmips/dev/mq200debug.c  |   8 ++++----
 sys/arch/hpcmips/dev/plumpcmcia.c  |   9 ++++-----
 sys/arch/hpcmips/hpcmips/machdep.c |  19 ++++++++++++++++---
 sys/arch/hpcmips/include/cpu.h     |   4 ++--
 sys/arch/hpcmips/tx/tx39.c         |  11 +++++------
 sys/arch/hpcmips/tx/tx39icu.c      |  10 +++++-----
 sys/arch/hpcmips/vr/vr.c           |   8 ++++----
 sys/arch/hpcmips/vr/vrpmu.c        |  10 ++++------
 8 files changed, 44 insertions(+), 35 deletions(-)

diffs (283 lines):

diff -r 9a3aedf5f9bd -r e4ef3ac18a5e sys/arch/hpcmips/dev/mq200debug.c
--- a/sys/arch/hpcmips/dev/mq200debug.c Wed Mar 26 17:41:15 2014 +0000
+++ b/sys/arch/hpcmips/dev/mq200debug.c Wed Mar 26 17:53:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mq200debug.c,v 1.5 2005/12/11 12:17:33 christos Exp $  */
+/*     $NetBSD: mq200debug.c,v 1.6 2014/03/26 17:53:36 christos Exp $  */
 
 /*-
  * Copyright (c) 2001 TAKEMURA Shin
@@ -31,7 +31,7 @@
 
 #ifdef _KERNEL
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mq200debug.c,v 1.5 2005/12/11 12:17:33 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mq200debug.c,v 1.6 2014/03/26 17:53:36 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -193,11 +193,11 @@
        for (i = 0; i < sizeof(regs)/sizeof(*regs); i++)
                if (regs[i].base + regs[i].start * 4 <= offset &&
                    offset <= regs[i].base + regs[i].end * 4) {
-                       sprintf(buf, "%s%02XR", regs[i].name,
+                       snprintf(buf, bufsize, "%s%02XR", regs[i].name,
                            (offset - regs[i].base) / 4);
                        return (buf);
                }
-       sprintf(buf, "OFFSET %02X", offset);
+       snprintf(buf, bufsize, "OFFSET %02X", offset);
        return (buf);
 }
 
diff -r 9a3aedf5f9bd -r e4ef3ac18a5e sys/arch/hpcmips/dev/plumpcmcia.c
--- a/sys/arch/hpcmips/dev/plumpcmcia.c Wed Mar 26 17:41:15 2014 +0000
+++ b/sys/arch/hpcmips/dev/plumpcmcia.c Wed Mar 26 17:53:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: plumpcmcia.c,v 1.26 2012/10/27 17:17:53 chs Exp $ */
+/*     $NetBSD: plumpcmcia.c,v 1.27 2014/03/26 17:53:36 christos Exp $ */
 
 /*
  * Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: plumpcmcia.c,v 1.26 2012/10/27 17:17:53 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plumpcmcia.c,v 1.27 2014/03/26 17:53:36 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -213,7 +213,7 @@
        struct plum_attach_args *pa = aux;
        struct plumpcmcia_softc *sc = device_private(self);
        struct plumpcmcia_handle *ph;
-       int error;
+       int error __diagused;
 
        sc->sc_dev = self;
        sc->sc_pc       = pa->pa_pc;
@@ -844,7 +844,6 @@
        bus_space_tag_t regt = ph->ph_regt;
        bus_space_handle_t regh = ph->ph_regh;
        plumreg_t reg;
-       void *ih;
        
        /* enable CARD DETECT ENABLE only */
        plum_conf_write(regt, regh, PLUM_PCMCIA_CSCINT,
@@ -856,7 +855,7 @@
        plum_conf_write(regt, regh, PLUM_PCMCIA_GLOBALCTRL, reg);
        
        /* install interrupt handler (don't fail) */
-       ih = plum_intr_establish(sc->sc_pc, irq, IST_EDGE, IPL_TTY,
+       plum_intr_establish(sc->sc_pc, irq, IST_EDGE, IPL_TTY,
            plum_csc_intr, ph);
        KASSERT(ih != 0);
 }
diff -r 9a3aedf5f9bd -r e4ef3ac18a5e sys/arch/hpcmips/hpcmips/machdep.c
--- a/sys/arch/hpcmips/hpcmips/machdep.c        Wed Mar 26 17:41:15 2014 +0000
+++ b/sys/arch/hpcmips/hpcmips/machdep.c        Wed Mar 26 17:53:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.118 2014/03/25 13:38:25 christos Exp $   */
+/*     $NetBSD: machdep.c,v 1.119 2014/03/26 17:53:36 christos Exp $   */
 
 /*-
  * Copyright (c) 1999 Shin Takemura, All rights reserved.
@@ -69,7 +69,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.118 2014/03/25 13:38:25 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.119 2014/03/26 17:53:36 christos Exp $");
 
 #include "opt_vr41xx.h"
 #include "opt_tx39xx.h"
@@ -152,7 +152,7 @@
 #endif
 
 /* the following is used externally (sysctl_hw) */
-char   hpcmips_cpuname[40];            /* set CPU depend xx_init() */
+static char    hpcmips_cpuname[40];            /* set CPU depend xx_init() */
 
 int    cpuspeed = 1;                   /* approx # instr per usec. */
 
@@ -458,6 +458,19 @@
        mips_init_lwp0_uarea();
 }
 
+int
+cpuname_printf(const char *fmt, ...)
+{
+       int len;
+       va_list ap;
+
+       va_start(ap, fmt);
+       len = vsnprintf(hpcmips_cpuname, sizeof(hpcmips_cpuname), fmt, ap);
+       va_end(ap);
+
+       return len;
+}
+
 /*
  * Machine-dependent startup code.
  * allocate memory for variable-sized tables, initialize CPU.
diff -r 9a3aedf5f9bd -r e4ef3ac18a5e sys/arch/hpcmips/include/cpu.h
--- a/sys/arch/hpcmips/include/cpu.h    Wed Mar 26 17:41:15 2014 +0000
+++ b/sys/arch/hpcmips/include/cpu.h    Wed Mar 26 17:53:36 2014 +0000
@@ -1,6 +1,6 @@
-/*     $NetBSD: cpu.h,v 1.13 2010/01/21 01:23:15 pooka Exp $   */
+/*     $NetBSD: cpu.h,v 1.14 2014/03/26 17:53:36 christos Exp $        */
 
 #include <mips/cpu.h>
 #ifndef _LOCORE
-extern char hpcmips_cpuname[];
+int cpuname_printf(const char *, ...) __printflike(1, 2);
 #endif
diff -r 9a3aedf5f9bd -r e4ef3ac18a5e sys/arch/hpcmips/tx/tx39.c
--- a/sys/arch/hpcmips/tx/tx39.c        Wed Mar 26 17:41:15 2014 +0000
+++ b/sys/arch/hpcmips/tx/tx39.c        Wed Mar 26 17:53:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tx39.c,v 1.44 2011/12/02 18:07:26 shattered Exp $ */
+/*     $NetBSD: tx39.c,v 1.45 2014/03/26 17:53:36 christos Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tx39.c,v 1.44 2011/12/02 18:07:26 shattered Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tx39.c,v 1.45 2014/03/26 17:53:36 christos Exp $");
 
 #include "opt_vr41xx.h"
 #include "opt_tx39xx.h"
@@ -120,13 +120,12 @@
        switch (model) {
        default:
                /* Unknown TOSHIBA TX39-series */
-               sprintf(hpcmips_cpuname,
-                   "Unknown TOSHIBA TX39-series %x", model);
+               cpuname_printf("Unknown TOSHIBA TX39-series %x", model);
                break;
        case TMPR3912:
                tx39clock_cpuspeed(&cpuclock, &cpuspeed);
 
-               sprintf(hpcmips_cpuname, "TOSHIBA TMPR3912 %d.%02d MHz",
+               cpuname_printf("TOSHIBA TMPR3912 %d.%02d MHz",
                    cpuclock / 1000000, (cpuclock % 1000000) / 10000);
                tc->tc_chipset = __TX391X;
                break;
@@ -134,7 +133,7 @@
                tx39clock_cpuspeed(&cpuclock, &cpuspeed);
                rev = tx_conf_read(tc, TX3922_REVISION_REG);
 
-               sprintf(hpcmips_cpuname, "TOSHIBA TMPR3922 rev. %x.%x "
+               cpuname_printf("TOSHIBA TMPR3922 rev. %x.%x "
                    "%d.%02d MHz", (rev >> 4) & 0xf, rev & 0xf, 
                    cpuclock / 1000000, (cpuclock % 1000000) / 10000);
                tc->tc_chipset = __TX392X;
diff -r 9a3aedf5f9bd -r e4ef3ac18a5e sys/arch/hpcmips/tx/tx39icu.c
--- a/sys/arch/hpcmips/tx/tx39icu.c     Wed Mar 26 17:41:15 2014 +0000
+++ b/sys/arch/hpcmips/tx/tx39icu.c     Wed Mar 26 17:53:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tx39icu.c,v 1.32 2012/10/27 17:17:54 chs Exp $ */
+/*     $NetBSD: tx39icu.c,v 1.33 2014/03/26 17:53:36 christos Exp $ */
 
 /*-
  * Copyright (c) 1999-2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tx39icu.c,v 1.32 2012/10/27 17:17:54 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tx39icu.c,v 1.33 2014/03/26 17:53:36 christos Exp $");
 
 #include "opt_vr41xx.h"
 #include "opt_tx39xx.h"
@@ -746,13 +746,13 @@
                                reg |= (1 << j);
                        }
                }
-               sprintf(msg, "%d high", i);
+               snprintf(msg, sizeof(msg), "%d high", i);
                dbg_bit_print_msg(reg, msg);
-               sprintf(msg, "%d status", i);
+               snprintf(msg, sizeof(msg), "%d status", i);
                dbg_bit_print_msg(sc->sc_regs[i], msg);
                ofs = TX39_INTRENABLE_REG(i);
                reg = tx_conf_read(tc, ofs);
-               sprintf(msg, "%d enable", i);
+               snprintf(msg, sizeof(msg), "%d enable", i);
                dbg_bit_print_msg(reg, msg);
        }
        reg = sc->sc_regs[0];
diff -r 9a3aedf5f9bd -r e4ef3ac18a5e sys/arch/hpcmips/vr/vr.c
--- a/sys/arch/hpcmips/vr/vr.c  Wed Mar 26 17:41:15 2014 +0000
+++ b/sys/arch/hpcmips/vr/vr.c  Wed Mar 26 17:53:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vr.c,v 1.64 2011/03/18 15:31:38 tsutsui Exp $  */
+/*     $NetBSD: vr.c,v 1.65 2014/03/26 17:53:36 christos Exp $ */
 
 /*-
  * Copyright (c) 1999-2002
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vr.c,v 1.64 2011/03/18 15:31:38 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vr.c,v 1.65 2014/03/26 17:53:36 christos Exp $");
 
 #include "opt_vr41xx.h"
 #include "opt_tx39xx.h"
@@ -303,14 +303,14 @@
        platform.reboot         = vr_reboot;
 
 #if NVRBCU > 0
-       sprintf(hpcmips_cpuname, "NEC %s rev%d.%d %d.%03dMHz", 
+       cpuname_printf("NEC %s rev%d.%d %d.%03dMHz", 
                vrbcu_vrip_getcpuname(),
                vrbcu_vrip_getcpumajor(),
                vrbcu_vrip_getcpuminor(),
                vrbcu_vrip_getcpuclock() / 1000000,
                (vrbcu_vrip_getcpuclock() % 1000000) / 1000);
 #else
-       sprintf(hpcmips_cpuname, "NEC VR41xx");
+       cpuname_printf("NEC VR41xx");
 #endif
 }
 
diff -r 9a3aedf5f9bd -r e4ef3ac18a5e sys/arch/hpcmips/vr/vrpmu.c
--- a/sys/arch/hpcmips/vr/vrpmu.c       Wed Mar 26 17:41:15 2014 +0000
+++ b/sys/arch/hpcmips/vr/vrpmu.c       Wed Mar 26 17:53:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vrpmu.c,v 1.19 2012/10/27 17:17:56 chs Exp $   */
+/*     $NetBSD: vrpmu.c,v 1.20 2014/03/26 17:53:36 christos Exp $      */
 
 /*
  * Copyright (c) 1999 M. Warner Losh.  All rights reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vrpmu.c,v 1.19 2012/10/27 17:17:56 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vrpmu.c,v 1.20 2014/03/26 17:53:36 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -219,14 +219,12 @@
 vrpmu_dump_regs(void *arg)
 {
         struct vrpmu_softc *sc = arg;
-       unsigned int intstat1;
-       unsigned int intstat2;
        unsigned int reg;
 #if NVRBCU > 0
        int cpuid;
 #endif
-       intstat1 = vrpmu_read(sc, PMUINT_REG_W);
-       intstat2 = vrpmu_read(sc, PMUINT2_REG_W);
+       reg = vrpmu_read(sc, PMUINT_REG_W);
+       reg = vrpmu_read(sc, PMUINT2_REG_W);
 
        /* others? XXXX */
        reg = vrpmu_read(sc, PMUCNT_REG_W);



Home | Main Index | Thread Index | Old Index