actions: introduce lttng_action_init
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 29 Nov 2019 21:46:05 +0000 (16:46 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 17 Apr 2020 20:33:56 +0000 (16:33 -0400)
This function is to be used to initialize the common portion of all
action structures.  I have updated the sole currently existing action
(notify), but the function will also be used in subsequent patches.

Change-Id: I4e42554c42a4e6a5ef2da292a6dfeb708d72a602
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/action/action-internal.h
src/common/actions/action.c
src/common/actions/notify.c

index d08024a039b3e9cd5e195153b9ac32f60042ce4e..d1868b06ba49375237b93c99ea7c9ce932ff3596 100644 (file)
@@ -35,6 +35,13 @@ struct lttng_action_comm {
        int8_t action_type;
 } LTTNG_PACKED;
 
+LTTNG_HIDDEN
+void lttng_action_init(struct lttng_action *action,
+               enum lttng_action_type type,
+               action_validate_cb validate,
+               action_serialize_cb serialize,
+               action_destroy_cb destroy);
+
 LTTNG_HIDDEN
 bool lttng_action_validate(struct lttng_action *action);
 
index 982ca45ff27619f3c52d1ba6a15e937ae4b2b647..6894036cb779d09ced9c5acee4dacf9a2e99d876 100644 (file)
@@ -22,6 +22,20 @@ enum lttng_action_type lttng_action_get_type_const(
        return action->type;
 }
 
+LTTNG_HIDDEN
+void lttng_action_init(
+               struct lttng_action *action,
+               enum lttng_action_type type,
+               action_validate_cb validate,
+               action_serialize_cb serialize,
+               action_destroy_cb destroy)
+{
+       action->type = type;
+       action->validate = validate;
+       action->serialize = serialize;
+       action->destroy = destroy;
+}
+
 void lttng_action_destroy(struct lttng_action *action)
 {
        if (!action) {
index 9d005b82365b9797c073408db5fa852f32385822..ea68c75fd0f0c38eba8255e7374033ec1928d5dd 100644 (file)
@@ -32,9 +32,9 @@ struct lttng_action *lttng_action_notify_create(void)
                goto end;
        }
 
-       notify->parent.type = LTTNG_ACTION_TYPE_NOTIFY;
-       notify->parent.serialize = lttng_action_notify_serialize;
-       notify->parent.destroy = lttng_action_notify_destroy;
+       lttng_action_init(&notify->parent, LTTNG_ACTION_TYPE_NOTIFY, NULL,
+                       lttng_action_notify_serialize,
+                       lttng_action_notify_destroy);
 end:
        return &notify->parent;
 }
This page took 0.039164 seconds and 4 git commands to generate.