memdisk: Make debug-mode a tad prettier
authorShao Miller <shao.miller@yrdsb.edu.on.ca>
Tue, 25 Jan 2011 02:47:43 +0000 (21:47 -0500)
committerShao Miller <shao.miller@yrdsb.edu.on.ca>
Tue, 25 Jan 2011 02:48:04 +0000 (21:48 -0500)
By removing the use of #ifdef-#endif blocks.

Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
memdisk/dskprobe.c

index de858bb..5c9d601 100644 (file)
  * 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;
+}