mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 04:32:37 +01:00
client: Enable lookup of command options with no arguments.
Previously, command_option_get used to return NULL in the following two scenarios: when command-line option with a such name didn’t exists or its argument was not provided. This worked great for the cmd-line options with the required arguments. With introduction of the cmd-line options with no or optional arguments the function was changed to return a boolean value indicating the existence of a such option and then, if it had an argument - value_out variable would have been set. Thereafter, this patch modifies the current usages of command_option_get. Note, in these particular applications of command_option_get there is no need to check the returned value from command_option_get, since these options have the required arguments and we can only check if the value_out parameter has been set or not.
This commit is contained in:
parent
27ae3ce14d
commit
0a1cd37228
@ -66,9 +66,9 @@ static struct l_dbus_message *request_passphrase_command_option(
|
||||
struct l_dbus_message *message)
|
||||
{
|
||||
struct l_dbus_message *reply;
|
||||
const char *passphrase;
|
||||
const char *passphrase = NULL;
|
||||
|
||||
passphrase = command_option_get(COMMAND_OPTION_PASSPHRASE);
|
||||
command_option_get(COMMAND_OPTION_PASSPHRASE, &passphrase);
|
||||
if (!passphrase)
|
||||
return NULL;
|
||||
|
||||
@ -154,14 +154,14 @@ static struct l_dbus_message *request_username_and_password_command_option(
|
||||
struct l_dbus_message *message)
|
||||
{
|
||||
struct l_dbus_message *reply;
|
||||
const char *username;
|
||||
const char *password;
|
||||
const char *username = NULL;
|
||||
const char *password = NULL;
|
||||
|
||||
username = command_option_get(COMMAND_OPTION_USERNAME);
|
||||
command_option_get(COMMAND_OPTION_USERNAME, &username);
|
||||
if (!username)
|
||||
return NULL;
|
||||
|
||||
password = command_option_get(COMMAND_OPTION_PASSWORD);
|
||||
command_option_get(COMMAND_OPTION_PASSWORD, &password);
|
||||
if (!password)
|
||||
return NULL;
|
||||
|
||||
@ -213,7 +213,7 @@ static struct l_dbus_message *request_user_password_command_option(
|
||||
struct l_dbus_message *reply;
|
||||
const char *password;
|
||||
|
||||
password = command_option_get(COMMAND_OPTION_PASSWORD);
|
||||
command_option_get(COMMAND_OPTION_PASSWORD, &password);
|
||||
if (!password)
|
||||
return NULL;
|
||||
|
||||
|
@ -56,7 +56,7 @@ static void command_options_destroy(void *data)
|
||||
l_free(option);
|
||||
}
|
||||
|
||||
const char *command_option_get(const char *name)
|
||||
bool command_option_get(const char *name, const char **value_out)
|
||||
{
|
||||
const struct l_queue_entry *entry;
|
||||
|
||||
@ -67,10 +67,13 @@ const char *command_option_get(const char *name)
|
||||
if (strcmp(option->name, name))
|
||||
continue;
|
||||
|
||||
return option->value;
|
||||
if (value_out)
|
||||
*value_out = option->value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool command_has_options(void)
|
||||
|
@ -56,7 +56,7 @@ struct command_family {
|
||||
void (*reset_default_entity)(void);
|
||||
};
|
||||
|
||||
const char *command_option_get(const char *name);
|
||||
bool command_option_get(const char *name, const char **value_out);
|
||||
bool command_has_options(void);
|
||||
|
||||
bool command_line_find_token(const char *token, uint8_t num_to_inspect);
|
||||
|
Loading…
Reference in New Issue
Block a user