diff --git a/client/agent.c b/client/agent.c index 0ff33b12..121a16ae 100644 --- a/client/agent.c +++ b/client/agent.c @@ -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; diff --git a/client/command.c b/client/command.c index ec3d3457..707f7f5b 100644 --- a/client/command.c +++ b/client/command.c @@ -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) diff --git a/client/command.h b/client/command.h index 88f2672d..4b2f4de3 100644 --- a/client/command.h +++ b/client/command.h @@ -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);