From bc06fce990b5bb8559d37eb2d2a7aa8c69ca024b Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 19 Nov 2009 16:52:11 -0800 Subject: [PATCH] dprintf: fix uninitialized pointer; return void Fix an uninitialized pointer bug; return void rather than returning int like normal printfs... if we're depending on the return value of a debugging function we're screwed when debugging is disabled. Signed-off-by: H. Peter Anvin --- com32/include/dprintf.h | 4 ++-- com32/lib/dprintf.c | 6 ++---- com32/lib/vdprintf.c | 11 +++++------ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/com32/include/dprintf.h b/com32/include/dprintf.h index 4c9682c..30a21ad 100644 --- a/com32/include/dprintf.h +++ b/com32/include/dprintf.h @@ -9,8 +9,8 @@ #include -int dprintf(const char *, ...); -int vdprintf(const char *, va_list); +void dprintf(const char *, ...); +void vdprintf(const char *, va_list); #else diff --git a/com32/lib/dprintf.c b/com32/lib/dprintf.c index ab431d8..900c0a4 100644 --- a/com32/lib/dprintf.c +++ b/com32/lib/dprintf.c @@ -9,13 +9,11 @@ #define DEBUG 1 #include -int dprintf(const char *format, ...) +void dprintf(const char *format, ...) { va_list ap; - int rv; va_start(ap, format); - rv = vdprintf(format, ap); + vdprintf(format, ap); va_end(ap); - return rv; } diff --git a/com32/lib/vdprintf.c b/com32/lib/vdprintf.c index 869296e..ea9e048 100644 --- a/com32/lib/vdprintf.c +++ b/com32/lib/vdprintf.c @@ -8,6 +8,7 @@ #include #include #include +#include #undef DEBUG #define DEBUG 1 @@ -15,12 +16,9 @@ #define BUFFER_SIZE 32768 -struct file_info; -extern ssize_t __serial_write(struct file_info *, const void *, size_t); - static const uint16_t debug_base = 0x03f8; /* I/O base address */ -int vdprintf(const char *format, va_list ap) +void vdprintf(const char *format, va_list ap) { int rv; char buffer[BUFFER_SIZE]; @@ -29,7 +27,7 @@ int vdprintf(const char *format, va_list ap) rv = vsnprintf(buffer, BUFFER_SIZE, format, ap); if (rv < 0) - return rv; + return; if (rv > BUFFER_SIZE - 1) rv = BUFFER_SIZE - 1; @@ -39,9 +37,10 @@ int vdprintf(const char *format, va_list ap) * if one is enabled or not (this means we don't have to enable the real * serial console and therefore get conflicting output.) */ + p = buffer; while (rv--) { while ((inb(debug_base+5) & 0x20) == 0) - ; + cpu_relax(); outb(*p++, debug_base); } } -- 2.7.4