mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-16 00:34:39 +08:00
device: Fix bogus errors on load_att_info
load_att_info would attempt to load attributes file from the storage but in case it doesn't exists it would print an error instead of just bailing out as attributes file is created on demand when there are something to be stored.
This commit is contained in:
parent
d36c45c55a
commit
b6061ea5b8
12
src/device.c
12
src/device.c
@ -22,6 +22,7 @@
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <dbus/dbus.h>
|
||||
@ -3614,6 +3615,7 @@ static void load_att_info(struct btd_device *device, const char *local,
|
||||
const char *peer)
|
||||
{
|
||||
char filename[PATH_MAX];
|
||||
struct stat st;
|
||||
GKeyFile *key_file;
|
||||
GError *gerr = NULL;
|
||||
char *prim_uuid, *str;
|
||||
@ -3623,12 +3625,13 @@ static void load_att_info(struct btd_device *device, const char *local,
|
||||
char tmp[3];
|
||||
int i;
|
||||
|
||||
sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
|
||||
prim_uuid = bt_uuid2string(&uuid);
|
||||
|
||||
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/attributes", local,
|
||||
peer);
|
||||
|
||||
/* Check if attributes file exists */
|
||||
if (stat(filename, &st) < 0)
|
||||
return;
|
||||
|
||||
key_file = g_key_file_new();
|
||||
if (!g_key_file_load_from_file(key_file, filename, 0, &gerr)) {
|
||||
error("Unable to load key file from %s: (%s)", filename,
|
||||
@ -3637,6 +3640,9 @@ static void load_att_info(struct btd_device *device, const char *local,
|
||||
}
|
||||
groups = g_key_file_get_groups(key_file, NULL);
|
||||
|
||||
sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
|
||||
prim_uuid = bt_uuid2string(&uuid);
|
||||
|
||||
for (handle = groups; *handle; handle++) {
|
||||
gboolean uuid_ok;
|
||||
int end;
|
||||
|
Loading…
Reference in New Issue
Block a user