Build fix: missing initializer for member 'indexes'
[lttng-tools.git] / src / common / actions / path.cpp
index cbb7519b13f5a21d907f993755785b6d6dfeaa4f..612ade8c31a69e7696312c9882c145b1700335e4 100644 (file)
@@ -7,10 +7,12 @@
 
 #include <lttng/action/path-internal.hpp>
 
+namespace {
 struct lttng_action_path_comm {
        uint32_t index_count;
        uint64_t indexes[];
 } LTTNG_PACKED;
+} /* namespace */
 
 struct lttng_action_path *lttng_action_path_create(
                const uint64_t *indexes, size_t index_count)
@@ -96,32 +98,25 @@ end:
 }
 
 int lttng_action_path_copy(const struct lttng_action_path *src,
-               struct lttng_action_path *dst)
+               struct lttng_action_path **dst)
 {
        int ret;
-       size_t i, src_count;
+       struct lttng_action_path *new_path;
 
        LTTNG_ASSERT(src);
        LTTNG_ASSERT(dst);
 
-       lttng_dynamic_array_init(&dst->indexes, sizeof(uint64_t), NULL);
-       src_count = lttng_dynamic_array_get_count(&src->indexes);
-
-       for (i = 0; i < src_count; i++) {
-               const void *index = lttng_dynamic_array_get_element(
-                               &src->indexes, i);
-
-               ret = lttng_dynamic_array_add_element(&dst->indexes, index);
-               if (ret) {
-                       goto error;
-               }
+       new_path = lttng_action_path_create(
+                       (uint64_t *) lttng_dynamic_array_get_element(
+                               &src->indexes, 0), 
+                       lttng_dynamic_array_get_count(&src->indexes));
+       if (!new_path) {
+               ret = -1;
+       } else {
+               ret = 0;
+               *dst = new_path;
        }
 
-       ret = 0;
-       goto end;
-error:
-       lttng_dynamic_array_reset(&dst->indexes);
-end:
        return ret;
 }
 
@@ -193,9 +188,7 @@ int lttng_action_path_serialize(const struct lttng_action_path *action_path,
                goto end;
        }
 
-       comm = {
-               .index_count = (uint32_t) index_count,
-       };
+       comm.index_count = (uint32_t) index_count;
        ret = lttng_dynamic_buffer_append(&payload->buffer,
                        &comm,
                        sizeof(struct lttng_action_path_comm));
This page took 0.025665 seconds and 4 git commands to generate.