diff options
author | Vinicius Costa Gomes <vinicius.gomes@openbossa.org> | 2012-07-27 16:43:12 -0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-07-29 20:02:39 +0200 |
commit | be5fd633a6976358e9c91f7bec87bccb05faafd2 (patch) | |
tree | 6c0c38c1c87f9efab392df96e924d83185700534 /src/storage.c | |
parent | 58a1819a44dd753ea14baea64e870e754ea6d8fc (diff) | |
download | bluez-be5fd633a6976358e9c91f7bec87bccb05faafd2.tar.gz |
storage: Make it clear that delete_entry only works for addresses
Also, delete_entry should try to erase both addresses styles, with and
without address type, if not we may find some leftovers from deleted
devices.
Diffstat (limited to 'src/storage.c')
-rw-r--r-- | src/storage.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/storage.c b/src/storage.c index 9289e079c..7a3010d91 100644 --- a/src/storage.c +++ b/src/storage.c @@ -800,13 +800,29 @@ int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles) return textfile_put(filename, addr, profiles); } -int delete_entry(bdaddr_t *src, const char *storage, const char *key) +int delete_entry(bdaddr_t *src, const char *storage, bdaddr_t *dst, + uint8_t dst_type) { - char filename[PATH_MAX + 1]; + char filename[PATH_MAX + 1], key[20]; + int err, ret; + + ba2str(dst, key); + sprintf(&key[17], "#%hhu", dst_type); create_filename(filename, PATH_MAX, src, storage); - return textfile_del(filename, key); + err = 0; + ret = textfile_del(filename, key); + if (ret) + err = ret; + + /* Trying without address type */ + key[17] = '\0'; + ret = textfile_del(filename, key); + if (ret) + err = ret; + + return err; } int store_record(const gchar *src, const gchar *dst, sdp_record_t *rec) |