linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/5] Storage cleanup
@ 2011-09-09 12:51 Claudio Takahasi
  2011-09-09 12:51 ` [PATCH BlueZ 1/5] Remove storing device type Claudio Takahasi
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-09 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Dependency: SMP patches needs to be applied first due conflicts in
storage.{c, h} => "[PATCH BlueZ 00/12] Support for the new mgmt SMP
messages"

This patch series removes useless code in storage.c and contains minor
cosmetic changes.

Claudio Takahasi (5):
  Remove storing device type
  Remove create_file calls for read operations
  Remove not referenced function in storage.c
  Remove unneeded headers included in storage.c
  Fix magic numbers for local/remote name length

 src/adapter.c |   28 -----------------
 src/device.c  |    2 -
 src/storage.c |   91 ++++-----------------------------------------------------
 src/storage.h |    4 --
 4 files changed, 6 insertions(+), 119 deletions(-)

-- 
1.7.6


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH BlueZ 1/5] Remove storing device type
  2011-09-09 12:51 [PATCH BlueZ 0/5] Storage cleanup Claudio Takahasi
@ 2011-09-09 12:51 ` Claudio Takahasi
  2011-09-15 19:31   ` [PATCH BlueZ v2 " Claudio Takahasi
  2011-09-09 12:51 ` [PATCH BlueZ 2/5] Remove create_file calls for read operations Claudio Takahasi
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-09 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Device type doesn't need to be stored since GATT services information
exported through basic rate can be retrieved from the SDP records.
Device "type" is also a wrong expression to represent the operation
mode: over which transport GATT service is being exported.
---
 src/adapter.c |   28 ----------------------------
 src/device.c  |    2 --
 src/storage.c |   38 --------------------------------------
 src/storage.h |    3 ---
 4 files changed, 0 insertions(+), 71 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 52ef934..917c641 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2057,31 +2057,6 @@ static void create_stored_device_from_blocked(char *key, char *value,
 	}
 }
 
-static void create_stored_device_from_types(char *key, char *value,
-							void *user_data)
-{
-	GSList *l;
-	struct btd_adapter *adapter = user_data;
-	struct btd_device *device;
-	uint8_t type;
-
-	type = strtol(value, NULL, 16);
-
-	l = g_slist_find_custom(adapter->devices,
-				key, (GCompareFunc) device_address_cmp);
-	if (l) {
-		device = l->data;
-		device_set_type(device, type);
-		return;
-	}
-
-	device = device_create(connection, adapter, key, type);
-	if (device) {
-		device_set_temporary(device, FALSE);
-		adapter->devices = g_slist_append(adapter->devices, device);
-	}
-}
-
 static GSList *string_to_primary_list(char *str)
 {
 	GSList *l = NULL;
@@ -2200,9 +2175,6 @@ static void load_devices(struct btd_adapter *adapter)
 
 	create_name(filename, PATH_MAX, STORAGEDIR, srcaddr, "blocked");
 	textfile_foreach(filename, create_stored_device_from_blocked, adapter);
-
-	create_name(filename, PATH_MAX, STORAGEDIR, srcaddr, "types");
-	textfile_foreach(filename, create_stored_device_from_types, adapter);
 }
 
 int btd_adapter_block_address(struct btd_adapter *adapter, bdaddr_t *bdaddr)
diff --git a/src/device.c b/src/device.c
index f484238..cbe47bd 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1510,7 +1510,6 @@ cleanup:
 		device_get_address(device, &dba);
 
 		store_profiles(device);
-		write_device_type(&sba, &dba, device->type);
 	}
 
 	device->browse = NULL;
@@ -1598,7 +1597,6 @@ static void store_services(struct btd_device *device)
 	adapter_get_address(adapter, &sba);
 	device_get_address(device, &dba);
 
-	write_device_type(&sba, &dba, device->type);
 	write_device_services(&sba, &dba, str);
 
 	g_free(str);
diff --git a/src/storage.c b/src/storage.c
index 3414e34..1002753 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -1304,44 +1304,6 @@ int read_device_attributes(const bdaddr_t *sba, textfile_cb func, void *data)
 	return textfile_foreach(filename, func, data);
 }
 
-int write_device_type(const bdaddr_t *sba, const bdaddr_t *dba,
-						device_type_t type)
-{
-	char filename[PATH_MAX + 1], addr[18], chars[3];
-
-	create_filename(filename, PATH_MAX, sba, "types");
-
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
-	ba2str(dba, addr);
-
-	snprintf(chars, sizeof(chars), "%2.2X", type);
-
-	return textfile_put(filename, addr, chars);
-}
-
-device_type_t read_device_type(const bdaddr_t *sba, const bdaddr_t *dba)
-{
-	char filename[PATH_MAX + 1], addr[18], *chars;
-	device_type_t type;
-
-	create_filename(filename, PATH_MAX, sba, "types");
-
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
-	ba2str(dba, addr);
-
-	chars = textfile_caseget(filename, addr);
-	if (chars == NULL)
-		return DEVICE_TYPE_UNKNOWN;
-
-	type = strtol(chars, NULL, 16);
-
-	free(chars);
-
-	return type;
-}
-
 int write_longtermkeys(bdaddr_t *local, bdaddr_t *peer, const char *key)
 {
 	char filename[PATH_MAX + 1], addr[18];
diff --git a/src/storage.h b/src/storage.h
index 14e072d..4627afe 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -84,9 +84,6 @@ char *read_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
 int write_device_attribute(const bdaddr_t *sba, const bdaddr_t *dba,
                                         uint16_t handle, const char *chars);
 int read_device_attributes(const bdaddr_t *sba, textfile_cb func, void *data);
-int write_device_type(const bdaddr_t *sba, const bdaddr_t *dba,
-						device_type_t type);
-device_type_t read_device_type(const bdaddr_t *sba, const bdaddr_t *dba);
 int write_longtermkeys(bdaddr_t *local, bdaddr_t *peer, const char *key);
 gboolean has_longtermkeys(bdaddr_t *local, bdaddr_t *peer);
 
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH BlueZ 2/5] Remove create_file calls for read operations
  2011-09-09 12:51 [PATCH BlueZ 0/5] Storage cleanup Claudio Takahasi
  2011-09-09 12:51 ` [PATCH BlueZ 1/5] Remove storing device type Claudio Takahasi
@ 2011-09-09 12:51 ` Claudio Takahasi
  2011-09-15 19:32   ` [PATCH BlueZ v2 " Claudio Takahasi
  2011-09-09 12:51 ` [PATCH BlueZ 3/5] Remove not referenced function in storage.c Claudio Takahasi
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-09 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

This patch fixes some read only functions in storage.c removing
create_file function calls.
---
 src/storage.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/src/storage.c b/src/storage.c
index 1002753..c2d1edc 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -1110,8 +1110,6 @@ int read_device_pairable(bdaddr_t *bdaddr, gboolean *mode)
 
 	create_filename(filename, PATH_MAX, bdaddr, "config");
 
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
 	str = textfile_get(filename, "pairable");
 	if (!str)
 		return -ENOENT;
@@ -1238,8 +1236,6 @@ char *read_device_services(const bdaddr_t *sba, const bdaddr_t *dba)
 
 	create_filename(filename, PATH_MAX, sba, "primary");
 
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
 	ba2str(dba, addr);
 
 	return textfile_caseget(filename, addr);
@@ -1268,8 +1264,6 @@ char *read_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
 
 	create_filename(filename, PATH_MAX, sba, "characteristic");
 
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
 	ba2str(dba, addr);
 
 	snprintf(key, sizeof(key), "%17s#%04X", addr, handle);
@@ -1299,8 +1293,6 @@ int read_device_attributes(const bdaddr_t *sba, textfile_cb func, void *data)
 
 	create_filename(filename, PATH_MAX, sba, "attributes");
 
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
 	return textfile_foreach(filename, func, data);
 }
 
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH BlueZ 3/5] Remove not referenced function in storage.c
  2011-09-09 12:51 [PATCH BlueZ 0/5] Storage cleanup Claudio Takahasi
  2011-09-09 12:51 ` [PATCH BlueZ 1/5] Remove storing device type Claudio Takahasi
  2011-09-09 12:51 ` [PATCH BlueZ 2/5] Remove create_file calls for read operations Claudio Takahasi
@ 2011-09-09 12:51 ` Claudio Takahasi
  2011-09-15 19:32   ` [PATCH BlueZ v2 " Claudio Takahasi
  2011-09-09 12:51 ` [PATCH BlueZ 4/5] Remove unneeded headers included " Claudio Takahasi
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-09 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

---
 src/storage.c |   29 -----------------------------
 src/storage.h |    1 -
 2 files changed, 0 insertions(+), 30 deletions(-)

diff --git a/src/storage.c b/src/storage.c
index c2d1edc..466b399 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -732,35 +732,6 @@ gboolean read_trust(const bdaddr_t *local, const char *addr, const char *service
 	return ret;
 }
 
-struct trust_list {
-	GSList *trusts;
-	const char *service;
-};
-
-static void append_trust(char *key, char *value, void *data)
-{
-	struct trust_list *list = data;
-
-	if (strstr(value, list->service))
-		list->trusts = g_slist_append(list->trusts, g_strdup(key));
-}
-
-GSList *list_trusts(bdaddr_t *local, const char *service)
-{
-	char filename[PATH_MAX + 1];
-	struct trust_list list;
-
-	create_filename(filename, PATH_MAX, local, "trusts");
-
-	list.trusts = NULL;
-	list.service = service;
-
-	if (textfile_foreach(filename, append_trust, &list) < 0)
-		return NULL;
-
-	return list.trusts;
-}
-
 int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles)
 {
 	char filename[PATH_MAX + 1], addr[18];
diff --git a/src/storage.h b/src/storage.h
index 4627afe..7104d78 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -52,7 +52,6 @@ int read_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key, uint8_t *
 ssize_t read_pin_code(bdaddr_t *local, bdaddr_t *peer, char *pin);
 gboolean read_trust(const bdaddr_t *local, const char *addr, const char *service);
 int write_trust(const char *src, const char *addr, const char *service, gboolean trust);
-GSList *list_trusts(bdaddr_t *local, const char *service);
 int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles);
 int delete_entry(bdaddr_t *src, const char *storage, const char *key);
 int store_record(const gchar *src, const gchar *dst, sdp_record_t *rec);
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH BlueZ 4/5] Remove unneeded headers included in storage.c
  2011-09-09 12:51 [PATCH BlueZ 0/5] Storage cleanup Claudio Takahasi
                   ` (2 preceding siblings ...)
  2011-09-09 12:51 ` [PATCH BlueZ 3/5] Remove not referenced function in storage.c Claudio Takahasi
@ 2011-09-09 12:51 ` Claudio Takahasi
  2011-09-15 19:32   ` [PATCH BlueZ v2 " Claudio Takahasi
  2011-09-09 12:51 ` [PATCH BlueZ 5/5] Fix magic numbers for local/remote name length Claudio Takahasi
  2011-09-14  9:26 ` [PATCH BlueZ 0/5] Storage cleanup Johan Hedberg
  5 siblings, 1 reply; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-09 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

---
 src/storage.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/src/storage.c b/src/storage.c
index 466b399..8aedfef 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -35,8 +35,6 @@
 #include <time.h>
 #include <sys/file.h>
 #include <sys/stat.h>
-#include <sys/param.h>
-#include <sys/socket.h>
 
 #include <glib.h>
 
@@ -45,8 +43,6 @@
 #include <bluetooth/sdp_lib.h>
 
 #include "textfile.h"
-#include "adapter.h"
-#include "device.h"
 #include "glib-helper.h"
 #include "storage.h"
 
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH BlueZ 5/5] Fix magic numbers for local/remote name length
  2011-09-09 12:51 [PATCH BlueZ 0/5] Storage cleanup Claudio Takahasi
                   ` (3 preceding siblings ...)
  2011-09-09 12:51 ` [PATCH BlueZ 4/5] Remove unneeded headers included " Claudio Takahasi
@ 2011-09-09 12:51 ` Claudio Takahasi
  2011-09-15 19:32   ` [PATCH BlueZ v2 " Claudio Takahasi
  2011-09-14  9:26 ` [PATCH BlueZ 0/5] Storage cleanup Johan Hedberg
  5 siblings, 1 reply; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-09 12:51 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

---
 src/storage.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/storage.c b/src/storage.c
index 8aedfef..2f0e4b5 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -237,8 +237,8 @@ int read_local_name(bdaddr_t *bdaddr, char *name)
 		return -ENOENT;
 
 	len = strlen(str);
-	if (len > 248)
-		str[248] = '\0';
+	if (len > HCI_MAX_NAME_LENGTH)
+		str[HCI_MAX_NAME_LENGTH] = '\0';
 	strcpy(name, str);
 
 	free(str);
@@ -319,11 +319,11 @@ int read_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t *class)
 
 int write_device_name(bdaddr_t *local, bdaddr_t *peer, char *name)
 {
-	char filename[PATH_MAX + 1], addr[18], str[249];
+	char filename[PATH_MAX + 1], addr[18], str[HCI_MAX_NAME_LENGTH + 1];
 	int i;
 
 	memset(str, 0, sizeof(str));
-	for (i = 0; i < 248 && name[i]; i++)
+	for (i = 0; i < HCI_MAX_NAME_LENGTH && name[i]; i++)
 		if ((unsigned char) name[i] < 32 || name[i] == 127)
 			str[i] = '.';
 		else
@@ -349,8 +349,8 @@ int read_device_name(const char *src, const char *dst, char *name)
 		return -ENOENT;
 
 	len = strlen(str);
-	if (len > 248)
-		str[248] = '\0';
+	if (len > HCI_MAX_NAME_LENGTH)
+		str[HCI_MAX_NAME_LENGTH] = '\0';
 	strcpy(name, str);
 
 	free(str);
-- 
1.7.6


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH BlueZ 0/5] Storage cleanup
  2011-09-09 12:51 [PATCH BlueZ 0/5] Storage cleanup Claudio Takahasi
                   ` (4 preceding siblings ...)
  2011-09-09 12:51 ` [PATCH BlueZ 5/5] Fix magic numbers for local/remote name length Claudio Takahasi
@ 2011-09-14  9:26 ` Johan Hedberg
  2011-09-15 19:28   ` Claudio Takahasi
  5 siblings, 1 reply; 14+ messages in thread
From: Johan Hedberg @ 2011-09-14  9:26 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

On Fri, Sep 09, 2011, Claudio Takahasi wrote:
> Dependency: SMP patches needs to be applied first due conflicts in
> storage.{c, h} => "[PATCH BlueZ 00/12] Support for the new mgmt SMP
> messages"
> 
> This patch series removes useless code in storage.c and contains minor
> cosmetic changes.
> 
> Claudio Takahasi (5):
>   Remove storing device type
>   Remove create_file calls for read operations
>   Remove not referenced function in storage.c
>   Remove unneeded headers included in storage.c
>   Fix magic numbers for local/remote name length
> 
>  src/adapter.c |   28 -----------------
>  src/device.c  |    2 -
>  src/storage.c |   91 ++++-----------------------------------------------------
>  src/storage.h |    4 --
>  4 files changed, 6 insertions(+), 119 deletions(-)

Would it be possible to rebase these on top of current git (github).
These are clear fixes that could be applied now whereas the SMP patches
they depend on will still need some discussion and review.

Johan

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH BlueZ 0/5] Storage cleanup
  2011-09-14  9:26 ` [PATCH BlueZ 0/5] Storage cleanup Johan Hedberg
@ 2011-09-15 19:28   ` Claudio Takahasi
  0 siblings, 0 replies; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-15 19:28 UTC (permalink / raw)
  To: Claudio Takahasi, linux-bluetooth

Hi Johan,

On Wed, Sep 14, 2011 at 6:26 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Claudio,
>
> On Fri, Sep 09, 2011, Claudio Takahasi wrote:
>> Dependency: SMP patches needs to be applied first due conflicts in
>> storage.{c, h} => "[PATCH BlueZ 00/12] Support for the new mgmt SMP
>> messages"
>>
>> This patch series removes useless code in storage.c and contains minor
>> cosmetic changes.
>>
>> Claudio Takahasi (5):
>>   Remove storing device type
>>   Remove create_file calls for read operations
>>   Remove not referenced function in storage.c
>>   Remove unneeded headers included in storage.c
>>   Fix magic numbers for local/remote name length
>>
>>  src/adapter.c |   28 -----------------
>>  src/device.c  |    2 -
>>  src/storage.c |   91 ++++-----------------------------------------------------
>>  src/storage.h |    4 --
>>  4 files changed, 6 insertions(+), 119 deletions(-)
>
> Would it be possible to rebase these on top of current git (github).
> These are clear fixes that could be applied now whereas the SMP patches
> they depend on will still need some discussion and review.
>
> Johan
>

Ok.

I will rebase it and send the patch series again.

BR,
Claudio

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH BlueZ v2 1/5] Remove storing device type
  2011-09-09 12:51 ` [PATCH BlueZ 1/5] Remove storing device type Claudio Takahasi
@ 2011-09-15 19:31   ` Claudio Takahasi
  2011-09-27  9:14     ` Johan Hedberg
  0 siblings, 1 reply; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-15 19:31 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Device type doesn't need to be stored since GATT services information
exported through basic rate can be retrieved from the SDP records.
Device "type" is also a wrong expression to represent the operation
mode: over which transport GATT service is being exported.
---
 src/adapter.c |   28 ----------------------------
 src/device.c  |    2 --
 src/storage.c |   38 --------------------------------------
 src/storage.h |    3 ---
 4 files changed, 0 insertions(+), 71 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 7d0c63e..628db60 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1967,31 +1967,6 @@ static void create_stored_device_from_blocked(char *key, char *value,
 	}
 }
 
-static void create_stored_device_from_types(char *key, char *value,
-							void *user_data)
-{
-	GSList *l;
-	struct btd_adapter *adapter = user_data;
-	struct btd_device *device;
-	uint8_t type;
-
-	type = strtol(value, NULL, 16);
-
-	l = g_slist_find_custom(adapter->devices,
-				key, (GCompareFunc) device_address_cmp);
-	if (l) {
-		device = l->data;
-		device_set_type(device, type);
-		return;
-	}
-
-	device = device_create(connection, adapter, key, type);
-	if (device) {
-		device_set_temporary(device, FALSE);
-		adapter->devices = g_slist_append(adapter->devices, device);
-	}
-}
-
 static GSList *string_to_primary_list(char *str)
 {
 	GSList *l = NULL;
@@ -2091,9 +2066,6 @@ static void load_devices(struct btd_adapter *adapter)
 
 	create_name(filename, PATH_MAX, STORAGEDIR, srcaddr, "blocked");
 	textfile_foreach(filename, create_stored_device_from_blocked, adapter);
-
-	create_name(filename, PATH_MAX, STORAGEDIR, srcaddr, "types");
-	textfile_foreach(filename, create_stored_device_from_types, adapter);
 }
 
 int btd_adapter_block_address(struct btd_adapter *adapter, bdaddr_t *bdaddr)
diff --git a/src/device.c b/src/device.c
index d54edbb..3be328d 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1500,7 +1500,6 @@ cleanup:
 		device_get_address(device, &dba);
 
 		store_profiles(device);
-		write_device_type(&sba, &dba, device->type);
 	}
 
 	device->browse = NULL;
@@ -1588,7 +1587,6 @@ static void store_services(struct btd_device *device)
 	adapter_get_address(adapter, &sba);
 	device_get_address(device, &dba);
 
-	write_device_type(&sba, &dba, device->type);
 	write_device_services(&sba, &dba, str);
 
 	g_free(str);
diff --git a/src/storage.c b/src/storage.c
index 1f3da6e..8511823 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -1303,41 +1303,3 @@ int read_device_attributes(const bdaddr_t *sba, textfile_cb func, void *data)
 
 	return textfile_foreach(filename, func, data);
 }
-
-int write_device_type(const bdaddr_t *sba, const bdaddr_t *dba,
-						device_type_t type)
-{
-	char filename[PATH_MAX + 1], addr[18], chars[3];
-
-	create_filename(filename, PATH_MAX, sba, "types");
-
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
-	ba2str(dba, addr);
-
-	snprintf(chars, sizeof(chars), "%2.2X", type);
-
-	return textfile_put(filename, addr, chars);
-}
-
-device_type_t read_device_type(const bdaddr_t *sba, const bdaddr_t *dba)
-{
-	char filename[PATH_MAX + 1], addr[18], *chars;
-	device_type_t type;
-
-	create_filename(filename, PATH_MAX, sba, "types");
-
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
-	ba2str(dba, addr);
-
-	chars = textfile_caseget(filename, addr);
-	if (chars == NULL)
-		return DEVICE_TYPE_UNKNOWN;
-
-	type = strtol(chars, NULL, 16);
-
-	free(chars);
-
-	return type;
-}
diff --git a/src/storage.h b/src/storage.h
index bb64727..7340ff7 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -84,9 +84,6 @@ char *read_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
 int write_device_attribute(const bdaddr_t *sba, const bdaddr_t *dba,
                                         uint16_t handle, const char *chars);
 int read_device_attributes(const bdaddr_t *sba, textfile_cb func, void *data);
-int write_device_type(const bdaddr_t *sba, const bdaddr_t *dba,
-						device_type_t type);
-device_type_t read_device_type(const bdaddr_t *sba, const bdaddr_t *dba);
 
 #define PNP_UUID		"00001200-0000-1000-8000-00805f9b34fb"
 
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH BlueZ v2 2/5] Remove create_file calls for read operations
  2011-09-09 12:51 ` [PATCH BlueZ 2/5] Remove create_file calls for read operations Claudio Takahasi
@ 2011-09-15 19:32   ` Claudio Takahasi
  0 siblings, 0 replies; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-15 19:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

This patch fixes some read only functions in storage.c removing
create_file function calls.
---
 src/storage.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)

diff --git a/src/storage.c b/src/storage.c
index 8511823..8d3a39d 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -1110,8 +1110,6 @@ int read_device_pairable(bdaddr_t *bdaddr, gboolean *mode)
 
 	create_filename(filename, PATH_MAX, bdaddr, "config");
 
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
 	str = textfile_get(filename, "pairable");
 	if (!str)
 		return -ENOENT;
@@ -1238,8 +1236,6 @@ char *read_device_services(const bdaddr_t *sba, const bdaddr_t *dba)
 
 	create_filename(filename, PATH_MAX, sba, "primary");
 
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
 	ba2str(dba, addr);
 
 	return textfile_caseget(filename, addr);
@@ -1268,8 +1264,6 @@ char *read_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
 
 	create_filename(filename, PATH_MAX, sba, "characteristic");
 
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
 	ba2str(dba, addr);
 
 	snprintf(key, sizeof(key), "%17s#%04X", addr, handle);
@@ -1299,7 +1293,5 @@ int read_device_attributes(const bdaddr_t *sba, textfile_cb func, void *data)
 
 	create_filename(filename, PATH_MAX, sba, "attributes");
 
-	create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
 	return textfile_foreach(filename, func, data);
 }
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH BlueZ v2 3/5] Remove not referenced function in storage.c
  2011-09-09 12:51 ` [PATCH BlueZ 3/5] Remove not referenced function in storage.c Claudio Takahasi
@ 2011-09-15 19:32   ` Claudio Takahasi
  0 siblings, 0 replies; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-15 19:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

---
 src/storage.c |   29 -----------------------------
 src/storage.h |    1 -
 2 files changed, 0 insertions(+), 30 deletions(-)

diff --git a/src/storage.c b/src/storage.c
index 8d3a39d..85cfed8 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -732,35 +732,6 @@ gboolean read_trust(const bdaddr_t *local, const char *addr, const char *service
 	return ret;
 }
 
-struct trust_list {
-	GSList *trusts;
-	const char *service;
-};
-
-static void append_trust(char *key, char *value, void *data)
-{
-	struct trust_list *list = data;
-
-	if (strstr(value, list->service))
-		list->trusts = g_slist_append(list->trusts, g_strdup(key));
-}
-
-GSList *list_trusts(bdaddr_t *local, const char *service)
-{
-	char filename[PATH_MAX + 1];
-	struct trust_list list;
-
-	create_filename(filename, PATH_MAX, local, "trusts");
-
-	list.trusts = NULL;
-	list.service = service;
-
-	if (textfile_foreach(filename, append_trust, &list) < 0)
-		return NULL;
-
-	return list.trusts;
-}
-
 int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles)
 {
 	char filename[PATH_MAX + 1], addr[18];
diff --git a/src/storage.h b/src/storage.h
index 7340ff7..dbe717f 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -52,7 +52,6 @@ int read_link_key(bdaddr_t *local, bdaddr_t *peer, unsigned char *key, uint8_t *
 ssize_t read_pin_code(bdaddr_t *local, bdaddr_t *peer, char *pin);
 gboolean read_trust(const bdaddr_t *local, const char *addr, const char *service);
 int write_trust(const char *src, const char *addr, const char *service, gboolean trust);
-GSList *list_trusts(bdaddr_t *local, const char *service);
 int write_device_profiles(bdaddr_t *src, bdaddr_t *dst, const char *profiles);
 int delete_entry(bdaddr_t *src, const char *storage, const char *key);
 int store_record(const gchar *src, const gchar *dst, sdp_record_t *rec);
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH BlueZ v2 4/5] Remove unneeded headers included in storage.c
  2011-09-09 12:51 ` [PATCH BlueZ 4/5] Remove unneeded headers included " Claudio Takahasi
@ 2011-09-15 19:32   ` Claudio Takahasi
  0 siblings, 0 replies; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-15 19:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

---
 src/storage.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/src/storage.c b/src/storage.c
index 85cfed8..00dc483 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -35,8 +35,6 @@
 #include <time.h>
 #include <sys/file.h>
 #include <sys/stat.h>
-#include <sys/param.h>
-#include <sys/socket.h>
 
 #include <glib.h>
 
@@ -45,8 +43,6 @@
 #include <bluetooth/sdp_lib.h>
 
 #include "textfile.h"
-#include "adapter.h"
-#include "device.h"
 #include "glib-helper.h"
 #include "storage.h"
 
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH BlueZ v2 5/5] Fix magic numbers for local/remote name length
  2011-09-09 12:51 ` [PATCH BlueZ 5/5] Fix magic numbers for local/remote name length Claudio Takahasi
@ 2011-09-15 19:32   ` Claudio Takahasi
  0 siblings, 0 replies; 14+ messages in thread
From: Claudio Takahasi @ 2011-09-15 19:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

---
 src/storage.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/storage.c b/src/storage.c
index 00dc483..c64842c 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -237,8 +237,8 @@ int read_local_name(bdaddr_t *bdaddr, char *name)
 		return -ENOENT;
 
 	len = strlen(str);
-	if (len > 248)
-		str[248] = '\0';
+	if (len > HCI_MAX_NAME_LENGTH)
+		str[HCI_MAX_NAME_LENGTH] = '\0';
 	strcpy(name, str);
 
 	free(str);
@@ -319,11 +319,11 @@ int read_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t *class)
 
 int write_device_name(bdaddr_t *local, bdaddr_t *peer, char *name)
 {
-	char filename[PATH_MAX + 1], addr[18], str[249];
+	char filename[PATH_MAX + 1], addr[18], str[HCI_MAX_NAME_LENGTH + 1];
 	int i;
 
 	memset(str, 0, sizeof(str));
-	for (i = 0; i < 248 && name[i]; i++)
+	for (i = 0; i < HCI_MAX_NAME_LENGTH && name[i]; i++)
 		if ((unsigned char) name[i] < 32 || name[i] == 127)
 			str[i] = '.';
 		else
@@ -349,8 +349,8 @@ int read_device_name(const char *src, const char *dst, char *name)
 		return -ENOENT;
 
 	len = strlen(str);
-	if (len > 248)
-		str[248] = '\0';
+	if (len > HCI_MAX_NAME_LENGTH)
+		str[HCI_MAX_NAME_LENGTH] = '\0';
 	strcpy(name, str);
 
 	free(str);
-- 
1.7.6.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH BlueZ v2 1/5] Remove storing device type
  2011-09-15 19:31   ` [PATCH BlueZ v2 " Claudio Takahasi
@ 2011-09-27  9:14     ` Johan Hedberg
  0 siblings, 0 replies; 14+ messages in thread
From: Johan Hedberg @ 2011-09-27  9:14 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

On Thu, Sep 15, 2011, Claudio Takahasi wrote:
> Device type doesn't need to be stored since GATT services information
> exported through basic rate can be retrieved from the SDP records.
> Device "type" is also a wrong expression to represent the operation
> mode: over which transport GATT service is being exported.
> ---
>  src/adapter.c |   28 ----------------------------
>  src/device.c  |    2 --
>  src/storage.c |   38 --------------------------------------
>  src/storage.h |    3 ---
>  4 files changed, 0 insertions(+), 71 deletions(-)

All five patches applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-09-27  9:14 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-09 12:51 [PATCH BlueZ 0/5] Storage cleanup Claudio Takahasi
2011-09-09 12:51 ` [PATCH BlueZ 1/5] Remove storing device type Claudio Takahasi
2011-09-15 19:31   ` [PATCH BlueZ v2 " Claudio Takahasi
2011-09-27  9:14     ` Johan Hedberg
2011-09-09 12:51 ` [PATCH BlueZ 2/5] Remove create_file calls for read operations Claudio Takahasi
2011-09-15 19:32   ` [PATCH BlueZ v2 " Claudio Takahasi
2011-09-09 12:51 ` [PATCH BlueZ 3/5] Remove not referenced function in storage.c Claudio Takahasi
2011-09-15 19:32   ` [PATCH BlueZ v2 " Claudio Takahasi
2011-09-09 12:51 ` [PATCH BlueZ 4/5] Remove unneeded headers included " Claudio Takahasi
2011-09-15 19:32   ` [PATCH BlueZ v2 " Claudio Takahasi
2011-09-09 12:51 ` [PATCH BlueZ 5/5] Fix magic numbers for local/remote name length Claudio Takahasi
2011-09-15 19:32   ` [PATCH BlueZ v2 " Claudio Takahasi
2011-09-14  9:26 ` [PATCH BlueZ 0/5] Storage cleanup Johan Hedberg
2011-09-15 19:28   ` Claudio Takahasi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).