Fix: string might be uninitialized
[lttng-tools.git] / src / common / tracker.c
index 126f8252a7016e66dc7e210a2f5614c4dc87ef9c..7c97d561c982139283afde068394da7703a161c6 100644 (file)
@@ -1,18 +1,8 @@
 /*
- * Copyright (C) 2019 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
+ * Copyright (C) 2019 Jonathan Rajotte-Julien <jonathan.rajotte-julien@efficios.com>
  *
- * This library is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License, version 2.1 only,
- * as published by the Free Software Foundation.
+ * SPDX-License-Identifier: LGPL-2.1-only
  *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <assert.h>
@@ -294,11 +284,13 @@ end:
 
 void lttng_tracker_ids_destroy(struct lttng_tracker_ids *ids)
 {
+       int i;
+
        if (!ids) {
                return;
        }
 
-       for (int i = 0; i < ids->count; i++) {
+       for (i = 0; i < ids->count; i++) {
                lttng_tracker_id_reset(&ids->id_array[i]);
        }
        free(ids->id_array);
@@ -308,12 +300,13 @@ void lttng_tracker_ids_destroy(struct lttng_tracker_ids *ids)
 int lttng_tracker_ids_serialize(const struct lttng_tracker_ids *ids,
                struct lttng_dynamic_buffer *buffer)
 {
-       int ret;
+       int ret = 0;
        int value;
-       const char *string;
+       const char *string = NULL;
        unsigned int count;
        enum lttng_tracker_id_status status;
        const struct lttng_tracker_id *id;
+       unsigned int i;
 
        status = lttng_tracker_ids_get_count(ids, &count);
        if (status != LTTNG_TRACKER_ID_STATUS_OK) {
@@ -321,7 +314,7 @@ int lttng_tracker_ids_serialize(const struct lttng_tracker_ids *ids,
                goto error;
        }
 
-       for (unsigned int i = 0; i < count; i++) {
+       for (i = 0; i < count; i++) {
                struct lttcomm_tracker_id_header id_hdr;
                size_t var_data_len = 0;
 
This page took 0.023802 seconds and 4 git commands to generate.