From 76636c4752d72ec3f4e2053ab239cc6d3d030bb4 Mon Sep 17 00:00:00 2001 From: Deokhyun Kim Date: Tue, 27 Aug 2019 10:46:36 +0900 Subject: [PATCH] Not set le_static_addr when initializing Change-Id: Iebd1a33c9ffb28635336018b71cd817b2ca166d5 Signed-off-by: Deokhyun Kim --- src/adapter.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index 69be970..1d3b879 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -5083,7 +5083,6 @@ static void init_le_static_address(struct btd_adapter *adapter) } else { error("Cannot save LE address"); } - bacpy(&adapter->le_static_addr, &le_static_addr); } static void set_le_static_address(struct btd_adapter *adapter) @@ -5094,24 +5093,23 @@ static void set_le_static_address(struct btd_adapter *adapter) char dirname[PATH_MAX]; snprintf(dirname, PATH_MAX, STORAGEDIR "/%s", "le_static_addr"); - if (access(dirname, F_OK) < 0) { + if (access(dirname, F_OK) < 0) init_le_static_address(adapter); + + fd = open(dirname, O_RDONLY); + if (fd >= 0) { + ret = read(fd, address, sizeof(address)); + if (ret >= 17) { + /* xx:xx:xx:xx:xx:xx */ + address[17] = '\0'; + DBG("LE static random : %s", address); + str2ba(address, &adapter->le_static_addr); + adapter->le_static_addr.b[5] |= 0xc0; + } else + error("Invalid LE address"); + close(fd); } else { - fd = open(dirname, O_RDONLY); - if (fd >= 0) { - ret = read(fd, address, sizeof(address)); - if (ret >= 17) { - /* xx:xx:xx:xx:xx:xx */ - address[17] = '\0'; - DBG("LE static random : %s", address); - str2ba(address, &adapter->le_static_addr); - adapter->le_static_addr.b[5] |= 0xc0; - } else - error("Invalid LE address"); - close(fd); - } else { - error("Cannot get LE address"); - } + error("Cannot get LE address"); } return; -- 2.7.4