From f7b4069ac212b718369c806939de9486ee0f8150 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 11 Apr 2019 15:15:57 +0300 Subject: [PATCH] Bluetooth: Settings: Fix not allowing custom handlers without arguments Custom handlers without any arguments don't since there is a check for argc > 1, to fix this behavior removing the check. Signed-off-by: Luiz Augusto von Dentz --- subsys/bluetooth/host/settings.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/subsys/bluetooth/host/settings.c b/subsys/bluetooth/host/settings.c index e112374b637..277aa756e21 100644 --- a/subsys/bluetooth/host/settings.c +++ b/subsys/bluetooth/host/settings.c @@ -89,20 +89,15 @@ int bt_settings_decode_key(char *key, bt_addr_le_t *addr) static int set(int argc, char **argv, void *value_ctx) { int len; + const struct bt_settings_handler *h; - if (argc > 1) { - const struct bt_settings_handler *h; + for (h = _bt_settings_start; h < _bt_settings_end; h++) { + if (!strcmp(argv[0], h->name)) { + argc--; + argv++; - for (h = _bt_settings_start; h < _bt_settings_end; h++) { - if (!strcmp(argv[0], h->name)) { - argc--; - argv++; - - return h->set(argc, argv, value_ctx); - } + return h->set(argc, argv, value_ctx); } - - return -ENOENT; } if (!strcmp(argv[0], "id")) { @@ -182,7 +177,7 @@ static int set(int argc, char **argv, void *value_ctx) } #endif /* CONFIG_BT_PRIVACY */ - return 0; + return -ENOENT; } #define ID_DATA_LEN(array) (bt_dev.id_count * sizeof(array[0]))