dprintf: fix uninitialized pointer; return void
authorH. Peter Anvin <hpa@zytor.com>
Fri, 20 Nov 2009 00:52:11 +0000 (16:52 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Fri, 20 Nov 2009 00:52:11 +0000 (16:52 -0800)
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 <hpa@zytor.com>
com32/include/dprintf.h
com32/lib/dprintf.c
com32/lib/vdprintf.c

index 4c9682c..30a21ad 100644 (file)
@@ -9,8 +9,8 @@
 
 #include <stdio.h>
 
-int dprintf(const char *, ...);
-int vdprintf(const char *, va_list);
+void dprintf(const char *, ...);
+void vdprintf(const char *, va_list);
 
 #else
 
index ab431d8..900c0a4 100644 (file)
@@ -9,13 +9,11 @@
 #define DEBUG 1
 #include <dprintf.h>
 
-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;
 }
index 869296e..ea9e048 100644 (file)
@@ -8,6 +8,7 @@
 #include <unistd.h>
 #include <inttypes.h>
 #include <sys/io.h>
+#include <sys/cpu.h>
 
 #undef DEBUG
 #define DEBUG 1
 
 #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);
     }
 }