clang-tidy: add Chrome-inspired checks
[lttng-tools.git] / src / common / actions / notify.cpp
index ff117321e0b73d7e0e0b7e30fc6b865cd7085660..cae5ecdc33a880964b1aa178eca9506646954f01 100644 (file)
@@ -8,32 +8,30 @@
 #include <common/error.hpp>
 #include <common/macros.hpp>
 #include <common/mi-lttng.hpp>
+
 #include <lttng/action/action-internal.hpp>
 #include <lttng/action/notify-internal.hpp>
 #include <lttng/action/rate-policy-internal.hpp>
 #include <lttng/lttng-error.h>
 
-#define IS_NOTIFY_ACTION(action) \
-       (lttng_action_get_type(action) == LTTNG_ACTION_TYPE_NOTIFY)
+#define IS_NOTIFY_ACTION(action) (lttng_action_get_type(action) == LTTNG_ACTION_TYPE_NOTIFY)
 
-static struct lttng_action_notify *action_notify_from_action(
-               struct lttng_action *action)
+static struct lttng_action_notify *action_notify_from_action(struct lttng_action *action)
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_notify, parent);
+       return lttng::utils::container_of(action, &lttng_action_notify::parent);
 }
 
-static const struct lttng_action_notify *action_notify_from_action_const(
-               const struct lttng_action *action)
+static const struct lttng_action_notify *
+action_notify_from_action_const(const struct lttng_action *action)
 {
        LTTNG_ASSERT(action);
 
-       return container_of(action, struct lttng_action_notify, parent);
+       return lttng::utils::container_of(action, &lttng_action_notify::parent);
 }
 
-static
-void lttng_action_notify_destroy(struct lttng_action *action)
+static void lttng_action_notify_destroy(struct lttng_action *action)
 {
        struct lttng_action_notify *notify_action;
        notify_action = action_notify_from_action(action);
@@ -41,9 +39,7 @@ void lttng_action_notify_destroy(struct lttng_action *action)
        free(notify_action);
 }
 
-static
-int lttng_action_notify_serialize(struct lttng_action *action,
-               struct lttng_payload *payload)
+static int lttng_action_notify_serialize(struct lttng_action *action, struct lttng_payload *payload)
 {
        int ret;
        struct lttng_action_notify *notify_action;
@@ -63,9 +59,7 @@ end:
        return ret;
 }
 
-static
-bool lttng_action_notify_is_equal(const struct lttng_action *a,
-               const struct lttng_action *b)
+static bool lttng_action_notify_is_equal(const struct lttng_action *a, const struct lttng_action *b)
 {
        const struct lttng_action_notify *_a, *_b;
 
@@ -83,13 +77,13 @@ lttng_action_notify_internal_get_rate_policy(const struct lttng_action *action)
        return _action->policy;
 }
 
-static enum lttng_error_code lttng_action_notify_mi_serialize(
-               const struct lttng_action *action, struct mi_writer *writer)
+static enum lttng_error_code lttng_action_notify_mi_serialize(const struct lttng_action *action,
+                                                             struct mi_writer *writer)
 {
        int ret;
        enum lttng_action_status status;
        enum lttng_error_code ret_code;
-       const struct lttng_rate_policy *policy = NULL;
+       const struct lttng_rate_policy *policy = nullptr;
 
        LTTNG_ASSERT(action);
        LTTNG_ASSERT(IS_NOTIFY_ACTION(action));
@@ -97,11 +91,10 @@ static enum lttng_error_code lttng_action_notify_mi_serialize(
 
        status = lttng_action_notify_get_rate_policy(action, &policy);
        LTTNG_ASSERT(status == LTTNG_ACTION_STATUS_OK);
-       LTTNG_ASSERT(policy != NULL);
+       LTTNG_ASSERT(policy != nullptr);
 
        /* Open action notify. */
-       ret = mi_lttng_writer_open_element(
-                       writer, mi_lttng_element_action_notify);
+       ret = mi_lttng_writer_open_element(writer, mi_lttng_element_action_notify);
        if (ret) {
                goto mi_error;
        }
@@ -128,9 +121,9 @@ end:
 
 struct lttng_action *lttng_action_notify_create(void)
 {
-       struct lttng_rate_policy *policy = NULL;
-       struct lttng_action_notify *notify = NULL;
-       struct lttng_action *action = NULL;
+       struct lttng_rate_policy *policy = nullptr;
+       struct lttng_action_notify *notify = nullptr;
+       struct lttng_action *action = nullptr;
 
        notify = zmalloc<lttng_action_notify>();
        if (!notify) {
@@ -143,19 +136,21 @@ struct lttng_action *lttng_action_notify_create(void)
                goto end;
        }
 
-       lttng_action_init(&notify->parent, LTTNG_ACTION_TYPE_NOTIFY, NULL,
-                       lttng_action_notify_serialize,
-                       lttng_action_notify_is_equal,
-                       lttng_action_notify_destroy,
-                       lttng_action_notify_internal_get_rate_policy,
-                       lttng_action_generic_add_error_query_results,
-                       lttng_action_notify_mi_serialize);
+       lttng_action_init(&notify->parent,
+                         LTTNG_ACTION_TYPE_NOTIFY,
+                         nullptr,
+                         lttng_action_notify_serialize,
+                         lttng_action_notify_is_equal,
+                         lttng_action_notify_destroy,
+                         lttng_action_notify_internal_get_rate_policy,
+                         lttng_action_generic_add_error_query_results,
+                         lttng_action_notify_mi_serialize);
 
        notify->policy = policy;
-       policy = NULL;
+       policy = nullptr;
 
        action = &notify->parent;
-       notify = NULL;
+       notify = nullptr;
 
 end:
        free(notify);
@@ -163,17 +158,15 @@ end:
        return action;
 }
 
-ssize_t lttng_action_notify_create_from_payload(
-               struct lttng_payload_view *view,
-               struct lttng_action **action)
+ssize_t lttng_action_notify_create_from_payload(struct lttng_payload_view *view,
+                                               struct lttng_action **action)
 {
        enum lttng_action_status status;
        ssize_t consumed_length;
-       struct lttng_rate_policy *rate_policy = NULL;
-       struct lttng_action *_action = NULL;
+       struct lttng_rate_policy *rate_policy = nullptr;
+       struct lttng_action *_action = nullptr;
 
-       consumed_length = lttng_rate_policy_create_from_payload(
-                       view, &rate_policy);
+       consumed_length = lttng_rate_policy_create_from_payload(view, &rate_policy);
        if (!rate_policy) {
                consumed_length = -1;
                goto end;
@@ -192,7 +185,7 @@ ssize_t lttng_action_notify_create_from_payload(
        }
 
        *action = _action;
-       _action = NULL;
+       _action = nullptr;
 
 end:
        lttng_rate_policy_destroy(rate_policy);
@@ -200,13 +193,12 @@ end:
        return consumed_length;
 }
 
-enum lttng_action_status lttng_action_notify_set_rate_policy(
-               struct lttng_action *action,
-               const struct lttng_rate_policy *policy)
+enum lttng_action_status lttng_action_notify_set_rate_policy(struct lttng_action *action,
+                                                            const struct lttng_rate_policy *policy)
 {
        enum lttng_action_status status;
        struct lttng_action_notify *notify_action;
-       struct lttng_rate_policy *copy = NULL;
+       struct lttng_rate_policy *copy = nullptr;
 
        if (!action || !policy || !IS_NOTIFY_ACTION(action)) {
                status = LTTNG_ACTION_STATUS_INVALID;
@@ -227,16 +219,16 @@ enum lttng_action_status lttng_action_notify_set_rate_policy(
        /* Assign the policy. */
        notify_action->policy = copy;
        status = LTTNG_ACTION_STATUS_OK;
-       copy = NULL;
+       copy = nullptr;
 
 end:
        lttng_rate_policy_destroy(copy);
        return status;
 }
 
-enum lttng_action_status lttng_action_notify_get_rate_policy(
-               const struct lttng_action *action,
-               const struct lttng_rate_policy **policy)
+enum lttng_action_status
+lttng_action_notify_get_rate_policy(const struct lttng_action *action,
+                                   const struct lttng_rate_policy **policy)
 {
        enum lttng_action_status status;
        const struct lttng_action_notify *notify_action;
This page took 0.031106 seconds and 4 git commands to generate.