side.c: Use assert to validate flags
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 21 Sep 2023 11:56:37 +0000 (12:56 +0100)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 21 Sep 2023 11:56:37 +0000 (12:56 +0100)
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 <mathieu.desnoyers@efficios.com>
src/side.c

index 54e0b6a9481420ada73c1d51028889d5effeea25..84f5b32de0cb0ea6f0129ef2f2ce8f316ca6638a 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <side/trace.h>
 #include <string.h>
+#include <assert.h>
 
 #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.
This page took 0.023239 seconds and 4 git commands to generate.