diff mbox series

[BlueZ,1/4] util: Introduce util_debug_va

Message ID 20210108211513.5180-1-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ,1/4] util: Introduce util_debug_va | expand

Commit Message

Luiz Augusto von Dentz Jan. 8, 2021, 9:15 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This introduces util_debug_va which can take a va_list that enables
callers to create wrapper functions if they need to.
---
 src/shared/util.c | 19 ++++++++++++++-----
 src/shared/util.h |  4 ++++
 2 files changed, 18 insertions(+), 5 deletions(-)

Comments

bluez.test.bot@gmail.com Jan. 8, 2021, 9:40 p.m. UTC | #1
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=411499

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS



---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz Jan. 11, 2021, 4:46 p.m. UTC | #2
Hi,

On Fri, Jan 8, 2021 at 1:40 PM <bluez.test.bot@gmail.com> wrote:
>

> 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=411499

>

> ---Test result---

>

> ##############################

> Test: CheckPatch - PASS

>

> ##############################

> Test: CheckGitLint - PASS

>

> ##############################

> Test: CheckBuild - PASS

>

> ##############################

> Test: MakeCheck - PASS


Pushed.

-- 
Luiz Augusto von Dentz
Sathish Narasimman Jan. 20, 2021, 9:29 a.m. UTC | #3
Hi Luiz

On Sat, Jan 9, 2021 at 2:48 AM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>

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

>

> Unfortunately assuming service changed has been subscribed may cause

> indication to time out in some peripherals (Logitech M720 Triathlon, Mx

> Anywhere 2, Lenovo Mice N700, RAPOO BleMouse and Microsoft Designer

> Mouse) even though the expect actually mandates that the client responds

> with confirmation these peripherals just ignores it completely which

> leads them to be disconnected whenever bluetoothd is restarted or the

> system reboots.

> ---

>  src/device.c        | 11 ++---------

>  src/gatt-database.c |  2 +-

>  2 files changed, 3 insertions(+), 10 deletions(-)

>

> diff --git a/src/device.c b/src/device.c

> index fe885aa64..af13badfc 100644

> --- a/src/device.c

> +++ b/src/device.c

> @@ -5831,18 +5831,11 @@ void device_load_svc_chng_ccc(struct btd_device *device, uint16_t *ccc_le,

>         key_file = g_key_file_new();

>         g_key_file_load_from_file(key_file, filename, 0, NULL);

>

> -       /*

> -        * If there is no "ServiceChanged" section we may be loading data from

> -        * old version which did not persist Service Changed CCC values. Let's

> -        * check if we are bonded and assume indications were enabled by peer

> -        * in such case - it should have done this anyway.

> -        */

>         if (!g_key_file_has_group(key_file, "ServiceChanged")) {

>                 if (ccc_le)

> -                       *ccc_le = device->le_state.bonded ? 0x0002 : 0x0000;

> +                       *ccc_le = 0x0000;

>                 if (ccc_bredr)

> -                       *ccc_bredr = device->bredr_state.bonded ?

> -                                                       0x0002 : 0x0000;

> +                       *ccc_bredr = 0x0000;

>                 g_key_file_free(key_file);

>                 return;

>         }

> diff --git a/src/gatt-database.c b/src/gatt-database.c

> index b7d2bea1d..d99604826 100644

> --- a/src/gatt-database.c

> +++ b/src/gatt-database.c

> @@ -333,7 +333,7 @@ static void att_disconnected(int err, void *user_data)

>                 handle = gatt_db_attribute_get_handle(state->db->svc_chngd_ccc);

>

>                 ccc = find_ccc_state(state, handle);

> -               if (ccc)

> +               if (ccc && ccc->value)

>                         device_store_svc_chng_ccc(device, state->bdaddr_type,

>                                                                 ccc->value);

>

> --

> 2.26.2

>


Was this patch is merged?

Regards
Sathish N
Luiz Augusto von Dentz Jan. 20, 2021, 3:35 p.m. UTC | #4
Hi Sathish,

On Wed, Jan 20, 2021 at 1:30 AM Sathish Narasimman <nsathish41@gmail.com> wrote:
>

> Hi Luiz

>

> On Sat, Jan 9, 2021 at 2:48 AM Luiz Augusto von Dentz

> <luiz.dentz@gmail.com> wrote:

> >

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

> >

> > Unfortunately assuming service changed has been subscribed may cause

> > indication to time out in some peripherals (Logitech M720 Triathlon, Mx

> > Anywhere 2, Lenovo Mice N700, RAPOO BleMouse and Microsoft Designer

> > Mouse) even though the expect actually mandates that the client responds

> > with confirmation these peripherals just ignores it completely which

> > leads them to be disconnected whenever bluetoothd is restarted or the

> > system reboots.

> > ---

> >  src/device.c        | 11 ++---------

> >  src/gatt-database.c |  2 +-

> >  2 files changed, 3 insertions(+), 10 deletions(-)

> >

> > diff --git a/src/device.c b/src/device.c

> > index fe885aa64..af13badfc 100644

> > --- a/src/device.c

> > +++ b/src/device.c

> > @@ -5831,18 +5831,11 @@ void device_load_svc_chng_ccc(struct btd_device *device, uint16_t *ccc_le,

> >         key_file = g_key_file_new();

> >         g_key_file_load_from_file(key_file, filename, 0, NULL);

> >

> > -       /*

> > -        * If there is no "ServiceChanged" section we may be loading data from

> > -        * old version which did not persist Service Changed CCC values. Let's

> > -        * check if we are bonded and assume indications were enabled by peer

> > -        * in such case - it should have done this anyway.

> > -        */

> >         if (!g_key_file_has_group(key_file, "ServiceChanged")) {

> >                 if (ccc_le)

> > -                       *ccc_le = device->le_state.bonded ? 0x0002 : 0x0000;

> > +                       *ccc_le = 0x0000;

> >                 if (ccc_bredr)

> > -                       *ccc_bredr = device->bredr_state.bonded ?

> > -                                                       0x0002 : 0x0000;

> > +                       *ccc_bredr = 0x0000;

> >                 g_key_file_free(key_file);

> >                 return;

> >         }

> > diff --git a/src/gatt-database.c b/src/gatt-database.c

> > index b7d2bea1d..d99604826 100644

> > --- a/src/gatt-database.c

> > +++ b/src/gatt-database.c

> > @@ -333,7 +333,7 @@ static void att_disconnected(int err, void *user_data)

> >                 handle = gatt_db_attribute_get_handle(state->db->svc_chngd_ccc);

> >

> >                 ccc = find_ccc_state(state, handle);

> > -               if (ccc)

> > +               if (ccc && ccc->value)

> >                         device_store_svc_chng_ccc(device, state->bdaddr_type,

> >                                                                 ccc->value);

> >

> > --

> > 2.26.2

> >

>

> Was this patch is merged?


Yes, https://git.kernel.org/pub/scm/bluetooth/bluez.git/commit/?id=39054d59c0ecdb102f8aa352cb7aa6fcbd7f2b6b

> Regards

> Sathish N




-- 
Luiz Augusto von Dentz
diff mbox series

Patch

diff --git a/src/shared/util.c b/src/shared/util.c
index 525302164..9c2054211 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -15,7 +15,6 @@ 
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <ctype.h>
-#include <stdarg.h>
 #include <stdbool.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -42,20 +41,30 @@  void *btd_malloc(size_t size)
 	return NULL;
 }
 
+void util_debug_va(util_debug_func_t function, void *user_data,
+				const char *format, va_list va)
+{
+	char str[78];
+
+	if (!function || !format)
+		return;
+
+	vsnprintf(str, sizeof(str), format, va);
+
+	function(str, user_data);
+}
+
 void util_debug(util_debug_func_t function, void *user_data,
 						const char *format, ...)
 {
-	char str[78];
 	va_list ap;
 
 	if (!function || !format)
 		return;
 
 	va_start(ap, format);
-	vsnprintf(str, sizeof(str), format, ap);
+	util_debug_va(function, user_data, format, ap);
 	va_end(ap);
-
-	function(str, user_data);
 }
 
 void util_hexdump(const char dir, const unsigned char *buf, size_t len,
diff --git a/src/shared/util.h b/src/shared/util.h
index 6fb702797..d6de55885 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -10,6 +10,7 @@ 
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <alloca.h>
 #include <byteswap.h>
 #include <string.h>
@@ -89,6 +90,9 @@  void *btd_malloc(size_t size);
 
 typedef void (*util_debug_func_t)(const char *str, void *user_data);
 
+void util_debug_va(util_debug_func_t function, void *user_data,
+				const char *format, va_list va);
+
 void util_debug(util_debug_func_t function, void *user_data,
 						const char *format, ...)
 					__attribute__((format(printf, 3, 4)));