} else {
error("Cannot save LE address");
}
- bacpy(&adapter->le_static_addr, &le_static_addr);
}
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;