static
void _lttng_enabler_attach_filter_bytecode(struct lttng_enabler *enabler,
- struct lttng_ust_bytecode_node *bytecode)
+ struct lttng_ust_bytecode_node **bytecode)
{
- bytecode->enabler = enabler;
- cds_list_add_tail(&bytecode->node, &enabler->filter_bytecode_head);
+ (*bytecode)->enabler = enabler;
+ cds_list_add_tail(&(*bytecode)->node, &enabler->filter_bytecode_head);
+ /* Take ownership of bytecode */
+ *bytecode = NULL;
}
int lttng_event_enabler_attach_filter_bytecode(struct lttng_event_enabler *event_enabler,
- struct lttng_ust_bytecode_node *bytecode)
+ struct lttng_ust_bytecode_node **bytecode)
{
_lttng_enabler_attach_filter_bytecode(
lttng_event_enabler_as_enabler(event_enabler), bytecode);
int lttng_event_notifier_enabler_attach_filter_bytecode(
struct lttng_event_notifier_enabler *event_notifier_enabler,
- struct lttng_ust_bytecode_node *bytecode)
+ struct lttng_ust_bytecode_node **bytecode)
{
_lttng_enabler_attach_filter_bytecode(
lttng_event_notifier_enabler_as_enabler(event_notifier_enabler),
case LTTNG_UST_FILTER:
return lttng_event_notifier_enabler_attach_filter_bytecode(
event_notifier_enabler,
- (struct lttng_ust_bytecode_node *) arg);
+ (struct lttng_ust_bytecode_node **) arg);
case LTTNG_UST_EXCLUSION:
return lttng_event_notifier_enabler_attach_exclusion(event_notifier_enabler,
(struct lttng_ust_excluder_node **) arg);
int ret;
ret = lttng_event_enabler_attach_filter_bytecode(enabler,
- (struct lttng_ust_bytecode_node *) arg);
+ (struct lttng_ust_bytecode_node **) arg);
if (ret)
return ret;
return 0;
int handle_bytecode_recv(struct sock_info *sock_info,
int sock, struct ustcomm_ust_msg *lum)
{
- struct lttng_ust_bytecode_node *bytecode;
+ struct lttng_ust_bytecode_node *bytecode = NULL;
enum lttng_ust_bytecode_node_type type;
const struct lttng_ust_objd_ops *ops;
uint32_t data_size, data_size_max, reloc_offset;
switch (len) {
case 0: /* orderly shutdown */
ret = 0;
- goto error_free_bytecode;
+ goto end;
default:
if (len == bytecode->bc.len) {
DBG("Bytecode %s data received",
ERR("%s remote end closed connection",
sock_info->name);
ret = len;
- goto error_free_bytecode;
+ goto end;
}
ret = len;
- goto error_free_bytecode;
+ goto end;
} else {
DBG("Incorrect %s bytecode data message size: %zd",
bytecode_type_str(lum->cmd), len);
ret = -EINVAL;
- goto error_free_bytecode;
+ goto end;
}
}
ops = objd_ops(lum->handle);
if (!ops) {
ret = -ENOENT;
- goto error_free_bytecode;
+ goto end;
}
- if (ops->cmd) {
+ if (ops->cmd)
ret = ops->cmd(lum->handle, lum->cmd,
- (unsigned long) bytecode,
+ (unsigned long) &bytecode,
NULL, sock_info);
- if (ret)
- goto error_free_bytecode;
- /* don't free bytecode if everything went fine. */
- } else {
+ else
ret = -ENOSYS;
- goto error_free_bytecode;
- }
-
- goto end;
-error_free_bytecode:
- free(bytecode);
end:
+ free(bytecode);
return ret;
}
LTTNG_HIDDEN
int lttng_event_enabler_attach_filter_bytecode(
struct lttng_event_enabler *enabler,
- struct lttng_ust_bytecode_node *bytecode);
+ struct lttng_ust_bytecode_node **bytecode);
/*
* Attach an application context to an event enabler.
LTTNG_HIDDEN
int lttng_event_notifier_enabler_attach_filter_bytecode(
struct lttng_event_notifier_enabler *event_notifier_enabler,
- struct lttng_ust_bytecode_node *bytecode);
+ struct lttng_ust_bytecode_node **bytecode);
/*
* Attach capture bytecode program to `struct lttng_event_notifier_enabler` and