From: Mathieu Desnoyers Date: Wed, 3 Nov 2021 16:14:09 +0000 (-0400) Subject: Refactoring/fix: desc match enabler: handle error internally X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8bff0fc3a53e182b6fdc8f70cedc564adc435afa;p=lttng-modules.git Refactoring/fix: desc match enabler: handle error internally This actually ensures that callers don't mistakenly consider a negative return value (error) as a match success. Signed-off-by: Mathieu Desnoyers Change-Id: I27fe42b4d1d018b9f69de62a0cd8b43c77a61fa5 --- diff --git a/include/lttng/events-internal.h b/include/lttng/events-internal.h index ee2a4ff2..5a1b9160 100644 --- a/include/lttng/events-internal.h +++ b/include/lttng/events-internal.h @@ -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); diff --git a/src/lttng-events.c b/src/lttng-events.c index c212ff3d..2abe3ead 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -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) { diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index 2c3b8af0..b5bd5bd3 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -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.