From e7f804a55553d1dd3b0c5e23222088c471bae3df Mon Sep 17 00:00:00 2001
From: Toby Murray <toby.murray@unimelb.edu.au>
Date: Fri, 6 Sep 2019 22:30:30 +1000
Subject: [PATCH] tweaks trying to maximise coverage in fuzzer generated test
 corpus

---
 src/debug.h    | 12 ++++++++++++
 src/passbook.c |  8 ++++----
 2 files changed, 16 insertions(+), 4 deletions(-)
 create mode 100644 src/debug.h

diff --git a/src/debug.h b/src/debug.h
new file mode 100644
index 0000000..0092c0c
--- /dev/null
+++ b/src/debug.h
@@ -0,0 +1,12 @@
+#ifndef _DEBUG_H_
+#define _DEBUG_H_
+
+
+#ifndef NDEBUG
+#include <stdio.h>
+#define debug_printf(...) fprintf(stderr, __VA_ARGS__)
+#else
+#define debug_printf(...)
+#endif
+
+#endif
diff --git a/src/passbook.c b/src/passbook.c
index 64ca943..89af7fe 100644
--- a/src/passbook.c
+++ b/src/passbook.c
@@ -298,7 +298,7 @@ nodeptr_list_t list_dequeue(nodeptr_list_t lst, const node_t **out){
   }
 }
 
-
+#ifdef UNUSED_FUNCTIONS
 nodeptr_list_t list_destroy(nodeptr_list_t lst){
   while (lst.head != NULL){
     lst = list_pop(lst,NULL);
@@ -325,7 +325,7 @@ void list_print_rev(nodeptr_list_t lst){
   }
   printf("End list reverse print.\n\n");
 }
-
+#endif
 
 /* in order traversal to print out nodes in sorted order */
 void print_inorder(const node_t *p){
@@ -483,7 +483,7 @@ static int run(FILE *f){
     }
     if (inst[MAX_LINE_LENGTH] != '\0'){
       if (!(inst[MAX_LINE_LENGTH] == '\n' && inst[MAX_LINE_LENGTH+1] == '\0')){
-        debug_printf("Line %d exceeds maximum length (%d)\n",instructionCount+1,MAX_LINE_LENGTH);
+        fprintf(stderr,"Line %d exceeds maximum length (%d)\n",instructionCount+1,MAX_LINE_LENGTH);
         debug_printf("(Expected at array index %d to find NUL but found '%c' (%d))\n",MAX_LINE_LENGTH,inst[MAX_LINE_LENGTH],inst[MAX_LINE_LENGTH]);
         fclose(f);
         return -1;
@@ -518,7 +518,7 @@ static int run(FILE *f){
     char c;
     int res = fread(&c,1,1,f);
     if (res == 1){
-      debug_printf("Number of instructions (lines) in file exceeds max (%d)\n",MAX_INSTRUCTIONS);
+      fprintf(stderr,"Number of instructions (lines) in file exceeds max (%d)\n",MAX_INSTRUCTIONS);
       fclose(f);
       return -1;
     }else{
-- 
GitLab