From: Jason Ish Date: Mon, 25 Nov 2019 22:55:08 +0000 (-0600) Subject: debug: add SCReturnBool function exit macro X-Git-Tag: suricata-5.0.1~75 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=62e4211f042679f337cf830bb81a268d5d54618b;p=thirdparty%2Fsuricata.git debug: add SCReturnBool function exit macro --- diff --git a/src/util-debug.h b/src/util-debug.h index b3fdd50161..8b352f9535 100644 --- a/src/util-debug.h +++ b/src/util-debug.h @@ -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 { \