]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
enum: don't printf on util-enum errors 3044/head
authorDanny Browning <danny.browning@protectwise.com>
Fri, 1 Dec 2017 18:23:30 +0000 (11:23 -0700)
committerVictor Julien <victor@inliniac.net>
Mon, 4 Dec 2017 09:30:07 +0000 (10:30 +0100)
When util-enum encounters an error around enum value it should log the error
rather than losing it to console with printf.

Bug #2268

src/util-enum.c

index 97ee86f9b8e1e4d380e0c55c73dd32964bef919b..f6c32910506e769fe77586e0d15d5cbc60994073 100644 (file)
@@ -25,6 +25,7 @@
 #include <string.h>
 
 #include "util-enum.h"
+#include "util-debug.h"
 
 /**
  * \brief Maps a string name to an enum value from the supplied table.  Please
@@ -42,7 +43,7 @@ int SCMapEnumNameToValue(const char *enum_name, SCEnumCharMap *table)
     int result = -1;
 
     if (enum_name == NULL || table == NULL) {
-        printf("Invalid argument(s) passed into SCMapEnumNameToValue\n");
+        SCLogDebug("Invalid argument(s) passed into SCMapEnumNameToValue");
         return -1;
     }
 
@@ -68,7 +69,7 @@ int SCMapEnumNameToValue(const char *enum_name, SCEnumCharMap *table)
 const char * SCMapEnumValueToName(int enum_value, SCEnumCharMap *table)
 {
     if (table == NULL) {
-        printf("Invalid argument(s) passed into SCMapEnumValueToName\n");
+        SCLogDebug("Invalid argument(s) passed into SCMapEnumValueToName");
         return NULL;
     }
 
@@ -78,7 +79,7 @@ const char * SCMapEnumValueToName(int enum_value, SCEnumCharMap *table)
         }
     }
 
-    printf("A enum by the value %d doesn't exist in this table\n", enum_value);
+    SCLogDebug("A enum by the value %d doesn't exist in this table", enum_value);
 
     return NULL;
 }