From: Mathieu Desnoyers Date: Thu, 21 Sep 2023 11:56:37 +0000 (+0100) Subject: side.c: Use assert to validate flags X-Git-Url: http://git.efficios.com/?p=libside.git;a=commitdiff_plain;h=b1bf768c6803f48edd863c9e37e8b2b6a2f78d49 side.c: Use assert to validate flags Flag validation is redundant with the logic already verified on registration. Therefore, use an assertion, which can be compiled-out when performance matters. Signed-off-by: Mathieu Desnoyers --- diff --git a/src/side.c b/src/side.c index 54e0b6a..84f5b32 100644 --- a/src/side.c +++ b/src/side.c @@ -5,6 +5,7 @@ #include #include +#include #include "rcu.h" #include "list.h" @@ -72,10 +73,7 @@ void side_call(const struct side_event_state *event_state, const struct side_arg return; if (side_unlikely(!initialized)) side_init(); - if (side_unlikely(event_state->desc->flags & SIDE_EVENT_FLAG_VARIADIC)) { - printf("ERROR: unexpected variadic event description\n"); - abort(); - } + assert(!(event_state->desc->flags & SIDE_EVENT_FLAG_VARIADIC)); enabled = __atomic_load_n(&event_state->enabled, __ATOMIC_RELAXED); if (side_unlikely(enabled & SIDE_EVENT_ENABLED_KERNEL_USER_EVENT_MASK)) { // TODO: call kernel write. @@ -98,10 +96,7 @@ void side_call_variadic(const struct side_event_state *event_state, return; if (side_unlikely(!initialized)) side_init(); - if (side_unlikely(!(event_state->desc->flags & SIDE_EVENT_FLAG_VARIADIC))) { - printf("ERROR: unexpected non-variadic event description\n"); - abort(); - } + assert(event_state->desc->flags & SIDE_EVENT_FLAG_VARIADIC); enabled = __atomic_load_n(&event_state->enabled, __ATOMIC_RELAXED); if (side_unlikely(enabled & SIDE_EVENT_ENABLED_KERNEL_USER_EVENT_MASK)) { // TODO: call kernel write.