Clean-up: mi: remove logically dead code
[lttng-tools.git] / src / common / mi-lttng.c
index f884f9385de317c72b68422e626a281878f6e1e9..f9f1e225aec32f1b383022e4a2afb55b2e9f90da 100644 (file)
@@ -1,26 +1,17 @@
 /*
- * Copyright (C) 2014 Jonathan Rajotte <jonathan.r.julien@gmail.com>
- *                    - Olivier Cotte <olivier.cotte@polymtl.ca>
- * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ * Copyright (C) 2014 Jonathan Rajotte <jonathan.r.julien@gmail.com>
+ * Copyright (C) 2014 Olivier Cotte <olivier.cotte@polymtl.ca>
+ * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
+ * SPDX-License-Identifier: GPL-2.0-only
  *
- * This program 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 General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #define _LGPL_SOURCE
 #include <common/config/session-config.h>
 #include <common/defaults.h>
 #include <lttng/snapshot-internal.h>
+#include <lttng/tracker-internal.h>
 #include <lttng/channel.h>
 #include "mi-lttng.h"
 
@@ -1661,11 +1652,14 @@ int mi_lttng_targets_open(struct mi_writer *writer)
 LTTNG_HIDDEN
 int mi_lttng_id_target(struct mi_writer *writer,
                enum lttng_tracker_type tracker_type,
-               struct lttng_tracker_id *id,
+               const struct lttng_tracker_id *id,
                int is_open)
 {
        int ret;
        const char *element_id_tracker, *element_target_id;
+       enum lttng_tracker_id_status status;
+       int value;
+       const char *string;
 
        ret = get_tracker_elements(
                        tracker_type, &element_id_tracker, &element_target_id);
@@ -1673,7 +1667,7 @@ int mi_lttng_id_target(struct mi_writer *writer,
                return ret;
        }
 
-       switch (id->type) {
+       switch (lttng_tracker_id_get_type(id)) {
        case LTTNG_ID_ALL:
                ret = mi_lttng_writer_open_element(writer, element_target_id);
                if (ret) {
@@ -1702,8 +1696,15 @@ int mi_lttng_id_target(struct mi_writer *writer,
                if (ret) {
                        goto end;
                }
+
+               status = lttng_tracker_id_get_value(id, &value);
+               if (status != LTTNG_TRACKER_ID_STATUS_OK) {
+                       ret = -1;
+                       goto end;
+               }
+
                ret = mi_lttng_writer_write_element_signed_int(
-                               writer, config_element_id, id->value);
+                               writer, config_element_id, value);
                if (ret) {
                        goto end;
                }
@@ -1721,8 +1722,15 @@ int mi_lttng_id_target(struct mi_writer *writer,
                if (ret) {
                        goto end;
                }
+
+               status = lttng_tracker_id_get_string(id, &string);
+               if (status != LTTNG_TRACKER_ID_STATUS_OK) {
+                       ret = -1;
+                       goto end;
+               }
+
                ret = mi_lttng_writer_write_element_string(
-                               writer, config_element_name, id->string);
+                               writer, config_element_name, string);
                if (ret) {
                        goto end;
                }
@@ -1735,9 +1743,6 @@ int mi_lttng_id_target(struct mi_writer *writer,
                ret = -LTTNG_ERR_INVALID;
                goto end;
        }
-       if (ret) {
-               goto end;
-       }
 
        if (!is_open) {
                ret = mi_lttng_writer_close_element(writer);
This page took 0.024811 seconds and 4 git commands to generate.