Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/m68k/m68k procfs_getcpuinfstr's len argument contai...



details:   https://anonhg.NetBSD.org/src/rev/bfc1bbb4472d
branches:  trunk
changeset: 328193:bfc1bbb4472d
user:      apb <apb%NetBSD.org@localhost>
date:      Sat Mar 29 11:34:13 2014 +0000

description:
procfs_getcpuinfstr's len argument contains the buffer size on entry,
and the number of bytes used on return.  Use the actual buffer size in a
snprintf call, instead of sizeof(*buf), which is always 1.

diffstat:

 sys/arch/m68k/m68k/procfs_machdep.c |  9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diffs (32 lines):

diff -r 580011f26a7c -r bfc1bbb4472d sys/arch/m68k/m68k/procfs_machdep.c
--- a/sys/arch/m68k/m68k/procfs_machdep.c       Sat Mar 29 09:36:18 2014 +0000
+++ b/sys/arch/m68k/m68k/procfs_machdep.c       Sat Mar 29 11:34:13 2014 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: procfs_machdep.c,v 1.5 2006/07/22 06:58:17 tsutsui Exp $ */
+/*     $NetBSD: procfs_machdep.c,v 1.6 2014/03/29 11:34:13 apb Exp $ */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.5 2006/07/22 06:58:17 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.6 2014/03/29 11:34:13 apb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -19,8 +19,7 @@
 procfs_getcpuinfstr(char *buf, int *len)
 {
        const char *cpu, *mmu, *fpu;
-
-       *len = 0;
+       int maxlen = *len;
 
        switch (cputype) {
        case CPU_68020:
@@ -79,7 +78,7 @@
                break;
        }
 
-       *len = snprintf(buf, sizeof(buf),
+       *len = snprintf(buf, maxlen,
            /* as seen in Linux 2.4.27 */
            "CPU:\t\t%s\n"
            "MMU:\t\t%s\n"



Home | Main Index | Thread Index | Old Index