From bd5048c251bd578776d063ac45a94f8b482c5ed4 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 13 Feb 2020 11:14:54 -0800 Subject: [PATCH] Bluetooth: Setting: Make bt_settings_encode_key take a const address This removes the need to cast in case the address is already const. Signed-off-by: Luiz Augusto von Dentz --- subsys/bluetooth/host/gatt.c | 14 ++++++-------- subsys/bluetooth/host/settings.c | 4 ++-- subsys/bluetooth/host/settings.h | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/subsys/bluetooth/host/gatt.c b/subsys/bluetooth/host/gatt.c index 20c014d5a4b..5305757e1db 100644 --- a/subsys/bluetooth/host/gatt.c +++ b/subsys/bluetooth/host/gatt.c @@ -4137,11 +4137,9 @@ int bt_gatt_store_ccc(u8_t id, const bt_addr_le_t *addr) char id_str[4]; u8_to_dec(id_str, sizeof(id_str), id); - bt_settings_encode_key(key, sizeof(key), "ccc", - (bt_addr_le_t *)addr, id_str); + bt_settings_encode_key(key, sizeof(key), "ccc", addr, id_str); } else { - bt_settings_encode_key(key, sizeof(key), "ccc", - (bt_addr_le_t *)addr, NULL); + bt_settings_encode_key(key, sizeof(key), "ccc", addr, NULL); } if (save.count) { @@ -4392,10 +4390,10 @@ static int bt_gatt_clear_ccc(u8_t id, const bt_addr_le_t *addr) u8_to_dec(id_str, sizeof(id_str), id); bt_settings_encode_key(key, sizeof(key), "ccc", - (bt_addr_le_t *)addr, id_str); + addr, id_str); } else { bt_settings_encode_key(key, sizeof(key), "ccc", - (bt_addr_le_t *)addr, NULL); + addr, NULL); } return settings_delete(key); @@ -4421,10 +4419,10 @@ static int bt_gatt_clear_cf(u8_t id, const bt_addr_le_t *addr) u8_to_dec(id_str, sizeof(id_str), id); bt_settings_encode_key(key, sizeof(key), "cf", - (bt_addr_le_t *)addr, id_str); + addr, id_str); } else { bt_settings_encode_key(key, sizeof(key), "cf", - (bt_addr_le_t *)addr, NULL); + addr, NULL); } return settings_delete(key); diff --git a/subsys/bluetooth/host/settings.c b/subsys/bluetooth/host/settings.c index a97bfe9bec5..ea138efaf4d 100644 --- a/subsys/bluetooth/host/settings.c +++ b/subsys/bluetooth/host/settings.c @@ -21,7 +21,7 @@ #if defined(CONFIG_BT_SETTINGS_USE_PRINTK) void bt_settings_encode_key(char *path, size_t path_size, const char *subsys, - bt_addr_le_t *addr, const char *key) + const bt_addr_le_t *addr, const char *key) { if (key) { snprintk(path, path_size, @@ -41,7 +41,7 @@ void bt_settings_encode_key(char *path, size_t path_size, const char *subsys, } #else void bt_settings_encode_key(char *path, size_t path_size, const char *subsys, - bt_addr_le_t *addr, const char *key) + const bt_addr_le_t *addr, const char *key) { size_t len = 3; diff --git a/subsys/bluetooth/host/settings.h b/subsys/bluetooth/host/settings.h index c918ad426c4..e4854e437c1 100644 --- a/subsys/bluetooth/host/settings.h +++ b/subsys/bluetooth/host/settings.h @@ -12,7 +12,7 @@ /* Helpers for keys containing a bdaddr */ void bt_settings_encode_key(char *path, size_t path_size, const char *subsys, - bt_addr_le_t *addr, const char *key); + const bt_addr_le_t *addr, const char *key); int bt_settings_decode_key(const char *key, bt_addr_le_t *addr); void bt_settings_save_id(void);