cli: drop unnecessary NULL sentinel from nmc_complete_strings()
Since commit 62b939de4e
('cli: add nmc_complete_strv() which takes a
string array for completion that may contain NULL'), the sentinel is
no longer needed.
This commit is contained in:
@@ -446,7 +446,7 @@ nmc_find_connection (const GPtrArray *connections,
|
|||||||
if (NM_IN_STRSET (filter_type, NULL, "id")) {
|
if (NM_IN_STRSET (filter_type, NULL, "id")) {
|
||||||
v = nm_connection_get_id (connection);
|
v = nm_connection_get_id (connection);
|
||||||
if (complete)
|
if (complete)
|
||||||
nmc_complete_strings (filter_val, v, NULL);
|
nmc_complete_strings (filter_val, v);
|
||||||
if (nm_streq0 (filter_val, v))
|
if (nm_streq0 (filter_val, v))
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
@@ -454,7 +454,7 @@ nmc_find_connection (const GPtrArray *connections,
|
|||||||
if (NM_IN_STRSET (filter_type, NULL, "uuid")) {
|
if (NM_IN_STRSET (filter_type, NULL, "uuid")) {
|
||||||
v = nm_connection_get_uuid (connection);
|
v = nm_connection_get_uuid (connection);
|
||||||
if (complete && (filter_type || *filter_val))
|
if (complete && (filter_type || *filter_val))
|
||||||
nmc_complete_strings (filter_val, v, NULL);
|
nmc_complete_strings (filter_val, v);
|
||||||
if (nm_streq0 (filter_val, v))
|
if (nm_streq0 (filter_val, v))
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
@@ -463,7 +463,7 @@ nmc_find_connection (const GPtrArray *connections,
|
|||||||
v = nm_connection_get_path (connection);
|
v = nm_connection_get_path (connection);
|
||||||
v_num = nm_utils_dbus_path_get_last_component (v);
|
v_num = nm_utils_dbus_path_get_last_component (v);
|
||||||
if (complete && (filter_type || *filter_val))
|
if (complete && (filter_type || *filter_val))
|
||||||
nmc_complete_strings (filter_val, v, filter_type ? v_num : NULL, NULL);
|
nmc_complete_strings (filter_val, v, filter_type ? v_num : NULL);
|
||||||
if ( nm_streq0 (filter_val, v)
|
if ( nm_streq0 (filter_val, v)
|
||||||
|| (filter_type && nm_streq0 (filter_val, v_num)))
|
|| (filter_type && nm_streq0 (filter_val, v_num)))
|
||||||
goto found;
|
goto found;
|
||||||
@@ -472,7 +472,7 @@ nmc_find_connection (const GPtrArray *connections,
|
|||||||
if (NM_IN_STRSET (filter_type, NULL, "filename")) {
|
if (NM_IN_STRSET (filter_type, NULL, "filename")) {
|
||||||
v = nm_remote_connection_get_filename (NM_REMOTE_CONNECTION (connections->pdata[i]));
|
v = nm_remote_connection_get_filename (NM_REMOTE_CONNECTION (connections->pdata[i]));
|
||||||
if (complete && (filter_type || *filter_val))
|
if (complete && (filter_type || *filter_val))
|
||||||
nmc_complete_strings (filter_val, v, NULL);
|
nmc_complete_strings (filter_val, v);
|
||||||
if (nm_streq0 (filter_val, v))
|
if (nm_streq0 (filter_val, v))
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
@@ -525,7 +525,7 @@ nmc_find_active_connection (const GPtrArray *active_cons,
|
|||||||
if (NM_IN_STRSET (filter_type, NULL, "id")) {
|
if (NM_IN_STRSET (filter_type, NULL, "id")) {
|
||||||
v = nm_active_connection_get_id (candidate);
|
v = nm_active_connection_get_id (candidate);
|
||||||
if (complete)
|
if (complete)
|
||||||
nmc_complete_strings (filter_val, v, NULL);
|
nmc_complete_strings (filter_val, v);
|
||||||
if (nm_streq0 (filter_val, v))
|
if (nm_streq0 (filter_val, v))
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
@@ -533,7 +533,7 @@ nmc_find_active_connection (const GPtrArray *active_cons,
|
|||||||
if (NM_IN_STRSET (filter_type, NULL, "uuid")) {
|
if (NM_IN_STRSET (filter_type, NULL, "uuid")) {
|
||||||
v = nm_active_connection_get_uuid (candidate);
|
v = nm_active_connection_get_uuid (candidate);
|
||||||
if (complete && (filter_type || *filter_val))
|
if (complete && (filter_type || *filter_val))
|
||||||
nmc_complete_strings (filter_val, v, NULL);
|
nmc_complete_strings (filter_val, v);
|
||||||
if (nm_streq0 (filter_val, v))
|
if (nm_streq0 (filter_val, v))
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
@@ -542,7 +542,7 @@ nmc_find_active_connection (const GPtrArray *active_cons,
|
|||||||
v = con ? nm_connection_get_path (NM_CONNECTION (con)) : NULL;
|
v = con ? nm_connection_get_path (NM_CONNECTION (con)) : NULL;
|
||||||
v_num = nm_utils_dbus_path_get_last_component (v);
|
v_num = nm_utils_dbus_path_get_last_component (v);
|
||||||
if (complete && (filter_type || *filter_val))
|
if (complete && (filter_type || *filter_val))
|
||||||
nmc_complete_strings (filter_val, v, filter_type ? v_num : NULL, NULL);
|
nmc_complete_strings (filter_val, v, filter_type ? v_num : NULL);
|
||||||
if ( nm_streq0 (filter_val, v)
|
if ( nm_streq0 (filter_val, v)
|
||||||
|| (filter_type && nm_streq0 (filter_val, v_num)))
|
|| (filter_type && nm_streq0 (filter_val, v_num)))
|
||||||
goto found;
|
goto found;
|
||||||
@@ -551,7 +551,7 @@ nmc_find_active_connection (const GPtrArray *active_cons,
|
|||||||
if (NM_IN_STRSET (filter_type, NULL, "filename")) {
|
if (NM_IN_STRSET (filter_type, NULL, "filename")) {
|
||||||
v = nm_remote_connection_get_filename (con);
|
v = nm_remote_connection_get_filename (con);
|
||||||
if (complete && (filter_type || *filter_val))
|
if (complete && (filter_type || *filter_val))
|
||||||
nmc_complete_strings (filter_val, v, NULL);
|
nmc_complete_strings (filter_val, v);
|
||||||
if (nm_streq0 (filter_val, v))
|
if (nm_streq0 (filter_val, v))
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
@@ -560,7 +560,7 @@ nmc_find_active_connection (const GPtrArray *active_cons,
|
|||||||
v = nm_object_get_path (NM_OBJECT (candidate));
|
v = nm_object_get_path (NM_OBJECT (candidate));
|
||||||
v_num = nm_utils_dbus_path_get_last_component (v);
|
v_num = nm_utils_dbus_path_get_last_component (v);
|
||||||
if (complete && (filter_type || *filter_val))
|
if (complete && (filter_type || *filter_val))
|
||||||
nmc_complete_strings (filter_val, v, filter_type ? v_num : NULL, NULL);
|
nmc_complete_strings (filter_val, v, filter_type ? v_num : NULL);
|
||||||
if ( nm_streq0 (filter_val, v)
|
if ( nm_streq0 (filter_val, v)
|
||||||
|| (filter_type && nm_streq0 (filter_val, v_num)))
|
|| (filter_type && nm_streq0 (filter_val, v_num)))
|
||||||
goto found;
|
goto found;
|
||||||
@@ -1254,9 +1254,9 @@ call_cmd (NmCli *nmc, GSimpleAsyncResult *simple, const NMCCommand *cmd, int arg
|
|||||||
static void
|
static void
|
||||||
nmc_complete_help (const char *prefix)
|
nmc_complete_help (const char *prefix)
|
||||||
{
|
{
|
||||||
nmc_complete_strings (prefix, "help", NULL);
|
nmc_complete_strings (prefix, "help");
|
||||||
if (*prefix == '-')
|
if (*prefix == '-')
|
||||||
nmc_complete_strings (prefix, "-help", "--help", NULL);
|
nmc_complete_strings (prefix, "-help", "--help");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1395,7 +1395,7 @@ void
|
|||||||
nmc_complete_bool (const char *prefix)
|
nmc_complete_bool (const char *prefix)
|
||||||
{
|
{
|
||||||
nmc_complete_strings (prefix, "true", "yes", "on",
|
nmc_complete_strings (prefix, "true", "yes", "on",
|
||||||
"false", "no", "off", NULL);
|
"false", "no", "off");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1941,7 +1941,7 @@ get_connection (NmCli *nmc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (*argc == 1 && nmc->complete)
|
if (*argc == 1 && nmc->complete)
|
||||||
nmc_complete_strings (**argv, "id", "uuid", "path", "filename", NULL);
|
nmc_complete_strings (**argv, "id", "uuid", "path", "filename");
|
||||||
|
|
||||||
if (NM_IN_STRSET (**argv, "id", "uuid", "path", "filename")) {
|
if (NM_IN_STRSET (**argv, "id", "uuid", "path", "filename")) {
|
||||||
if (*argc == 1) {
|
if (*argc == 1) {
|
||||||
@@ -2100,7 +2100,7 @@ do_connections_show (NmCli *nmc, int argc, char **argv)
|
|||||||
guint i_found_cons;
|
guint i_found_cons;
|
||||||
|
|
||||||
if (argc == 1 && nmc->complete)
|
if (argc == 1 && nmc->complete)
|
||||||
nmc_complete_strings (*argv, "id", "uuid", "path", "filename", "apath", NULL);
|
nmc_complete_strings (*argv, "id", "uuid", "path", "filename", "apath");
|
||||||
|
|
||||||
if (NM_IN_STRSET (*argv, "id", "uuid", "path", "filename", "apath")) {
|
if (NM_IN_STRSET (*argv, "id", "uuid", "path", "filename", "apath")) {
|
||||||
selector = *argv;
|
selector = *argv;
|
||||||
@@ -2846,7 +2846,7 @@ do_connection_up (NmCli *nmc, int argc, char **argv)
|
|||||||
|
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (argc == 1 && nmc->complete)
|
if (argc == 1 && nmc->complete)
|
||||||
nmc_complete_strings (*argv, "ifname", "ap", "passwd-file", NULL);
|
nmc_complete_strings (*argv, "ifname", "ap", "passwd-file");
|
||||||
|
|
||||||
if (strcmp (*argv, "ifname") == 0) {
|
if (strcmp (*argv, "ifname") == 0) {
|
||||||
argc--;
|
argc--;
|
||||||
@@ -3098,7 +3098,7 @@ do_connection_down (NmCli *nmc, int argc, char **argv)
|
|||||||
const char *selector = NULL;
|
const char *selector = NULL;
|
||||||
|
|
||||||
if (arg_num == 1 && nmc->complete)
|
if (arg_num == 1 && nmc->complete)
|
||||||
nmc_complete_strings (*arg_ptr, "id", "uuid", "path", "filename", "apath", NULL);
|
nmc_complete_strings (*arg_ptr, "id", "uuid", "path", "filename", "apath");
|
||||||
|
|
||||||
if (NM_IN_STRSET (*arg_ptr, "id", "uuid", "path", "filename", "apath")) {
|
if (NM_IN_STRSET (*arg_ptr, "id", "uuid", "path", "filename", "apath")) {
|
||||||
selector = *arg_ptr;
|
selector = *arg_ptr;
|
||||||
@@ -8167,7 +8167,7 @@ do_connection_edit (NmCli *nmc, int argc, char **argv)
|
|||||||
|
|
||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
if (argc == 1 && nmc->complete)
|
if (argc == 1 && nmc->complete)
|
||||||
nmc_complete_strings (*argv, "type", "con-name", "id", "uuid", "path", "filename", NULL);
|
nmc_complete_strings (*argv, "type", "con-name", "id", "uuid", "path", "filename");
|
||||||
|
|
||||||
nmc->return_value = NMC_RESULT_SUCCESS;
|
nmc->return_value = NMC_RESULT_SUCCESS;
|
||||||
|
|
||||||
|
@@ -2473,7 +2473,7 @@ do_device_set (NmCli *nmc, int argc, char **argv)
|
|||||||
gboolean flag;
|
gboolean flag;
|
||||||
|
|
||||||
if (argc == 1 && nmc->complete)
|
if (argc == 1 && nmc->complete)
|
||||||
nmc_complete_strings (*argv, "managed", "autoconnect", NULL);
|
nmc_complete_strings (*argv, "managed", "autoconnect");
|
||||||
|
|
||||||
if (matches (*argv, "managed")) {
|
if (matches (*argv, "managed")) {
|
||||||
argc--;
|
argc--;
|
||||||
@@ -2997,7 +2997,7 @@ do_device_wifi_list (NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
rescan = *argv;
|
rescan = *argv;
|
||||||
if (argc == 1 && nmc->complete)
|
if (argc == 1 && nmc->complete)
|
||||||
nmc_complete_strings (rescan, "auto", "no", "yes", NULL);
|
nmc_complete_strings (rescan, "auto", "no", "yes");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached();
|
g_assert_not_reached();
|
||||||
@@ -3179,7 +3179,7 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
|
|||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (argc == 1 && nmc->complete) {
|
if (argc == 1 && nmc->complete) {
|
||||||
nmc_complete_strings (*argv, "ifname", "bssid", "password", "wep-key-type",
|
nmc_complete_strings (*argv, "ifname", "bssid", "password", "wep-key-type",
|
||||||
"name", "private", "hidden", NULL);
|
"name", "private", "hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp (*argv, "ifname") == 0) {
|
if (strcmp (*argv, "ifname") == 0) {
|
||||||
@@ -3229,7 +3229,7 @@ do_device_wifi_connect_network (NmCli *nmc, int argc, char **argv)
|
|||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
if (argc == 1 && nmc->complete)
|
if (argc == 1 && nmc->complete)
|
||||||
nmc_complete_strings (*argv, "key", "phrase", NULL);
|
nmc_complete_strings (*argv, "key", "phrase");
|
||||||
if (strcmp (*argv, "key") == 0)
|
if (strcmp (*argv, "key") == 0)
|
||||||
wep_passphrase = FALSE;
|
wep_passphrase = FALSE;
|
||||||
else if (strcmp (*argv, "phrase") == 0)
|
else if (strcmp (*argv, "phrase") == 0)
|
||||||
@@ -3711,7 +3711,7 @@ do_device_wifi_hotspot (NmCli *nmc, int argc, char **argv)
|
|||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (argc == 1 && nmc->complete) {
|
if (argc == 1 && nmc->complete) {
|
||||||
nmc_complete_strings (*argv, "ifname", "con-name", "ssid", "band",
|
nmc_complete_strings (*argv, "ifname", "con-name", "ssid", "band",
|
||||||
"channel", "password", NULL);
|
"channel", "password");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp (*argv, "ifname") == 0) {
|
if (strcmp (*argv, "ifname") == 0) {
|
||||||
@@ -3753,7 +3753,7 @@ do_device_wifi_hotspot (NmCli *nmc, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
band = *argv;
|
band = *argv;
|
||||||
if (argc == 1 && nmc->complete)
|
if (argc == 1 && nmc->complete)
|
||||||
nmc_complete_strings (band, "a", "bg", NULL);
|
nmc_complete_strings (band, "a", "bg");
|
||||||
if (strcmp (band, "a") && strcmp (band, "bg")) {
|
if (strcmp (band, "a") && strcmp (band, "bg")) {
|
||||||
g_string_printf (nmc->return_text, _("Error: band argument value '%s' is invalid; use 'a' or 'bg'."),
|
g_string_printf (nmc->return_text, _("Error: band argument value '%s' is invalid; use 'a' or 'bg'."),
|
||||||
band);
|
band);
|
||||||
@@ -3935,7 +3935,7 @@ do_device_wifi_rescan (NmCli *nmc, int argc, char **argv)
|
|||||||
/* Get the parameters */
|
/* Get the parameters */
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (argc == 1 && nmc->complete)
|
if (argc == 1 && nmc->complete)
|
||||||
nmc_complete_strings (*argv, "ifname", "ssid", NULL);
|
nmc_complete_strings (*argv, "ifname", "ssid");
|
||||||
|
|
||||||
if (strcmp (*argv, "ifname") == 0) {
|
if (strcmp (*argv, "ifname") == 0) {
|
||||||
if (ifname) {
|
if (ifname) {
|
||||||
@@ -4122,7 +4122,7 @@ do_device_lldp_list (NmCli *nmc, int argc, char **argv)
|
|||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (argc == 1 && nmc->complete)
|
if (argc == 1 && nmc->complete)
|
||||||
nmc_complete_strings (*argv, "ifname", NULL);
|
nmc_complete_strings (*argv, "ifname");
|
||||||
|
|
||||||
if (strcmp (*argv, "ifname") == 0) {
|
if (strcmp (*argv, "ifname") == 0) {
|
||||||
argc--;
|
argc--;
|
||||||
|
@@ -683,7 +683,7 @@ do_general_logging (NmCli *nmc, int argc, char **argv)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
if (argc == 1 && nmc->complete)
|
if (argc == 1 && nmc->complete)
|
||||||
nmc_complete_strings (*argv, "level", "domains", NULL);
|
nmc_complete_strings (*argv, "level", "domains");
|
||||||
|
|
||||||
if (matches (*argv, "level")) {
|
if (matches (*argv, "level")) {
|
||||||
argc--;
|
argc--;
|
||||||
@@ -878,7 +878,7 @@ do_networking_connectivity (NmCli *nmc, int argc, char **argv)
|
|||||||
next_arg (nmc, &argc, &argv, NULL);
|
next_arg (nmc, &argc, &argv, NULL);
|
||||||
if (nmc->complete) {
|
if (nmc->complete) {
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
nmc_complete_strings (*argv, "check", NULL);
|
nmc_complete_strings (*argv, "check");
|
||||||
return nmc->return_value;
|
return nmc->return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -732,7 +732,7 @@ process_command_line (NmCli *nmc, int argc, char **argv)
|
|||||||
nmc_complete_strings (argv[0], "--terse", "--pretty", "--mode", "--overview",
|
nmc_complete_strings (argv[0], "--terse", "--pretty", "--mode", "--overview",
|
||||||
"--colors", "--escape",
|
"--colors", "--escape",
|
||||||
"--fields", "--nocheck", "--get-values",
|
"--fields", "--nocheck", "--get-values",
|
||||||
"--wait", "--version", "--help", NULL);
|
"--wait", "--version", "--help");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argv[0][1] == '-' && argv[0][2] == '\0') {
|
if (argv[0][1] == '-' && argv[0][2] == '\0') {
|
||||||
|
@@ -189,10 +189,10 @@ next_arg (NmCli *nmc, int *argc, char ***argv, ...)
|
|||||||
|
|
||||||
if (nmc && nmc->complete && *argc == 1) {
|
if (nmc && nmc->complete && *argc == 1) {
|
||||||
while ((cmd_option = va_arg (args, const char *)))
|
while ((cmd_option = va_arg (args, const char *)))
|
||||||
nmc_complete_strings (**argv, cmd_option, NULL);
|
nmc_complete_strings (**argv, cmd_option);
|
||||||
|
|
||||||
if (***argv == '-')
|
if (***argv == '-')
|
||||||
nmc_complete_strings (**argv, "--ask", "--show-secrets", NULL);
|
nmc_complete_strings (**argv, "--ask", "--show-secrets");
|
||||||
|
|
||||||
va_end (args);
|
va_end (args);
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user