X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.cpp;h=444a96b40a5e4957177109777196360c7ce9adf7;hb=c9e313bc594f40a86eed237dce222c0fc99c957f;hp=4bb681e09c1a9dca8850242dfc156c98beb8e62e;hpb=48a4000561343808724f7cb5fa8c131877489ccd;p=lttng-tools.git diff --git a/src/bin/lttng/commands/list.cpp b/src/bin/lttng/commands/list.cpp index 4bb681e09..444a96b40 100644 --- a/src/bin/lttng/commands/list.cpp +++ b/src/bin/lttng/commands/list.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 David Goulet + * Copyright (C) 2011 EfficiOS Inc. * Copyright (C) 2020 Jérémie Galarneau * * SPDX-License-Identifier: GPL-2.0-only @@ -14,13 +14,13 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include -#include "../command.h" +#include "../command.hpp" static int opt_userspace; static int opt_kernel; @@ -338,13 +338,8 @@ static void print_events(struct lttng_event *event) if (ret) { filter_msg = strdup(" [failed to retrieve filter]"); } else if (filter_str) { - const char * const filter_fmt = " [filter: '%s']"; - - filter_msg = (char *) malloc(strlen(filter_str) + - strlen(filter_fmt) + 1); - if (filter_msg) { - sprintf(filter_msg, filter_fmt, - filter_str); + if (asprintf(&filter_msg, " [filter: '%s']", filter_str) == -1) { + filter_msg = NULL; } } @@ -1151,14 +1146,8 @@ static int list_session_agent_events(void) if (ret) { filter_msg = strdup(" [failed to retrieve filter]"); } else if (filter_str) { - const char * const filter_fmt = - " [filter: '%s']"; - - filter_msg = (char *) malloc(strlen(filter_str) + - strlen(filter_fmt) + 1); - if (filter_msg) { - sprintf(filter_msg, filter_fmt, - filter_str); + if (asprintf(&filter_msg, " [filter: '%s']", filter_str) == -1) { + filter_msg = NULL; } }