common: replace container_of with a C++ safe implementation
[lttng-tools.git] / src / common / event-rule / log4j-logging.cpp
index b7386c0ba36f99743055efff6c0ff5a8b04d954e..11e775c3f893f9d4269f76b020d2e9204057c20c 100644 (file)
@@ -32,8 +32,8 @@ static void lttng_event_rule_log4j_logging_destroy(struct lttng_event_rule *rule
                return;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        lttng_log_level_rule_destroy(log4j_logging->log_level_rule);
        free(log4j_logging->pattern);
@@ -53,8 +53,8 @@ static bool lttng_event_rule_log4j_logging_validate(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        /* Required field. */
        if (!log4j_logging->pattern) {
@@ -86,8 +86,8 @@ static int lttng_event_rule_log4j_logging_serialize(
        header_offset = payload->buffer.size;
 
        DBG("Serializing log4j_logging event rule.");
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        pattern_len = strlen(log4j_logging->pattern) + 1;
 
@@ -141,8 +141,8 @@ static bool lttng_event_rule_log4j_logging_is_equal(
        bool is_equal = false;
        struct lttng_event_rule_log4j_logging *a, *b;
 
-       a = container_of(_a, struct lttng_event_rule_log4j_logging, parent);
-       b = container_of(_b, struct lttng_event_rule_log4j_logging, parent);
+       a = lttng::utils::container_of(_a, &lttng_event_rule_log4j_logging::parent);
+       b = lttng::utils::container_of(_b, &lttng_event_rule_log4j_logging::parent);
 
        /* Quick checks. */
 
@@ -304,8 +304,8 @@ lttng_event_rule_log4j_logging_generate_filter_bytecode(
 
        LTTNG_ASSERT(rule);
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        status = lttng_event_rule_log4j_logging_get_filter(rule, &filter);
        if (status == LTTNG_EVENT_RULE_STATUS_UNSET) {
@@ -357,8 +357,8 @@ static const char *lttng_event_rule_log4j_logging_get_internal_filter(
        struct lttng_event_rule_log4j_logging *log4j_logging;
 
        LTTNG_ASSERT(rule);
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        return log4j_logging->internal_filter.filter;
 }
 
@@ -369,8 +369,8 @@ lttng_event_rule_log4j_logging_get_internal_filter_bytecode(
        struct lttng_event_rule_log4j_logging *log4j_logging;
 
        LTTNG_ASSERT(rule);
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        return log4j_logging->internal_filter.bytecode;
 }
 
@@ -389,7 +389,7 @@ static unsigned long lttng_event_rule_log4j_logging_hash(
 {
        unsigned long hash;
        struct lttng_event_rule_log4j_logging *tp_rule =
-                       container_of(rule, typeof(*tp_rule), parent);
+                       lttng::utils::container_of(rule, &lttng_event_rule_log4j_logging::parent);
 
        hash = hash_key_ulong((void *) LTTNG_EVENT_RULE_TYPE_LOG4J_LOGGING,
                        lttng_ht_seed);
@@ -418,8 +418,8 @@ static struct lttng_event *lttng_event_rule_log4j_logging_generate_lttng_event(
        enum lttng_event_rule_status status;
        const struct lttng_log_level_rule *log_level_rule;
 
-       log4j_logging = container_of(
-                       rule, const struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        local_event = zmalloc<lttng_event>();
        if (!local_event) {
@@ -752,8 +752,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_name_pattern(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        pattern_copy = strdup(pattern);
        if (!pattern_copy) {
                status = LTTNG_EVENT_RULE_STATUS_ERROR;
@@ -782,8 +782,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_name_pattern(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        if (!log4j_logging->pattern) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -807,8 +807,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_filter(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        expression_copy = strdup(expression);
        if (!expression_copy) {
                PERROR("Failed to copy filter expression");
@@ -837,8 +837,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_filter(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        if (!log4j_logging->filter_expression) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
@@ -872,8 +872,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_set_log_level_rule(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
 
        if (!log_level_rule_valid(log_level_rule)) {
                status = LTTNG_EVENT_RULE_STATUS_INVALID;
@@ -909,8 +909,8 @@ enum lttng_event_rule_status lttng_event_rule_log4j_logging_get_log_level_rule(
                goto end;
        }
 
-       log4j_logging = container_of(
-                       rule, struct lttng_event_rule_log4j_logging, parent);
+       log4j_logging = lttng::utils::container_of(
+                       rule, &lttng_event_rule_log4j_logging::parent);
        if (log4j_logging->log_level_rule == NULL) {
                status = LTTNG_EVENT_RULE_STATUS_UNSET;
                goto end;
This page took 0.026597 seconds and 4 git commands to generate.