mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-12-02 00:24:25 +08:00
Fix the case if device isn't found in the name cache
This commit is contained in:
parent
91ec718746
commit
12513fafd3
@ -286,7 +286,7 @@ static int read_device_name(const bdaddr_t *local, const bdaddr_t *peer, char *n
|
||||
char filename[PATH_MAX + 1], addr[18], str[249], *buf, *ptr;
|
||||
bdaddr_t bdaddr;
|
||||
struct stat st;
|
||||
int fd, pos, err = 0;
|
||||
int fd, pos, err = -ENOENT;
|
||||
|
||||
ba2str(local, addr);
|
||||
snprintf(filename, PATH_MAX, "%s/%s/names", DEVPATH, addr);
|
||||
@ -321,6 +321,7 @@ static int read_device_name(const bdaddr_t *local, const bdaddr_t *peer, char *n
|
||||
|
||||
if (!bacmp(&bdaddr, peer)) {
|
||||
snprintf(name, 249, "%s", str);
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -534,7 +535,7 @@ static void cmd_scan(int dev_id, int argc, char **argv)
|
||||
|
||||
for (i = 0; i < num_rsp; i++) {
|
||||
memset(name, 0, sizeof(name));
|
||||
nc = read_device_name(&di.bdaddr, &(info+i)->bdaddr, name) < 0 ? 0 : 1;
|
||||
nc = (read_device_name(&di.bdaddr, &(info+i)->bdaddr, name) == 0);
|
||||
|
||||
if (!extcls && !extinf && !extoui) {
|
||||
ba2str(&(info+i)->bdaddr, addr);
|
||||
|
Loading…
Reference in New Issue
Block a user