diff options
author | H. Peter Anvin <hpa@zytor.com> | 2012-07-19 08:42:32 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2012-07-19 08:42:32 -0700 |
commit | ff7334a2ce536b7f4b1f6d6f93ff4e285a3bd45a (patch) | |
tree | 40598b8f0f09fbc6ddc9e6e22802ba400528e300 | |
parent | 7cc3ba019aee913d09e7bf0b6711da2e1f6b2db4 (diff) | |
download | syslinux-ff7334a2ce536b7f4b1f6d6f93ff4e285a3bd45a.tar.gz syslinux-ff7334a2ce536b7f4b1f6d6f93ff4e285a3bd45a.tar.xz syslinux-ff7334a2ce536b7f4b1f6d6f93ff4e285a3bd45a.zip |
Only compile dprintf/vdprintf if DEBUG_PORT is defined
We really, really don't want to accidentally spew output to a debug
port in production, so make it obligatory to define DEBUG_PORT or
DEBUG_STDIO in order for the debugging code to be compiled in. Since
DEBUG_STDIO just turns the debugging code into stdio references, we
only need to compile the code for the DEBUG_PORT case.
Add a commented-out line to mk/devel.mk to make it easier for users.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Matt Fleming <matt.fleming@intel.com>
-rw-r--r-- | com32/include/dprintf.h | 4 | ||||
-rw-r--r-- | com32/lib/dprintf.c | 4 | ||||
-rw-r--r-- | com32/lib/vdprintf.c | 8 | ||||
-rw-r--r-- | mk/devel.mk | 1 |
4 files changed, 13 insertions, 4 deletions
diff --git a/com32/include/dprintf.h b/com32/include/dprintf.h index b8a3b84c..26ca734b 100644 --- a/com32/include/dprintf.h +++ b/com32/include/dprintf.h @@ -5,6 +5,10 @@ #ifndef _DPRINTF_H #define _DPRINTF_H +#if !defined(DEBUG_PORT) && !defined(DEBUG_STDIO) +# undef DEBUG +#endif + #ifdef DEBUG # include <stdio.h> diff --git a/com32/lib/dprintf.c b/com32/lib/dprintf.c index d22dae95..dea77b39 100644 --- a/com32/lib/dprintf.c +++ b/com32/lib/dprintf.c @@ -5,6 +5,8 @@ #include <stdio.h> #include <stdarg.h> +#ifdef DEBUG_PORT + void vdprintf(const char *, va_list); void dprintf(const char *format, ...) @@ -15,3 +17,5 @@ void dprintf(const char *format, ...) vdprintf(format, ap); va_end(ap); } + +#endif /* DEBUG_PORT */ diff --git a/com32/lib/vdprintf.c b/com32/lib/vdprintf.c index db602959..bcf55bb7 100644 --- a/com32/lib/vdprintf.c +++ b/com32/lib/vdprintf.c @@ -10,6 +10,8 @@ #include <sys/io.h> #include <sys/cpu.h> +#ifdef DEBUG_PORT + #define BUFFER_SIZE 4096 enum serial_port_regs { @@ -27,10 +29,6 @@ enum serial_port_regs { SCR = 7, }; -#ifndef DEBUG_PORT -# define DEBUG_PORT 0x03f8 /* I/O base address */ -#endif - static const uint16_t debug_base = DEBUG_PORT; static void debug_putc(char c) @@ -109,3 +107,5 @@ void vdprintf(const char *format, va_list ap) while (rv--) debug_putc(*p++); } + +#endif /* DEBUG_PORT */ diff --git a/mk/devel.mk b/mk/devel.mk index c05d76e8..8184c30f 100644 --- a/mk/devel.mk +++ b/mk/devel.mk @@ -1,2 +1,3 @@ # Useful while doing development, but not for production. GCCWARN += -Wno-clobbered +# GCCWARN += -DDEBUG_PORT=0x3f8 -DDEBUG=1 |