condition: implement lttng_condition_event_rule_get_internal_capture_descriptor_at_index
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 29 Apr 2020 19:36:00 +0000 (15:36 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 11 Mar 2021 20:31:53 +0000 (15:31 -0500)
The lttng_capture_descriptor object is only exposed internally. A
getter is necessary to allow more control on the
lttng_capture_descriptor object. This will be reused to set the bytecode
later in the patchset.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7fdfdc9d2ac1920bcf1a098352dfd105949e1062
Depends-on: lttng-ust: I5a800fc92e588c2a6a0e26282b0ad5f31c044479

src/common/conditions/event-rule.c

index a08b3eb419a7e897d2e7118ea519274798eb40ec..8d3f1cd536c01e427513ff528d764063ea849715 100644 (file)
@@ -192,6 +192,39 @@ end:
        return ret;
 }
 
+static
+struct lttng_capture_descriptor *
+lttng_condition_event_rule_get_internal_capture_descriptor_at_index(
+               const struct lttng_condition *condition, unsigned int index)
+{
+       const struct lttng_condition_event_rule *event_rule_cond =
+                       container_of(condition,
+                               const struct lttng_condition_event_rule,
+                               parent);
+       struct lttng_capture_descriptor *desc = NULL;
+       unsigned int count;
+       enum lttng_condition_status status;
+
+       if (!condition || !IS_EVENT_RULE_CONDITION(condition)) {
+               goto end;
+       }
+
+       status = lttng_condition_event_rule_get_capture_descriptor_count(
+                       condition, &count);
+       if (status != LTTNG_CONDITION_STATUS_OK) {
+               goto end;
+       }
+
+       if (index >= count) {
+               goto end;
+       }
+
+       desc = lttng_dynamic_pointer_array_get_pointer(
+                       &event_rule_cond->capture_descriptors, index);
+end:
+       return desc;
+}
+
 static int lttng_condition_event_rule_serialize(
                const struct lttng_condition *condition,
                struct lttng_payload *payload)
@@ -233,13 +266,13 @@ static int lttng_condition_event_rule_serialize(
        }
 
        for (i = 0; i < capture_descr_count; i++) {
-               const struct lttng_event_expr *expr =
-                               lttng_condition_event_rule_get_capture_descriptor_at_index(
+               const struct lttng_capture_descriptor *desc =
+                               lttng_condition_event_rule_get_internal_capture_descriptor_at_index(
                                                condition, i);
 
                DBG("Serializing event rule condition's capture descriptor %" PRIu32,
                                i);
-               ret = serialize_event_expr(expr, payload);
+               ret = serialize_event_expr(desc->event_expression, payload);
                if (ret) {
                        goto end;
                }
@@ -586,9 +619,9 @@ ssize_t lttng_condition_event_rule_create_from_payload(
 
        /* Capture descriptors. */
        for (i = 0; i < capture_descr_count; i++) {
+               enum lttng_condition_status status;
                struct lttng_event_expr *expr = event_expr_from_payload(
                                view, &offset);
-               enum lttng_condition_status status;
 
                if (!expr) {
                        goto error;
@@ -724,30 +757,14 @@ const struct lttng_event_expr *
 lttng_condition_event_rule_get_capture_descriptor_at_index(
                const struct lttng_condition *condition, unsigned int index)
 {
-       const struct lttng_condition_event_rule *event_rule_cond =
-                       container_of(condition,
-                               const struct lttng_condition_event_rule,
-                               parent);
        const struct lttng_event_expr *expr = NULL;
-       struct lttng_capture_descriptor *desc = NULL;
-       unsigned int count;
-       enum lttng_condition_status status;
+       const struct lttng_capture_descriptor *desc = NULL;
 
-       if (!condition || !IS_EVENT_RULE_CONDITION(condition)) {
-               goto end;
-       }
-
-       status = lttng_condition_event_rule_get_capture_descriptor_count(condition, &count);
-       if (status != LTTNG_CONDITION_STATUS_OK) {
-               goto end;
-       }
-
-       if (index >= count) {
+       desc = lttng_condition_event_rule_get_internal_capture_descriptor_at_index(
+                       condition, index);
+       if (desc == NULL) {
                goto end;
        }
-
-       desc = lttng_dynamic_pointer_array_get_pointer(
-                       &event_rule_cond->capture_descriptors, index);
        expr = desc->event_expression;
 
 end:
This page took 0.035038 seconds and 4 git commands to generate.