Prepare for '-Wmissing-field-initializers'
[lttng-tools.git] / src / common / event.cpp
index 6d82504e2fe71611be5c86a1aea8b03cbb301c4a..ad3e23d4d8a15679977e7048ed6d6001ac0e3029 100644 (file)
@@ -77,7 +77,7 @@ static int lttng_event_probe_attr_serialize(
 {
        int ret;
        size_t symbol_name_len;
-       struct lttng_event_probe_attr_comm comm = { 0 };
+       struct lttng_event_probe_attr_comm comm = {};
 
        symbol_name_len = lttng_strnlen(probe->symbol_name, LTTNG_SYMBOL_NAME_LEN);
        if (symbol_name_len == LTTNG_SYMBOL_NAME_LEN) {
@@ -200,6 +200,7 @@ static ssize_t lttng_event_probe_attr_create_from_payload(
        local_attr = NULL;
        ret = offset;
 end:
+       free(local_attr);
        return ret;
 }
 
@@ -261,6 +262,7 @@ static ssize_t lttng_event_function_attr_create_from_payload(
        local_attr = NULL;
        ret = offset;
 end:
+       free(local_attr);
        return ret;
 }
 
@@ -619,7 +621,7 @@ deserialize_event_type_payload:
                }
 
                if (ret != event_comm->userspace_probe_location_len) {
-                       WARN("Userspace probe location from the received buffer is not the advertised length: header length = %" PRIu32 ", payload length = %lu", event_comm->userspace_probe_location_len, ret);
+                       WARN("Userspace probe location from the received buffer is not the advertised length: header length = %" PRIu32 ", payload length = %zd", event_comm->userspace_probe_location_len, ret);
                        ret = -1;
                        goto end;
                }
@@ -698,7 +700,7 @@ int lttng_event_serialize(const struct lttng_event *event,
        unsigned int i;
        size_t header_offset, size_before_payload;
        size_t name_len;
-       struct lttng_event_comm event_comm = { 0 };
+       struct lttng_event_comm event_comm = {};
        struct lttng_event_comm *header;
 
        assert(event);
@@ -995,7 +997,8 @@ static ssize_t lttng_event_context_perf_counter_populate_from_payload(
                const struct lttng_payload_view *view,
                struct lttng_event_context *event_ctx)
 {
-       ssize_t ret, offset = 0;
+       int ret;
+       ssize_t consumed, offset = 0;
        const struct lttng_event_context_perf_counter_comm *comm;
        size_t name_len;
        const struct lttng_buffer_view comm_view = lttng_buffer_view_from_view(
@@ -1007,7 +1010,7 @@ static ssize_t lttng_event_context_perf_counter_populate_from_payload(
                        event_ctx->ctx == LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER);
 
        if (!lttng_buffer_view_is_valid(&comm_view)) {
-               ret = -1;
+               consumed = -1;
                goto end;
        }
 
@@ -1024,7 +1027,7 @@ static ssize_t lttng_event_context_perf_counter_populate_from_payload(
                                                name_len);
 
                if (!lttng_buffer_view_is_valid(&provider_name_view)) {
-                       ret = -1;
+                       consumed = -1;
                        goto end;
                }
 
@@ -1032,21 +1035,25 @@ static ssize_t lttng_event_context_perf_counter_populate_from_payload(
 
                if (!lttng_buffer_view_contains_string(
                                    &provider_name_view, name, name_len)) {
-                       ret = -1;
+                       consumed = -1;
                        goto end;
                }
 
-               lttng_strncpy(event_ctx->u.perf_counter.name, name, name_len);
+               ret = lttng_strncpy(event_ctx->u.perf_counter.name, name, name_len);
+               if (ret) {
+                       consumed = -1;
+                       goto end;
+               }
                offset += name_len;
        }
 
        event_ctx->u.perf_counter.config = comm->config;
        event_ctx->u.perf_counter.type = comm->type;
 
-       ret = offset;
+       consumed = offset;
 
 end:
-       return ret;
+       return consumed;
 }
 
 ssize_t lttng_event_context_create_from_payload(
@@ -1121,7 +1128,7 @@ static int lttng_event_context_app_serialize(
                struct lttng_payload *payload)
 {
        int ret;
-       struct lttng_event_context_app_comm comm = { 0 };
+       struct lttng_event_context_app_comm comm = {};
        size_t provider_len, ctx_len;
        const char *provider_name;
        const char *ctx_name;
@@ -1189,7 +1196,7 @@ static int lttng_event_context_perf_counter_serialize(
                struct lttng_payload *payload)
 {
        int ret;
-       struct lttng_event_context_perf_counter_comm comm = { 0 };
+       struct lttng_event_context_perf_counter_comm comm = {};
 
        assert(payload);
        assert(context);
@@ -1410,7 +1417,7 @@ int lttng_event_field_serialize(const struct lttng_event_field *field,
        int ret;
        size_t header_offset, size_before_event;
        size_t name_len;
-       struct lttng_event_field_comm event_field_comm = { 0 };
+       struct lttng_event_field_comm event_field_comm = {};
        struct lttng_event_field_comm *header;
 
        assert(field);
@@ -1481,6 +1488,9 @@ static enum lttng_error_code compute_flattened_size(
        /* The basic struct lttng_event */
        storage_req = event_count * sizeof(struct lttng_event);
 
+       /* The struct·lttng_event_extended */
+       storage_req += event_count * sizeof(struct lttng_event_extended);
+
        for (i = 0; i < event_count; i++) {
                int probe_storage_req = 0;
                const struct event_list_element *element = (const struct event_list_element *)
@@ -1501,10 +1511,6 @@ static enum lttng_error_code compute_flattened_size(
                        probe_storage_req = ret;
                }
 
-               /* The struct·lttng_event_extended */
-               storage_req += event_count *
-                       sizeof(struct lttng_event_extended);
-
                if (element->filter_expression) {
                        storage_req += strlen(element->filter_expression) + 1;
                }
This page took 0.024724 seconds and 4 git commands to generate.