Build fix: Missing message in LTTNG_DEPRECATED invocation
[lttng-tools.git] / src / common / evaluation.c
index cb379168e3a20ddab5167add1d839c82519d6cf3..6b3e634947253812329f099770d2345f999622b1 100644 (file)
@@ -5,23 +5,22 @@
  *
  */
 
+#include <lttng/condition/condition-internal.h>
 #include <lttng/condition/evaluation-internal.h>
 #include <lttng/condition/buffer-usage-internal.h>
 #include <lttng/condition/session-consumed-size-internal.h>
 #include <lttng/condition/session-rotation-internal.h>
+#include <lttng/condition/event-rule-matches-internal.h>
 #include <common/macros.h>
 #include <common/error.h>
 #include <stdbool.h>
-#include <assert.h>
 
-LTTNG_HIDDEN
 void lttng_evaluation_init(struct lttng_evaluation *evaluation,
                enum lttng_condition_type type)
 {
        evaluation->type = type;
 }
 
-LTTNG_HIDDEN
 int lttng_evaluation_serialize(const struct lttng_evaluation *evaluation,
                struct lttng_payload *payload)
 {
@@ -46,23 +45,31 @@ end:
        return ret;
 }
 
-LTTNG_HIDDEN
 ssize_t lttng_evaluation_create_from_payload(
+               const struct lttng_condition *condition,
                struct lttng_payload_view *src_view,
                struct lttng_evaluation **evaluation)
 {
        ssize_t ret, evaluation_size = 0;
        const struct lttng_evaluation_comm *evaluation_comm;
-       struct lttng_payload_view evaluation_view =
+       struct lttng_payload_view evaluation_comm_view =
                        lttng_payload_view_from_view(
-                                       src_view, sizeof(*evaluation_comm), -1);
+                                       src_view, 0, sizeof(*evaluation_comm));
+       struct lttng_payload_view evaluation_view =
+                       lttng_payload_view_from_view(src_view,
+                                       sizeof(*evaluation_comm), -1);
 
        if (!src_view || !evaluation) {
                ret = -1;
                goto end;
        }
 
-       evaluation_comm = (typeof(evaluation_comm)) src_view->buffer.data;
+       if (!lttng_payload_view_is_valid(&evaluation_comm_view)) {
+               ret = -1;
+               goto end;
+       }
+
+       evaluation_comm = (typeof(evaluation_comm)) evaluation_comm_view.buffer.data;
        evaluation_size += sizeof(*evaluation_comm);
 
        switch ((enum lttng_condition_type) evaluation_comm->type) {
@@ -106,6 +113,20 @@ ssize_t lttng_evaluation_create_from_payload(
                }
                evaluation_size += ret;
                break;
+       case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES:
+               LTTNG_ASSERT(condition);
+               LTTNG_ASSERT(condition->type ==
+                               LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES);
+               ret = lttng_evaluation_event_rule_matches_create_from_payload(
+                               container_of(condition,
+                                               const struct lttng_condition_event_rule_matches,
+                                               parent),
+                               &evaluation_view, evaluation);
+               if (ret < 0) {
+                       goto end;
+               }
+               evaluation_size += ret;
+               break;
        default:
                ERR("Attempted to create evaluation of unknown type (%i)",
                                (int) evaluation_comm->type);
@@ -130,6 +151,6 @@ void lttng_evaluation_destroy(struct lttng_evaluation *evaluation)
                return;
        }
 
-       assert(evaluation->destroy);
+       LTTNG_ASSERT(evaluation->destroy);
        evaluation->destroy(evaluation);
 }
This page took 0.025114 seconds and 4 git commands to generate.