From 3034fe9f4d33c0bdd4f8998495fdee260ea27069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= Date: Fri, 12 Dec 2014 21:38:37 +0100 Subject: [PATCH] cli: fix DEADCODE (CWE-561) found by coverity Error: DEADCODE (CWE-561): [#def3] NetworkManager-0.9.11.0/clients/cli/utils.c:488: cond_notnull: Condition "input", taking true branch. Now the value of "input" is not "NULL". NetworkManager-0.9.11.0/clients/cli/utils.c:517: notnull: At condition "input", the value of "input" cannot be "NULL". NetworkManager-0.9.11.0/clients/cli/utils.c:517: dead_error_condition: The condition "input" must be true. NetworkManager-0.9.11.0/clients/cli/utils.c:517: dead_error_line: Execution cannot reach the expression """" inside this statement: "g_set_error(error, 1U, 0, d...". (cherry picked from commit bcd5b2cdc1d81c7914c6aa490dd140ce7046a625) --- clients/cli/utils.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/clients/cli/utils.c b/clients/cli/utils.c index cb8fbf018a..60cf9f93f5 100644 --- a/clients/cli/utils.c +++ b/clients/cli/utils.c @@ -510,13 +510,10 @@ nmc_string_is_valid (const char *input, const char **allowed, GError **error) finish: if (ret == NULL) { char *valid_vals = g_strjoinv (", ", (char **) allowed); - if (!input || !*input) { - g_set_error (error, 1, 0, _("missing name, try one of [%s]"), - valid_vals); - } else { - g_set_error (error, 1, 0, _("'%s' not among [%s]"), - input ? input : "", valid_vals); - } + if (!input || !*input) + g_set_error (error, 1, 0, _("missing name, try one of [%s]"), valid_vals); + else + g_set_error (error, 1, 0, _("'%s' not among [%s]"), input, valid_vals); g_free (valid_vals); }