X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbin%2Flttng-sessiond%2Fclient.c;h=473491f37965459ffb2d260601f05d273b0b7260;hb=b53d4e59bf0a980aa774dcccc27123986e77b8ff;hp=8eff1650ebfe1036f83fced7929f0e136c044ffd;hpb=a7a533cd65d544e8beebabcca5fe906e27af4707;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/client.c b/src/bin/lttng-sessiond/client.c index 8eff1650e..473491f37 100644 --- a/src/bin/lttng-sessiond/client.c +++ b/src/bin/lttng-sessiond/client.c @@ -1,20 +1,10 @@ /* - * Copyright (C) 2011 - David Goulet - * Mathieu Desnoyers - * 2013 - Jérémie Galarneau + * Copyright (C) 2011 David Goulet + * Copyright (C) 2011 Mathieu Desnoyers + * Copyright (C) 2013 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. */ #include @@ -28,6 +18,7 @@ #include #include #include +#include #include "client.h" #include "lttng-sessiond.h" @@ -191,7 +182,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) case LTTNG_CONSUMER64_UST: { if (config.consumerd64_lib_dir.value) { - char *tmp; + const char *tmp; size_t tmplen; char *tmpnew; @@ -228,7 +219,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) case LTTNG_CONSUMER32_UST: { if (config.consumerd32_lib_dir.value) { - char *tmp; + const char *tmp; size_t tmplen; char *tmpnew; @@ -1569,7 +1560,8 @@ error_add_context: { struct lttcomm_tracker_command_header cmd_header; struct lttng_tracker_ids *ids = NULL; - size_t nr_ids, i; + enum lttng_tracker_id_status status; + unsigned int nr_ids; struct lttng_dynamic_buffer buf; ret = cmd_list_tracker_ids( @@ -1580,72 +1572,28 @@ error_add_context: goto error; } - nr_ids = lttng_tracker_ids_get_count(ids); lttng_dynamic_buffer_init(&buf); - for (i = 0; i < nr_ids; i++) { - const struct lttng_tracker_id *id; - struct lttcomm_tracker_id_header id_hdr; - size_t var_data_len = 0; - enum lttng_tracker_id_status status; - const char *string; - int value; - - id = lttng_tracker_ids_get_at_index(ids, i); - if (!id) { - ret = LTTNG_ERR_INVALID; - goto error_list_tracker; - } - memset(&id_hdr, 0, sizeof(id_hdr)); - id_hdr.type = lttng_tracker_id_get_type(id); - switch (id_hdr.type) { - case LTTNG_ID_ALL: - break; - case LTTNG_ID_VALUE: - status = lttng_tracker_id_get_value(id, &value); - id_hdr.u.value = value; - if (status != LTTNG_TRACKER_ID_STATUS_OK) { - ret = LTTNG_ERR_INVALID; - goto error_list_tracker; - } - break; - case LTTNG_ID_STRING: - status = lttng_tracker_id_get_string( - id, &string); - if (status != LTTNG_TRACKER_ID_STATUS_OK) { - ret = LTTNG_ERR_INVALID; - goto error_list_tracker; - } - - id_hdr.u.var_data_len = var_data_len = - strlen(string) + 1; - break; - default: - ret = LTTNG_ERR_INVALID; - goto error_list_tracker; - } - ret = lttng_dynamic_buffer_append( - &buf, &id_hdr, sizeof(id_hdr)); - if (ret) { - ret = LTTNG_ERR_NOMEM; - goto error_list_tracker; - } - ret = lttng_dynamic_buffer_append( - &buf, string, var_data_len); - if (ret) { - ret = LTTNG_ERR_NOMEM; - goto error_list_tracker; - } + status = lttng_tracker_ids_get_count(ids, &nr_ids); + if (status != LTTNG_TRACKER_ID_STATUS_OK) { + ret = -LTTNG_ERR_INVALID; + goto error_list_tracker; } cmd_header.nb_tracker_id = nr_ids; + + ret = lttng_tracker_ids_serialize(ids, &buf); + if (ret < 0) { + goto error_list_tracker; + } + ret = setup_lttng_msg(cmd_ctx, buf.data, buf.size, &cmd_header, sizeof(cmd_header)); error_list_tracker: lttng_tracker_ids_destroy(ids); lttng_dynamic_buffer_reset(&buf); if (ret < 0) { - goto setup_error; + goto error; } ret = LTTNG_OK;