]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output: get rid of BUG_ONs
authorVictor Julien <victor@inliniac.net>
Thu, 30 May 2019 08:24:10 +0000 (10:24 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 30 May 2019 08:24:10 +0000 (10:24 +0200)
src/output-file.c
src/output-filedata.c
src/output-flow.c
src/output-packet.c
src/output-stats.c
src/output-streaming.c
src/output-tx.c

index fdded0572e9d5387012ce7113c3a43f951718e3d..22137bb30b90c6dd6899a04b6f67915ab92539f7 100644 (file)
@@ -124,7 +124,7 @@ static void OutputFileLogFfc(ThreadVars *tv,
                 const OutputFileLogger *logger = list;
                 const OutputLoggerThreadStore *store = op_thread_data->store;
                 while (logger && store) {
-                    BUG_ON(logger->LogFunc == NULL);
+                    DEBUG_VALIDATE_BUG_ON(logger->LogFunc == NULL);
 
                     SCLogDebug("logger %p", logger);
                     PACKET_PROFILING_LOGGER_START(p, logger->logger_id);
@@ -135,8 +135,8 @@ static void OutputFileLogFfc(ThreadVars *tv,
                     logger = logger->next;
                     store = store->next;
 
-                    BUG_ON(logger == NULL && store != NULL);
-                    BUG_ON(logger != NULL && store == NULL);
+                    DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+                    DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
                 }
 
                 if (file_logged) {
index 0502c62a78367e3f289668bfc17b9fcac42333cc..acc1e6a980cf81d193eea3bb0b60f02b6847e35a 100644 (file)
@@ -32,6 +32,7 @@
 #include "detect-filemagic.h"
 #include "conf.h"
 #include "util-profiling.h"
+#include "util-validate.h"
 
 typedef struct OutputLoggerThreadStore_ {
     void *thread_data;
@@ -106,7 +107,7 @@ static int CallLoggers(ThreadVars *tv, OutputLoggerThreadStore *store_list,
     int file_logged = 0;
 
     while (logger && store) {
-        BUG_ON(logger->LogFunc == NULL);
+        DEBUG_VALIDATE_BUG_ON(logger->LogFunc == NULL);
 
         SCLogDebug("logger %p", logger);
         PACKET_PROFILING_LOGGER_START(p, logger->logger_id);
@@ -118,8 +119,8 @@ static int CallLoggers(ThreadVars *tv, OutputLoggerThreadStore *store_list,
         logger = logger->next;
         store = store->next;
 
-        BUG_ON(logger == NULL && store != NULL);
-        BUG_ON(logger != NULL && store == NULL);
+        DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+        DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
     }
     return file_logged;
 }
@@ -206,7 +207,7 @@ static void OutputFiledataLogFfc(ThreadVars *tv, OutputLoggerThreadStore *store,
 
 static TmEcode OutputFiledataLog(ThreadVars *tv, Packet *p, void *thread_data)
 {
-    BUG_ON(thread_data == NULL);
+    DEBUG_VALIDATE_BUG_ON(thread_data == NULL);
 
     if (list == NULL) {
         /* No child loggers. */
index 9552a86075d3a001420a56fe6a14cbea44072600..a30f99282e3cb07cd4895eaca7d8f041fba995ba 100644 (file)
@@ -27,6 +27,7 @@
 #include "tm-modules.h"
 #include "output-flow.h"
 #include "util-profiling.h"
+#include "util-validate.h"
 
 typedef struct OutputLoggerThreadStore_ {
     void *thread_data;
@@ -89,7 +90,7 @@ int OutputRegisterFlowLogger(const char *name, FlowLogger LogFunc,
  */
 TmEcode OutputFlowLog(ThreadVars *tv, void *thread_data, Flow *f)
 {
-    BUG_ON(thread_data == NULL);
+    DEBUG_VALIDATE_BUG_ON(thread_data == NULL);
 
     if (list == NULL)
         return TM_ECODE_OK;
@@ -98,14 +99,14 @@ TmEcode OutputFlowLog(ThreadVars *tv, void *thread_data, Flow *f)
     OutputFlowLogger *logger = list;
     OutputLoggerThreadStore *store = op_thread_data->store;
 
-    BUG_ON(logger == NULL && store != NULL);
-    BUG_ON(logger != NULL && store == NULL);
-    BUG_ON(logger == NULL && store == NULL);
+    DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+    DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
+    DEBUG_VALIDATE_BUG_ON(logger == NULL && store == NULL);
 
     logger = list;
     store = op_thread_data->store;
     while (logger && store) {
-        BUG_ON(logger->LogFunc == NULL);
+        DEBUG_VALIDATE_BUG_ON(logger->LogFunc == NULL);
 
         SCLogDebug("logger %p", logger);
         //PACKET_PROFILING_LOGGER_START(p, logger->module_id);
@@ -115,8 +116,8 @@ TmEcode OutputFlowLog(ThreadVars *tv, void *thread_data, Flow *f)
         logger = logger->next;
         store = store->next;
 
-        BUG_ON(logger == NULL && store != NULL);
-        BUG_ON(logger != NULL && store == NULL);
+        DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+        DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
     }
 
     return TM_ECODE_OK;
index 2d5d302786ef1c43a8b15c42a767496025cbff3e..45de33b1a13f69a1eace21195b4559f42f78cc19 100644 (file)
@@ -28,6 +28,7 @@
 #include "output.h"
 #include "output-packet.h"
 #include "util-profiling.h"
+#include "util-validate.h"
 
 typedef struct OutputLoggerThreadStore_ {
     void *thread_data;
@@ -92,7 +93,7 @@ int OutputRegisterPacketLogger(LoggerId logger_id, const char *name,
 
 static TmEcode OutputPacketLog(ThreadVars *tv, Packet *p, void *thread_data)
 {
-    BUG_ON(thread_data == NULL);
+    DEBUG_VALIDATE_BUG_ON(thread_data == NULL);
 
     if (list == NULL) {
         /* No child loggers. */
@@ -103,12 +104,12 @@ static TmEcode OutputPacketLog(ThreadVars *tv, Packet *p, void *thread_data)
     OutputPacketLogger *logger = list;
     OutputLoggerThreadStore *store = op_thread_data->store;
 
-    BUG_ON(logger == NULL && store != NULL);
-    BUG_ON(logger != NULL && store == NULL);
-    BUG_ON(logger == NULL && store == NULL);
+    DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+    DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
+    DEBUG_VALIDATE_BUG_ON(logger == NULL && store == NULL);
 
     while (logger && store) {
-        BUG_ON(logger->LogFunc == NULL || logger->ConditionFunc == NULL);
+        DEBUG_VALIDATE_BUG_ON(logger->LogFunc == NULL || logger->ConditionFunc == NULL);
 
         if ((logger->ConditionFunc(tv, (const Packet *)p)) == TRUE) {
             PACKET_PROFILING_LOGGER_START(p, logger->logger_id);
@@ -119,8 +120,8 @@ static TmEcode OutputPacketLog(ThreadVars *tv, Packet *p, void *thread_data)
         logger = logger->next;
         store = store->next;
 
-        BUG_ON(logger == NULL && store != NULL);
-        BUG_ON(logger != NULL && store == NULL);
+        DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+        DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
     }
 
     return TM_ECODE_OK;
index 58c457097814e4855730e767f31ac71b0e098c4e..d04f1b22b72bd828566fedf2a21349087f1801ac 100644 (file)
@@ -26,6 +26,7 @@
 #include "suricata-common.h"
 #include "tm-modules.h"
 #include "output-stats.h"
+#include "util-validate.h"
 
 typedef struct OutputLoggerThreadStore_ {
     void *thread_data;
@@ -85,29 +86,27 @@ int OutputRegisterStatsLogger(const char *name, StatsLogger LogFunc,
 
 TmEcode OutputStatsLog(ThreadVars *tv, void *thread_data, StatsTable *st)
 {
-    BUG_ON(thread_data == NULL);
-    BUG_ON(list == NULL);
+    DEBUG_VALIDATE_BUG_ON(thread_data == NULL);
+    DEBUG_VALIDATE_BUG_ON(list == NULL);
 
     OutputLoggerThreadData *op_thread_data = (OutputLoggerThreadData *)thread_data;
     OutputStatsLogger *logger = list;
     OutputLoggerThreadStore *store = op_thread_data->store;
 
-    BUG_ON(logger == NULL && store != NULL);
-    BUG_ON(logger != NULL && store == NULL);
-    BUG_ON(logger == NULL && store == NULL);
+    DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+    DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
+    DEBUG_VALIDATE_BUG_ON(logger == NULL && store == NULL);
 
-    logger = list;
-    store = op_thread_data->store;
     while (logger && store) {
-        BUG_ON(logger->LogFunc == NULL);
+        DEBUG_VALIDATE_BUG_ON(logger->LogFunc == NULL);
 
         logger->LogFunc(tv, store->thread_data, st);
 
         logger = logger->next;
         store = store->next;
 
-        BUG_ON(logger == NULL && store != NULL);
-        BUG_ON(logger != NULL && store == NULL);
+        DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+        DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
     }
 
     return TM_ECODE_OK;
index fc159265e9a922f37cbc1231bc1ee93d22609be3..46dfebcf1a5f50af557548db927d063aab1d73f8 100644 (file)
@@ -36,6 +36,7 @@
 #include "stream-tcp.h"
 #include "stream-tcp-inline.h"
 #include "stream-tcp-reassemble.h"
+#include "util-validate.h"
 
 typedef struct OutputLoggerThreadStore_ {
     void *thread_data;
@@ -114,18 +115,18 @@ typedef struct StreamerCallbackData_ {
 static int Streamer(void *cbdata, Flow *f, const uint8_t *data, uint32_t data_len, uint64_t tx_id, uint8_t flags)
 {
     StreamerCallbackData *streamer_cbdata = (StreamerCallbackData *)cbdata;
-    BUG_ON(streamer_cbdata == NULL);
+    DEBUG_VALIDATE_BUG_ON(streamer_cbdata == NULL);
     OutputStreamingLogger *logger = streamer_cbdata->logger;
     OutputLoggerThreadStore *store = streamer_cbdata->store;
     ThreadVars *tv = streamer_cbdata->tv;
 #ifdef PROFILING
     Packet *p = streamer_cbdata->p;
 #endif
-    BUG_ON(logger == NULL);
-    BUG_ON(store == NULL);
+    DEBUG_VALIDATE_BUG_ON(logger == NULL);
+    DEBUG_VALIDATE_BUG_ON(store == NULL);
 
     while (logger && store) {
-        BUG_ON(logger->LogFunc == NULL);
+        DEBUG_VALIDATE_BUG_ON(logger->LogFunc == NULL);
 
         if (logger->type == streamer_cbdata->type) {
             SCLogDebug("logger %p", logger);
@@ -137,8 +138,8 @@ static int Streamer(void *cbdata, Flow *f, const uint8_t *data, uint32_t data_le
         logger = logger->next;
         store = store->next;
 
-        BUG_ON(logger == NULL && store != NULL);
-        BUG_ON(logger != NULL && store == NULL);
+        DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+        DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
     }
 
     return 0;
@@ -298,7 +299,7 @@ static int TcpDataLogger (Flow *f, TcpSession *ssn, TcpStream *stream,
 
 static TmEcode OutputStreamingLog(ThreadVars *tv, Packet *p, void *thread_data)
 {
-    BUG_ON(thread_data == NULL);
+    DEBUG_VALIDATE_BUG_ON(thread_data == NULL);
 
     if (list == NULL) {
         /* No child loggers. */
@@ -311,9 +312,9 @@ static TmEcode OutputStreamingLog(ThreadVars *tv, Packet *p, void *thread_data)
 
     StreamerCallbackData streamer_cbdata = { logger, store, tv, p , 0};
 
-    BUG_ON(logger == NULL && store != NULL);
-    BUG_ON(logger != NULL && store == NULL);
-    BUG_ON(logger == NULL && store == NULL);
+    DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+    DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
+    DEBUG_VALIDATE_BUG_ON(logger == NULL && store == NULL);
 
     uint8_t flags = 0;
     Flow * const f = p->flow;
index a780d6ee59f4de698f3b5ef7acb5d9fe50b2a816..aef0f8781502b21783883dc3a96abda5aeb6a267 100644 (file)
@@ -30,6 +30,7 @@
 #include "app-layer.h"
 #include "app-layer-parser.h"
 #include "util-profiling.h"
+#include "util-validate.h"
 
 typedef struct OutputLoggerThreadStore_ {
     void *thread_data;
@@ -129,7 +130,7 @@ int OutputRegisterTxLogger(LoggerId id, const char *name, AppProto alproto,
 
 static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
 {
-    BUG_ON(thread_data == NULL);
+    DEBUG_VALIDATE_BUG_ON(thread_data == NULL);
     if (list == NULL) {
         /* No child loggers registered. */
         return TM_ECODE_OK;
@@ -191,13 +192,13 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
 
         const OutputTxLogger *logger = list;
         const OutputLoggerThreadStore *store = op_thread_data->store;
-#ifdef DEBUG_VALIDATION
-        BUG_ON(logger == NULL && store != NULL);
-        BUG_ON(logger != NULL && store == NULL);
-        BUG_ON(logger == NULL && store == NULL);
-#endif
+
+        DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+        DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
+        DEBUG_VALIDATE_BUG_ON(logger == NULL && store == NULL);
+
         while (logger && store) {
-            BUG_ON(logger->LogFunc == NULL);
+            DEBUG_VALIDATE_BUG_ON(logger->LogFunc == NULL);
 
             SCLogDebug("logger %p, LogCondition %p, ts_log_progress %d "
                     "tc_log_progress %d", logger, logger->LogCondition,
@@ -240,10 +241,9 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data)
 next_logger:
             logger = logger->next;
             store = store->next;
-#ifdef DEBUG_VALIDATION
-            BUG_ON(logger == NULL && store != NULL);
-            BUG_ON(logger != NULL && store == NULL);
-#endif
+
+            DEBUG_VALIDATE_BUG_ON(logger == NULL && store != NULL);
+            DEBUG_VALIDATE_BUG_ON(logger != NULL && store == NULL);
         }
 
         if (tx_logged != tx_logged_old) {