[syslinux:elflink] Only compile dprintf/ vdprintf if DEBUG_PORT is defined

syslinux-bot for H. Peter Anvin hpa at zytor.com
Thu Jul 19 08:48:05 PDT 2012


Commit-ID:  ff7334a2ce536b7f4b1f6d6f93ff4e285a3bd45a
Gitweb:     http://www.syslinux.org/commit/ff7334a2ce536b7f4b1f6d6f93ff4e285a3bd45a
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Thu, 19 Jul 2012 08:42:32 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Thu, 19 Jul 2012 08:42:32 -0700

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 at zytor.com>
Cc: Matt Fleming <matt.fleming at intel.com>

---
 com32/include/dprintf.h |    4 ++++
 com32/lib/dprintf.c     |    4 ++++
 com32/lib/vdprintf.c    |    8 ++++----
 mk/devel.mk             |    1 +
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/com32/include/dprintf.h b/com32/include/dprintf.h
index b8a3b84..26ca734 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 d22dae9..dea77b3 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 db60295..bcf55bb 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 c05d76e..8184c30 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 


More information about the Syslinux-commits mailing list