Source-Changes-HG archive

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

[src/trunk]: src/sys/kern - fixed signed/unsigned comparison



details:   https://anonhg.NetBSD.org/src/rev/d0620ec53dc9
branches:  trunk
changeset: 771515:d0620ec53dc9
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 24 01:45:39 2011 +0000

description:
- fixed signed/unsigned comparison
- don't write/increment sbuf if NULL

diffstat:

 sys/kern/subr_prf.c |  10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diffs (39 lines):

diff -r 28a9f0c6e529 -r d0620ec53dc9 sys/kern/subr_prf.c
--- a/sys/kern/subr_prf.c       Thu Nov 24 01:14:19 2011 +0000
+++ b/sys/kern/subr_prf.c       Thu Nov 24 01:45:39 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_prf.c,v 1.147 2011/11/24 01:14:19 christos Exp $  */
+/*     $NetBSD: subr_prf.c,v 1.148 2011/11/24 01:45:39 christos Exp $  */
 
 /*-
  * Copyright (c) 1986, 1988, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.147 2011/11/24 01:14:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_prf.c,v 1.148 2011/11/24 01:45:39 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_ipkdb.h"
@@ -1079,7 +1079,7 @@
        retval = kprintf(fmt, TOBUFONLY, &p, bf, ap);
        if (bf && size > 0) {
                /* nul terminate */
-               if (size <= retval)
+               if (size <= (size_t)retval)
                        bf[size - 1] = '\0';
                else
                        bf[retval] = '\0';
@@ -1142,10 +1142,8 @@
 
 #define KPRINTF_PUTCHAR(C) {                                           \
        if (oflags == TOBUFONLY) {                                      \
-               if ((vp == NULL) || (sbuf < tailp))                     \
+               if (sbuf && ((vp == NULL) || (sbuf < tailp)))           \
                        *sbuf++ = (C);                                  \
-               else                                                    \
-                       sbuf++;                                         \
        } else {                                                        \
                putchar((C), oflags, vp);                               \
        }                                                               \



Home | Main Index | Thread Index | Old Index