From: Simon Marchi Date: Fri, 29 Nov 2019 21:46:05 +0000 (-0500) Subject: actions: introduce lttng_action_init X-Git-Tag: v2.13.0-rc1~663 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=6acb3f46333c25d5a2f3a3ff8158956a4689031e actions: introduce lttng_action_init 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 Signed-off-by: Jérémie Galarneau --- diff --git a/include/lttng/action/action-internal.h b/include/lttng/action/action-internal.h index d08024a03..d1868b06b 100644 --- a/include/lttng/action/action-internal.h +++ b/include/lttng/action/action-internal.h @@ -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); diff --git a/src/common/actions/action.c b/src/common/actions/action.c index 982ca45ff..6894036cb 100644 --- a/src/common/actions/action.c +++ b/src/common/actions/action.c @@ -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) { diff --git a/src/common/actions/notify.c b/src/common/actions/notify.c index 9d005b823..ea68c75fd 100644 --- a/src/common/actions/notify.c +++ b/src/common/actions/notify.c @@ -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(¬ify->parent, LTTNG_ACTION_TYPE_NOTIFY, NULL, + lttng_action_notify_serialize, + lttng_action_notify_destroy); end: return ¬ify->parent; }