From: Simon Marchi Date: Wed, 8 Apr 2020 20:38:19 +0000 (-0400) Subject: common: move copy_filter_bytecode to bytecode.c and rename it X-Git-Tag: v2.13.0-rc1~264 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=763f0d4cef1438d3f1f5f5c5a232d72628bca550 common: move copy_filter_bytecode to bytecode.c and rename it Since there's now a file dedicated to bytecode stuff, that is independent of filters, move copy_filter_bytecode there. Rename it to `bytecode_copy`. Change-Id: I61a7a7fa1a04d39fbaf367f6bf8147b323aa8b27 Signed-off-by: Simon Marchi Signed-off-by: Jérémie Galarneau Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479 --- diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index 40eb26560..c7768a547 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 0f8664cc3..5ba14748d 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include diff --git a/src/bin/lttng-sessiond/utils.c b/src/bin/lttng-sessiond/utils.c index febf23058..f84859fc6 100644 --- a/src/bin/lttng-sessiond/utils.c +++ b/src/bin/lttng-sessiond/utils.c @@ -98,26 +98,3 @@ const char *consumer_output_get_base_path(const struct consumer_output *output) output->dst.session_root_path : output->dst.net.base_dir; } - -/* - * Allocate a filter and copy the given original filter. - * - * Return allocated filter or NULL on error. - */ -struct lttng_filter_bytecode *lttng_filter_bytecode_copy( - const struct lttng_filter_bytecode *orig_f) -{ - struct lttng_filter_bytecode *filter = NULL; - - /* Copy filter bytecode */ - filter = zmalloc(sizeof(*filter) + orig_f->len); - if (!filter) { - PERROR("zmalloc alloc filter bytecode"); - goto error; - } - - memcpy(filter, orig_f, sizeof(*filter) + orig_f->len); - -error: - return filter; -} diff --git a/src/bin/lttng-sessiond/utils.h b/src/bin/lttng-sessiond/utils.h index 2492bb0f6..ff8deaec4 100644 --- a/src/bin/lttng-sessiond/utils.h +++ b/src/bin/lttng-sessiond/utils.h @@ -19,7 +19,5 @@ int loglevels_match(int a_loglevel_type, int a_loglevel_value, int b_loglevel_type, int b_loglevel_value, int loglevel_all_type); const char *session_get_base_path(const struct ltt_session *session); const char *consumer_output_get_base_path(const struct consumer_output *output); -struct lttng_filter_bytecode *lttng_filter_bytecode_copy( - const struct lttng_filter_bytecode *orig_f); #endif /* _LTT_UTILS_H */ diff --git a/src/common/bytecode/bytecode.c b/src/common/bytecode/bytecode.c index b8edd6913..e85dd66c1 100644 --- a/src/common/bytecode/bytecode.c +++ b/src/common/bytecode/bytecode.c @@ -99,3 +99,25 @@ int bytecode_push_logical(struct lttng_filter_bytecode_alloc **fb, - (void *) &(*fb)->b.data[0]; return 0; } + +/* + * Allocate an lttng_bytecode object and copy the given original bytecode. + * + * Return allocated bytecode or NULL on error. + */ +LTTNG_HIDDEN +struct lttng_filter_bytecode *lttng_filter_bytecode_copy( + const struct lttng_filter_bytecode *orig_f) +{ + struct lttng_filter_bytecode *bytecode = NULL; + + bytecode = zmalloc(sizeof(*bytecode) + orig_f->len); + if (!bytecode) { + goto error; + } + + memcpy(bytecode, orig_f, sizeof(*bytecode) + orig_f->len); + +error: + return bytecode; +} diff --git a/src/common/bytecode/bytecode.h b/src/common/bytecode/bytecode.h index ecf54f92e..3a639c939 100644 --- a/src/common/bytecode/bytecode.h +++ b/src/common/bytecode/bytecode.h @@ -238,6 +238,8 @@ LTTNG_HIDDEN int bytecode_push(struct lttng_filter_bytecode_alloc **fb, LTTNG_HIDDEN int bytecode_push_logical(struct lttng_filter_bytecode_alloc **fb, struct logical_op *data, uint32_t align, uint32_t len, uint16_t *skip_offset); +LTTNG_HIDDEN struct lttng_filter_bytecode *lttng_filter_bytecode_copy( + const struct lttng_filter_bytecode *orig_f); static inline unsigned int bytecode_get_len(struct lttng_filter_bytecode *bytecode)