Refactoring/fix: desc match enabler: handle error internally
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 3 Nov 2021 16:14:09 +0000 (12:14 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 3 Nov 2021 16:14:35 +0000 (12:14 -0400)
This actually ensures that callers don't mistakenly consider a negative
return value (error) as a match success.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I27fe42b4d1d018b9f69de62a0cd8b43c77a61fa5

include/lttng/events-internal.h
src/lttng-events.c
src/lttng-syscalls.c

index ee2a4ff26bd0c970bbd4d9a8e5e07a6f1ac566b9..5a1b91604efae411dd3e42c9a2be196090c748a7 100644 (file)
@@ -817,7 +817,7 @@ int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler_common
                struct lttng_kernel_abi_filter_bytecode __user *bytecode);
 void lttng_event_enabler_destroy(struct lttng_event_enabler_common *event_enabler);
 
-int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
+bool lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
                struct lttng_event_enabler_common *enabler);
 bool lttng_event_enabler_match_event(struct lttng_event_enabler_common *event_enabler,
                struct lttng_kernel_event_common *event);
index c212ff3d6bcff092092a07a9fada60bee748d21c..2abe3ead02ad46f3a4b7ea05f67d78100a705b5b 100644 (file)
@@ -1945,7 +1945,8 @@ int lttng_match_enabler_name(const char *desc_name,
        return 1;
 }
 
-int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
+static
+int lttng_desc_match_enabler_check(const struct lttng_kernel_event_desc *desc,
                struct lttng_event_enabler_common *enabler)
 {
        const char *desc_name, *enabler_name;
@@ -2034,6 +2035,19 @@ int lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
        }
 }
 
+bool lttng_desc_match_enabler(const struct lttng_kernel_event_desc *desc,
+               struct lttng_event_enabler_common *enabler)
+{
+       int ret;
+
+       ret = lttng_desc_match_enabler_check(desc, enabler);
+       if (ret < 0) {
+               WARN_ON_ONCE(1);
+               return false;
+       }
+       return ret;
+}
+
 bool lttng_event_enabler_match_event(struct lttng_event_enabler_common *event_enabler,
                struct lttng_kernel_event_common *event)
 {
index 2c3b8af028b609a2839423c4f253168098f1511b..b5bd5bd39e9ee25c59536ef4b5248cfc929b36ab 100644 (file)
@@ -554,8 +554,8 @@ int lttng_create_syscall_event_if_missing(const struct trace_syscall_entry *tabl
                        /* Unknown syscall */
                        continue;
                }
-               if (lttng_desc_match_enabler(desc,
-                               lttng_event_recorder_enabler_as_enabler(syscall_event_enabler)) <= 0)
+               if (!lttng_desc_match_enabler(desc,
+                               lttng_event_recorder_enabler_as_enabler(syscall_event_enabler)))
                        continue;
                /*
                 * Check if already created.
This page took 0.029846 seconds and 4 git commands to generate.