X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fmi-lttng.c;h=f9f1e225aec32f1b383022e4a2afb55b2e9f90da;hp=f884f9385de317c72b68422e626a281878f6e1e9;hb=f5112e978f61eb82bf487cfa9efa2de359d37661;hpb=83d6d6c4496e692df39843142cb8cf96279eaa20 diff --git a/src/common/mi-lttng.c b/src/common/mi-lttng.c index f884f9385..f9f1e225a 100644 --- a/src/common/mi-lttng.c +++ b/src/common/mi-lttng.c @@ -1,26 +1,17 @@ /* - * Copyright (C) 2014 - Jonathan Rajotte - * - Olivier Cotte - * Copyright (C) 2016 - Jérémie Galarneau + * Copyright (C) 2014 Jonathan Rajotte + * Copyright (C) 2014 Olivier Cotte + * Copyright (C) 2016 Jérémie Galarneau * - * 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 #include #include +#include #include #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);