From: Mathieu Desnoyers Date: Thu, 25 Feb 2021 17:36:18 +0000 (-0500) Subject: Fix: "Cleanup: clarify bytecode ownership" X-Git-Tag: v2.13.0-rc1~368 X-Git-Url: http://git.lttng.org/?p=lttng-ust.git;a=commitdiff_plain;h=49cde654915a90aab1c1fb1cd02c829b4a3e4473 Fix: "Cleanup: clarify bytecode ownership" The function lttng_event_notifier_enabler_attach_capture_bytecode have also been adapted to this change. Signed-off-by: Mathieu Desnoyers Change-Id: I6d8a984af829356329f933b552f9ada34387fd2c --- diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 664f8b5d..acf5f3b6 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -1526,12 +1526,14 @@ int lttng_event_notifier_enabler_attach_filter_bytecode( int lttng_event_notifier_enabler_attach_capture_bytecode( struct lttng_event_notifier_enabler *event_notifier_enabler, - struct lttng_ust_bytecode_node *bytecode) + struct lttng_ust_bytecode_node **bytecode) { - bytecode->enabler = lttng_event_notifier_enabler_as_enabler( + (*bytecode)->enabler = lttng_event_notifier_enabler_as_enabler( event_notifier_enabler); - cds_list_add_tail(&bytecode->node, + cds_list_add_tail(&(*bytecode)->node, &event_notifier_enabler->capture_bytecode_head); + /* Take ownership of bytecode */ + *bytecode = NULL; event_notifier_enabler->num_captures++; lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group); diff --git a/liblttng-ust/lttng-ust-abi.c b/liblttng-ust/lttng-ust-abi.c index 8c0c4655..4703dc3d 100644 --- a/liblttng-ust/lttng-ust-abi.c +++ b/liblttng-ust/lttng-ust-abi.c @@ -719,7 +719,7 @@ long lttng_event_notifier_enabler_cmd(int objd, unsigned int cmd, unsigned long case LTTNG_UST_CAPTURE: return lttng_event_notifier_enabler_attach_capture_bytecode( event_notifier_enabler, - (struct lttng_ust_bytecode_node *) arg); + (struct lttng_ust_bytecode_node **) arg); case LTTNG_UST_ENABLE: return lttng_event_notifier_enabler_enable(event_notifier_enabler); case LTTNG_UST_DISABLE: diff --git a/liblttng-ust/ust-events-internal.h b/liblttng-ust/ust-events-internal.h index 1d8e914a..fc55cb03 100644 --- a/liblttng-ust/ust-events-internal.h +++ b/liblttng-ust/ust-events-internal.h @@ -233,7 +233,7 @@ int lttng_event_notifier_enabler_attach_filter_bytecode( LTTNG_HIDDEN int lttng_event_notifier_enabler_attach_capture_bytecode( struct lttng_event_notifier_enabler *event_notifier_enabler, - struct lttng_ust_bytecode_node *bytecode); + struct lttng_ust_bytecode_node **bytecode); /* * Attach exclusion list to `struct lttng_event_notifier_enabler` and all