The org.freedesktop.DBus.Properties.PropertiesChanged signal allows
sending "invalidated_properties" (only property names without values).
In this case the property_changed callbacks are called with NULL iterator
by gdbus/client.c::properties_changed():
...
proxy->prop_func(..., ..., iter=NULL, ...)
...
Christian Eggers (9):
advertising: parse_secondary: fix loop condition
advertising: parse_secondary: fix mask value
advertising: parse_secondary: check for NULL iterator
advertising: parse_min_interval: reset min_interval if iter is NULL
advertising: parse_[min|max]_interval: reset value if iter is NULL
advertising: parse_tx_power: reset value if iter is NULL
client/gatt: proxy_property_changed: check for NULL iterator
gatt: proxy_property_changed: check for NULL iterator
battery: provided_battery_property_changed_cb: check for NULL iterator
client/gatt.c | 5 +++++
src/advertising.c | 22 +++++++++++++++++-----
src/battery.c | 10 ++++++----
src/gatt-database.c | 20 +++++++++++---------
4 files changed, 39 insertions(+), 18 deletions(-)
--
2.35.3
Set property to its default value (as done in all other methods listed
in parsers[]).
---
src/advertising.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/advertising.c b/src/advertising.c
index 6d8d06edd34f..fbfd90b4e300 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1087,8 +1087,10 @@ static bool parse_min_interval(DBusMessageIter *iter,
if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL))
return true;
- if (!iter)
+ if (!iter) {
+ client->min_interval = 0;
return false;
+ }
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32)
return false;
--
2.35.3
Set property to its default value (as done in all other methods listed
in parsers[]).
---
src/advertising.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/advertising.c b/src/advertising.c
index fbfd90b4e300..25df2297b3c1 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1120,8 +1120,10 @@ static bool parse_max_interval(DBusMessageIter *iter,
if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL))
return true;
- if (!iter)
+ if (!iter) {
+ client->max_interval = 0;
return false;
+ }
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32)
return false;
--
2.35.3
Set property to its default value (as done in all other methods listed
in parsers[]).
---
src/advertising.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/advertising.c b/src/advertising.c
index 25df2297b3c1..f9748b1328bc 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1153,8 +1153,10 @@ static bool parse_tx_power(DBusMessageIter *iter,
if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL))
return true;
- if (!iter)
+ if (!iter) {
+ client->tx_power = ADV_TX_POWER_NO_PREFERENCE;
return false;
+ }
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INT16)
return false;
--
2.35.3
The passed iterator can be NULL as in
gdbus/client.c::properties_changed():
...
proxy->prop_func(..., ..., iter=NULL, ...)
+--src/battery.c::provided_battery_property_changed_cb(, , iter, );
+--dbus_message_iter_get_arg_type(iter);
...
---
src/battery.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/battery.c b/src/battery.c
index 77fee22b6e61..88a53e80e890 100644
--- a/src/battery.c
+++ b/src/battery.c
@@ -252,7 +252,7 @@ static void provided_battery_property_changed_cb(GDBusProxy *proxy,
DBusMessageIter *iter,
void *user_data)
{
- uint8_t percentage;
+ uint8_t percentage = 0;
const char *export_path;
DBusMessageIter dev_iter;
@@ -264,10 +264,12 @@ static void provided_battery_property_changed_cb(GDBusProxy *proxy,
if (strcmp(name, "Percentage") != 0)
return;
- if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BYTE)
- return;
+ if (iter) {
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BYTE)
+ return;
- dbus_message_iter_get_basic(iter, &percentage);
+ dbus_message_iter_get_basic(iter, &percentage);
+ }
DBG("battery percentage changed on %s, percentage = %d",
g_dbus_proxy_get_path(proxy), percentage);
--
2.35.3
The passed iterator can be NULL as in
gdbus/client.c::properties_changed():
...
proxy->prop_func(..., ..., iter=NULL, ...)
+--client/gatt.c::proxy_property_changed(..., ..., iter, ...);
+--dbus_message_iter_get_arg_type(iter);
...
---
client/gatt.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/client/gatt.c b/client/gatt.c
index efd736b2359a..c3bdd4710897 100644
--- a/client/gatt.c
+++ b/client/gatt.c
@@ -3003,17 +3003,20 @@ static void proxy_property_changed(GDBusProxy *proxy, const char *name,
chrc->path, bt_uuidstr_to_str(chrc->uuid), name);
if (!strcmp(name, "Value")) {
- DBusMessageIter array;
- uint8_t *value;
- int len;
+ uint8_t *value = NULL;
+ int len = 0;
+
+ if (iter && dbus_message_iter_get_arg_type(iter) ==
+ DBUS_TYPE_ARRAY) {
+ DBusMessageIter array;
- if (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_ARRAY) {
dbus_message_iter_recurse(iter, &array);
dbus_message_iter_get_fixed_array(&array, &value, &len);
- write_value(&chrc->value_len, &chrc->value, value, len,
- 0, chrc->max_val_len);
- bt_shell_hexdump(value, len);
}
+
+ write_value(&chrc->value_len, &chrc->value, value, len,
+ 0, chrc->max_val_len);
+ bt_shell_hexdump(value, len);
}
g_dbus_emit_property_changed(conn, chrc->path, CHRC_INTERFACE, name);
--
2.35.3
The passed iterator can be NULL as in
src/gatt-database.c::properties_changed():
...
proxy->prop_func(..., ..., iter=NULL, ...)
+--client/gatt.c::property_changed_cb(..., ..., iter, ...);
+--dbus_message_iter_get_arg_type(iter);
...
---
src/gatt-database.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/gatt-database.c b/src/gatt-database.c
index c72f4a4d5c54..ea282d4bc193 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -2867,17 +2867,19 @@ static void property_changed_cb(GDBusProxy *proxy, const char *name,
if (strcmp(name, "Value"))
return;
- if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) {
- DBG("Malformed \"Value\" property received");
- return;
- }
+ if (iter) {
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) {
+ DBG("Malformed \"Value\" property received");
+ return;
+ }
- dbus_message_iter_recurse(iter, &array);
- dbus_message_iter_get_fixed_array(&array, &value, &len);
+ dbus_message_iter_recurse(iter, &array);
+ dbus_message_iter_get_fixed_array(&array, &value, &len);
- if (len < 0) {
- DBG("Malformed \"Value\" property received");
- return;
+ if (len < 0) {
+ DBG("Malformed \"Value\" property received");
+ return;
+ }
}
/* Truncate the value if it's too large */
--
2.35.3
Hello:
This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:
On Fri, 23 Sep 2022 12:26:00 +0200 you wrote:
> Set property to its default value (as done in all other methods listed
> in parsers[]).
> ---
> src/advertising.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Here is the summary with links:
- [BlueZ,4/9] advertising: parse_min_interval: reset min_interval if iter is NULL
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=abfb3a807c39
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html