diff options
| author | Sebastien Bacher <seb128@ubuntu.com> | 2021-02-25 11:36:45 +0100 |
|---|---|---|
| committer | Sebastien Bacher <seb128@ubuntu.com> | 2021-02-25 11:36:45 +0100 |
| commit | d92aa7f298fe84d4cf686c5ad64b73438e00d377 (patch) | |
| tree | 2f1f4c7b48cff9e63b0d0e3669bada3d9aeda72e /clients/cli/utils.c | |
| parent | a82e048a943092315a32d745c99e0f5635e29134 (diff) | |
| parent | 3a56bce6c0ea7ba0fe269520547740783b342e0d (diff) | |
Merge branch 'upstream/latest' of https://salsa.debian.org/utopia-team/network-manager into upstream/latest
Diffstat (limited to 'clients/cli/utils.c')
| -rw-r--r-- | clients/cli/utils.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/clients/cli/utils.c b/clients/cli/utils.c index 2e7b22ce..0a62c35c 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -1,10 +1,10 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ +/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * Copyright (C) 2010 Lennart Poettering * Copyright (C) 2010 - 2018 Red Hat, Inc. */ -#include "nm-default.h" +#include "libnm/nm-default-client.h" #include "utils.h" @@ -374,23 +374,21 @@ nmc_terminal_show_progress(const char *str) char * nmc_colorize(const NmcConfig *nmc_config, NMMetaColor color, const char *fmt, ...) { - va_list args; - char * str, *colored; - const char *ansi_seq = NULL; + va_list args; + gs_free char *str = NULL; + const char * ansi_seq = NULL; va_start(args, fmt); str = g_strdup_vprintf(fmt, args); va_end(args); if (nmc_config->use_colors) - ansi_seq = nmc_config->palette[color]; + ansi_seq = nmc_config->palette.ansi_seq[color]; - if (ansi_seq == NULL) - return str; + if (!ansi_seq) + return g_steal_pointer(&str); - colored = g_strdup_printf("\33[%sm%s\33[0m", ansi_seq, str); - g_free(str); - return colored; + return g_strdup_printf("\33[%sm%s\33[0m", ansi_seq, str); } /* |