]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
debug: add SCReturnBool function exit macro
authorJason Ish <jason.ish@oisf.net>
Mon, 25 Nov 2019 22:55:08 +0000 (16:55 -0600)
committerJason Ish <jason.ish@oisf.net>
Wed, 27 Nov 2019 19:03:46 +0000 (13:03 -0600)
src/util-debug.h

index b3fdd501610178ce54dc2a5a9e9b18d3ed282081..8b352f9535b58f1228a439628f6db1c6090a6daa 100644 (file)
@@ -352,6 +352,8 @@ extern int sc_log_module_cleaned;
 
 #define SCReturnPtr(x, type)            return x
 
+#define SCReturnBool(x)                 return x
+
 /* Please use it only for debugging purposes */
 #else
 
@@ -534,6 +536,24 @@ extern int sc_log_module_cleaned;
                                   return x;                                  \
                               } while(0)
 
+/**
+ * \brief Macro used to log debug messages on function exit.  Comes under the
+ *        debugging sybsystem, and hence will be enabled only in the presence
+ *        of the DEBUG macro.  Apart from logging function_exit logs, it also
+ *        processes the FD filters, if any FD filters are registered.  This
+ *        function_exit macro should be used for functions that returns a
+ *        boolean value.
+ *
+ * \retval x Variable of type 'bool' that has to be returned
+ */
+#define SCReturnBool(x)        do {                                           \
+                                  if (sc_log_global_log_level >= SC_LOG_DEBUG) { \
+                                      SCLogDebug("Returning: %s ... <<", x ? "true" : "false"); \
+                                      SCLogCheckFDFilterExit(__FUNCTION__);  \
+                                  }                                          \
+                                  return x;                                  \
+                              } while(0)
+
 #endif /* DEBUG */
 
 #define FatalError(x, ...) do {                                             \