diff options
author | João Valverde <j@v6e.pt> | 2023-01-12 00:30:50 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2023-01-12 00:59:15 +0000 |
commit | 25d4a099f7c5578d1d43f66f8e9ea567f698cc4b (patch) | |
tree | 6b49238e2fcef75e8cf12f2c32cf0c7deea7e8a9 /wsutil | |
parent | 640c44f24edef4ee3062d77b5fc8366db64e85c4 (diff) |
Remove WS_DISABLE_ASSERT
Assertions can be enabled/disabled using WS_DISABLE_DEBUG. The extra
granularity afforded by WS_DISABLE_ASSERT seems unnecessary.
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/wmem/wmem-int.h | 4 | ||||
-rw-r--r-- | wsutil/ws_assert.h | 12 | ||||
-rw-r--r-- | wsutil/wslog.c | 13 |
3 files changed, 10 insertions, 19 deletions
diff --git a/wsutil/wmem/wmem-int.h b/wsutil/wmem/wmem-int.h index c4b5d1c94b..4cc14106ba 100644 --- a/wsutil/wmem/wmem-int.h +++ b/wsutil/wmem/wmem-int.h @@ -15,11 +15,11 @@ #include <glib.h> -#ifdef WS_DISABLE_ASSERT +#ifdef WS_DISABLE_DEBUG #define ASSERT(...) (void)0 #else #define ASSERT(...) g_assert(__VA_ARGS__) -#endif /* WS_DISABLE_ASSERT */ +#endif /* WS_DISABLE_DEBUG */ #endif /* __WMEM_INT_H__ */ diff --git a/wsutil/ws_assert.h b/wsutil/ws_assert.h index 4d6531c735..3b394e0616 100644 --- a/wsutil/ws_assert.h +++ b/wsutil/ws_assert.h @@ -16,7 +16,7 @@ #include <string.h> #include <wsutil/wslog.h> -#ifdef WS_DISABLE_ASSERT +#ifdef WS_DISABLE_DEBUG #define _ASSERT_ENABLED false #else #define _ASSERT_ENABLED true @@ -27,9 +27,9 @@ extern "C" { #endif /* __cplusplus */ /* - * We don't want to execute the expression with WS_DISABLE_ASSERT because + * We don't want to execute the expression with WS_DISABLE_DEBUG because * it might be time and space costly and the goal here is to optimize for - * WS_DISABLE_ASSERT. However removing it completely is not good enough + * WS_DISABLE_DEBUG. However removing it completely is not good enough * because it might generate many unused variable warnings. So we use * if (false) and let the compiler optimize away the dead execution branch. */ @@ -40,7 +40,7 @@ extern "C" { } while (0) /* - * ws_abort_if_fail() is not conditional on WS_DISABLE_ASSERT. + * ws_abort_if_fail() is not conditional on WS_DISABLE_DEBUG. * Usually used to appease a static analyzer. */ #define ws_abort_if_fail(expr) \ @@ -48,7 +48,7 @@ extern "C" { /* * ws_assert() cannot produce side effects, otherwise code will - * behave differently because of WS_DISABLE_ASSERT, and probably introduce + * behave differently because of WS_DISABLE_DEBUG, and probably introduce * some difficult to track bugs. */ #define ws_assert(expr) \ @@ -70,7 +70,7 @@ extern "C" { } while (0) /* - * We don't want to disable ws_assert_not_reached() with WS_DISABLE_ASSERT. + * We don't want to disable ws_assert_not_reached() with WS_DISABLE_DEBUG. * That would blast compiler warnings everywhere for no benefit, not * even a miniscule performance gain. Reaching this function is always * a programming error and will unconditionally abort execution. diff --git a/wsutil/wslog.c b/wsutil/wslog.c index 7061360f96..91adbb0db7 100644 --- a/wsutil/wslog.c +++ b/wsutil/wslog.c @@ -10,18 +10,14 @@ #include "config.h" -/* Because ws_assert() dependes on ws_error() we do not use it - * here and fall back on assert() instead. */ -#if defined(WS_DISABLE_ASSERT) && !defined(NDEBUG) -#define NDEBUG -#endif - #include "wslog.h" #include <stdlib.h> #include <string.h> #include <errno.h> #include <time.h> +/* Because ws_assert() dependes on ws_error() we do not use it + * here and fall back on assert() instead. */ #include <assert.h> #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -40,12 +36,7 @@ #include "console_win32.h" #endif - -#ifndef WS_DISABLE_ASSERT #define ASSERT(expr) assert(expr) -#else -#define ASSERT(expr) (void)(expr); -#endif /* Runtime log level. */ #define ENV_VAR_LEVEL "WIRESHARK_LOG_LEVEL" |