[syslinux:master] memdisk: Make debug-mode a tad prettier

syslinux-bot for Shao Miller shao.miller at yrdsb.edu.on.ca
Tue Jan 25 17:00:02 PST 2011


Commit-ID:  13101c28a48c226bdb25b27278014e84ee9f0874
Gitweb:     http://syslinux.zytor.com/commit/13101c28a48c226bdb25b27278014e84ee9f0874
Author:     Shao Miller <shao.miller at yrdsb.edu.on.ca>
AuthorDate: Mon, 24 Jan 2011 21:47:43 -0500
Committer:  Shao Miller <shao.miller at yrdsb.edu.on.ca>
CommitDate: Mon, 24 Jan 2011 21:48:04 -0500

memdisk: Make debug-mode a tad prettier

By removing the use of #ifdef-#endif blocks.

Signed-off-by: Shao Miller <shao.miller at yrdsb.edu.on.ca>


---
 memdisk/dskprobe.c |   34 ++++++++++++++++++++++------------
 1 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/memdisk/dskprobe.c b/memdisk/dskprobe.c
index de858bb..5c9d601 100644
--- a/memdisk/dskprobe.c
+++ b/memdisk/dskprobe.c
@@ -16,17 +16,23 @@
  * Routines for probing BIOS disk drives
  */
 
-/*
- * Uncomment for debugging
- *
- * #define DBG_DSKPROBE 1
- */
+/* Change to 1 for debugging */
+#define DBG_DSKPROBE 0
 
 #include <stdint.h>
 #include "memdisk.h"
 #include "bda.h"
 #include "conio.h"
 
+/* Function type for printf() */
+typedef int (f_printf) (const char *, ...);
+
+/* Dummy printf() that does nothing */
+static f_printf no_printf;
+static f_printf *dskprobe_printfs[] = { no_printf, printf };
+
+#define dskprobe_printf (dskprobe_printfs[DBG_DSKPROBE])
+
 /*
  * We will probe a BIOS drive numer using INT 13h, AH=probe
  * and will pass along that call's success or failure
@@ -43,9 +49,8 @@ int probe_int13_ah(uint8_t drive, uint8_t probe)
     intcall(0x13, &regs, &regs);
 
     err = !(regs.eflags.l & 1);
-#ifdef DBG_DSKPROBE
-    printf("probe_int13_ah(0x%02x, 0x%02x) == %d\n", drive, probe, err);
-#endif
+    dskprobe_printf("probe_int13_ah(0x%02x, 0x%02x) == %d\n", drive, probe,
+		    err);
     return err;
 }
 
@@ -72,10 +77,8 @@ int probe_bda_drive(uint8_t drive)
 	    bios_drives = 0;
     }
     err = (drive - (drive & 0x80)) >= bios_drives ? 0 : 1;
-#ifdef DBG_DSKPROBE
-    printf("probe_bda_drive(0x%02x) == %d, count: %d\n",
-	   drive, err, bios_drives);
-#endif
+    dskprobe_printf("probe_bda_drive(0x%02x) == %d, count: %d\n", drive, err,
+		    bios_drives);
     return err;
 }
 
@@ -112,3 +115,10 @@ uint8_t probe_drive_range(uint8_t start)
     }
     return drive;
 }
+
+/* Dummy printf() that does nothing */
+static int no_printf(const char *ignored, ...)
+{
+    (void)ignored;
+    return 0;
+}



More information about the Syslinux-commits mailing list