Linux-Bluetooth Archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ v2 1/3] settings: Fix scan-build warning
@ 2022-10-18 23:45 Luiz Augusto von Dentz
  2022-10-18 23:45 ` [PATCH BlueZ v2 2/3] monitor/att: Detect cache changes Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2022-10-18 23:45 UTC (permalink / raw
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This fixes the following warning:

src/settings.c:281:7: warning: Branch condition evaluates to a garbage
value [core.uninitialized.Branch]
                if (ret) {
                    ^~~
---
 src/settings.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/settings.c b/src/settings.c
index 0f053000610b..85534f2c7aca 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -269,6 +269,7 @@ static int gatt_db_load(struct gatt_db *db, GKeyFile *key_file, char **keys)
 							&primary, &uuid);
 
 			bt_uuid_to_string(&uuid, uuid_str, sizeof(uuid_str));
+			ret = 0;
 		} else if (g_str_equal(type, GATT_INCLUDE_UUID_STR)) {
 			ret = load_incl(db, *handle, value, current_service);
 		} else if (g_str_equal(type, GATT_CHARAC_UUID_STR)) {
-- 
2.37.3


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

* [PATCH BlueZ v2 2/3] monitor/att: Detect cache changes
  2022-10-18 23:45 [PATCH BlueZ v2 1/3] settings: Fix scan-build warning Luiz Augusto von Dentz
@ 2022-10-18 23:45 ` Luiz Augusto von Dentz
  2022-10-18 23:46 ` [PATCH BlueZ v2 3/3] monitor/att: Revert treating Notification/Indication as a request Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2022-10-18 23:45 UTC (permalink / raw
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This attempts to detect if the were any changes on cache files since
they were last loaded and then attempt to reload them.
---
 monitor/att.c | 41 +++++++++++++++++++++++++++++------------
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/monitor/att.c b/monitor/att.c
index 491f196bf38d..7a4125567498 100644
--- a/monitor/att.c
+++ b/monitor/att.c
@@ -22,6 +22,7 @@
 #include <stdbool.h>
 #include <errno.h>
 #include <linux/limits.h>
+#include <sys/stat.h>
 
 #include <glib.h>
 
@@ -2426,7 +2427,9 @@ struct att_read {
 
 struct att_conn_data {
 	struct gatt_db *ldb;
+	struct timespec ldb_mtim;
 	struct gatt_db *rdb;
+	struct timespec rdb_mtim;
 	struct queue *reads;
 };
 
@@ -2440,6 +2443,28 @@ static void att_conn_data_free(void *data)
 	free(att_data);
 }
 
+static void gatt_load_db(struct gatt_db *db, const char *filename,
+						struct timespec *mtim)
+{
+	struct stat st;
+
+	if (lstat(filename, &st))
+		return;
+
+	if (!gatt_db_isempty(db)) {
+		/* Check if file has been modified since last time */
+		if (st.st_mtim.tv_sec == mtim->tv_sec &&
+				    st.st_mtim.tv_nsec == mtim->tv_nsec)
+			return;
+		/* Clear db before reloading */
+		gatt_db_clear(db);
+	}
+
+	*mtim = st.st_mtim;
+
+	btd_settings_gatt_db_load(db, filename);
+}
+
 static void load_gatt_db(struct packet_conn_data *conn)
 {
 	struct att_conn_data *data = conn->data;
@@ -2455,22 +2480,14 @@ static void load_gatt_db(struct packet_conn_data *conn)
 		conn->destroy = att_conn_data_free;
 	}
 
-	if (!gatt_db_isempty(data->ldb) && !gatt_db_isempty(data->rdb))
-		return;
-
 	ba2str((bdaddr_t *)conn->src, local);
 	ba2str((bdaddr_t *)conn->dst, peer);
 
-	if (gatt_db_isempty(data->ldb)) {
-		create_filename(filename, PATH_MAX, "/%s/attributes", local);
-		btd_settings_gatt_db_load(data->ldb, filename);
-	}
+	create_filename(filename, PATH_MAX, "/%s/attributes", local);
+	gatt_load_db(data->ldb, filename, &data->ldb_mtim);
 
-	if (gatt_db_isempty(data->rdb)) {
-		create_filename(filename, PATH_MAX, "/%s/cache/%s", local,
-								peer);
-		btd_settings_gatt_db_load(data->rdb, filename);
-	}
+	create_filename(filename, PATH_MAX, "/%s/cache/%s", local, peer);
+	gatt_load_db(data->rdb, filename, &data->rdb_mtim);
 }
 
 static struct gatt_db_attribute *get_attribute(const struct l2cap_frame *frame,
-- 
2.37.3


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

* [PATCH BlueZ v2 3/3] monitor/att: Revert treating Notification/Indication as a request
  2022-10-18 23:45 [PATCH BlueZ v2 1/3] settings: Fix scan-build warning Luiz Augusto von Dentz
  2022-10-18 23:45 ` [PATCH BlueZ v2 2/3] monitor/att: Detect cache changes Luiz Augusto von Dentz
@ 2022-10-18 23:46 ` Luiz Augusto von Dentz
  2022-10-19  0:51 ` [BlueZ,v2,1/3] settings: Fix scan-build warning bluez.test.bot
  2022-10-19 20:40 ` [PATCH BlueZ v2 1/3] " patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2022-10-18 23:46 UTC (permalink / raw
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

Notification/Indication shall be treated as response (rsp=true) so the
correct database is used:

> ACL Data RX: Handle 3585 flags 0x02 dlen 14
      ATT: Handle Value Notification (0x1b) len 9
        Handle: 0x002a Type: Report (0x2a4d)
          Data: 0000feffff0000
---
 monitor/att.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/monitor/att.c b/monitor/att.c
index 7a4125567498..fbd75db03b83 100644
--- a/monitor/att.c
+++ b/monitor/att.c
@@ -2785,7 +2785,7 @@ static void print_notify(const struct l2cap_frame *frame, uint16_t handle,
 	struct gatt_handler *handler;
 	struct l2cap_frame clone;
 
-	print_handle(frame, handle, false);
+	print_handle(frame, handle, true);
 	print_hex_field("  Data", frame->data, len);
 
 	if (len > frame->size) {
-- 
2.37.3


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

* RE: [BlueZ,v2,1/3] settings: Fix scan-build warning
  2022-10-18 23:45 [PATCH BlueZ v2 1/3] settings: Fix scan-build warning Luiz Augusto von Dentz
  2022-10-18 23:45 ` [PATCH BlueZ v2 2/3] monitor/att: Detect cache changes Luiz Augusto von Dentz
  2022-10-18 23:46 ` [PATCH BlueZ v2 3/3] monitor/att: Revert treating Notification/Indication as a request Luiz Augusto von Dentz
@ 2022-10-19  0:51 ` bluez.test.bot
  2022-10-19 20:40 ` [PATCH BlueZ v2 1/3] " patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2022-10-19  0:51 UTC (permalink / raw
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1053 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=686498

---Test result---

Test Summary:
CheckPatch                    PASS      3.39 seconds
GitLint                       PASS      2.35 seconds
Prep - Setup ELL              PASS      34.58 seconds
Build - Prep                  PASS      1.00 seconds
Build - Configure             PASS      11.02 seconds
Build - Make                  PASS      1177.12 seconds
Make Check                    PASS      13.47 seconds
Make Check w/Valgrind         PASS      370.82 seconds
Make Distcheck                PASS      311.71 seconds
Build w/ext ELL - Configure   PASS      11.27 seconds
Build w/ext ELL - Make        PASS      112.47 seconds
Incremental Build w/ patches  PASS      397.01 seconds
Scan Build                    PASS      702.70 seconds



---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ v2 1/3] settings: Fix scan-build warning
  2022-10-18 23:45 [PATCH BlueZ v2 1/3] settings: Fix scan-build warning Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2022-10-19  0:51 ` [BlueZ,v2,1/3] settings: Fix scan-build warning bluez.test.bot
@ 2022-10-19 20:40 ` patchwork-bot+bluetooth
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2022-10-19 20:40 UTC (permalink / raw
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 18 Oct 2022 16:45:58 -0700 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This fixes the following warning:
> 
> src/settings.c:281:7: warning: Branch condition evaluates to a garbage
> value [core.uninitialized.Branch]
>                 if (ret) {
>                     ^~~
> 
> [...]

Here is the summary with links:
  - [BlueZ,v2,1/3] settings: Fix scan-build warning
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=9c739ba22f09
  - [BlueZ,v2,2/3] monitor/att: Detect cache changes
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a49b47f241ce
  - [BlueZ,v2,3/3] monitor/att: Revert treating Notification/Indication as a request
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=68155e2f7e66

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-10-19 20:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-18 23:45 [PATCH BlueZ v2 1/3] settings: Fix scan-build warning Luiz Augusto von Dentz
2022-10-18 23:45 ` [PATCH BlueZ v2 2/3] monitor/att: Detect cache changes Luiz Augusto von Dentz
2022-10-18 23:46 ` [PATCH BlueZ v2 3/3] monitor/att: Revert treating Notification/Indication as a request Luiz Augusto von Dentz
2022-10-19  0:51 ` [BlueZ,v2,1/3] settings: Fix scan-build warning bluez.test.bot
2022-10-19 20:40 ` [PATCH BlueZ v2 1/3] " patchwork-bot+bluetooth

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 read-only IMAP folder(s) and NNTP newsgroup(s).