summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-11-19 16:52:11 -0800
committerH. Peter Anvin <hpa@zytor.com>2009-11-19 16:52:11 -0800
commitbc06fce990b5bb8559d37eb2d2a7aa8c69ca024b (patch)
tree95687475bd42e11a1db3832971969abc33c70705
parent8b5bef3b13cf05f4e661370ee353a4a86c00ea11 (diff)
downloadsyslinux-bc06fce990b5bb8559d37eb2d2a7aa8c69ca024b.tar.gz
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 <hpa@zytor.com>
-rw-r--r--com32/include/dprintf.h4
-rw-r--r--com32/lib/dprintf.c6
-rw-r--r--com32/lib/vdprintf.c11
3 files changed, 9 insertions, 12 deletions
diff --git a/com32/include/dprintf.h b/com32/include/dprintf.h
index 4c9682c0..30a21ada 100644
--- a/com32/include/dprintf.h
+++ b/com32/include/dprintf.h
@@ -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
diff --git a/com32/lib/dprintf.c b/com32/lib/dprintf.c
index ab431d8a..900c0a47 100644
--- a/com32/lib/dprintf.c
+++ b/com32/lib/dprintf.c
@@ -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;
}
diff --git a/com32/lib/vdprintf.c b/com32/lib/vdprintf.c
index 869296ef..ea9e0488 100644
--- a/com32/lib/vdprintf.c
+++ b/com32/lib/vdprintf.c
@@ -8,6 +8,7 @@
#include <unistd.h>
#include <inttypes.h>
#include <sys/io.h>
+#include <sys/cpu.h>
#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);
}
}