Skip to contentSkip to conversation

mesh: Correctly initialize node's vendor models

PATCH In review Inga Stotland 2 participants 2 messages Mar 21, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mesh: Correctly initialize node's vendor models

This fixes vendor model initialization based on node properties collected during Join() method call.

---
 mesh/node.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
mesh/node.c +9 -6
index 761a67af4..999d3b8c0 100644
@@ -1177,17 +1177,20 @@ static void add_model_from_properties(struct node_element *ele,
 static void add_vendor_model_from_properties(struct node_element *ele,
 					struct l_dbus_message_iter *property)
 {
-	struct {
-		uint16_t v;
-		uint16_t m;
-	} id_pair;
+	struct l_dbus_message_iter ids;
+	uint16_t v;
+	uint16_t m;
 
 	if (!ele->models)
 		ele->models = l_queue_new();
 
-	while (l_dbus_message_iter_next_entry(property, &id_pair)) {
+	if (!l_dbus_message_iter_get_variant(property, "a(qq)", &ids))
+		return;
+
+	while (l_dbus_message_iter_next_entry(&ids, &v, &m)) {
 		struct mesh_model *mod;
-		mod = mesh_model_vendor_new(ele->idx, id_pair.v, id_pair.m);
+
+		mod = mesh_model_vendor_new(ele->idx, v, m);
 		l_queue_push_tail(ele->models, mod);
 	}
 }
Signature · 1 line
2.17.2
#1 lore raw

Critical patch applied

Quoted 37 lines · Inga Stotland

This fixes vendor model initialization based on node properties collected during Join() method call.

---
 mesh/node.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
mesh/node.c +9 -6
index 761a67af4..999d3b8c0 100644
@@ -1177,17 +1177,20 @@ static void add_model_from_properties(struct node_element *ele,
 static void add_vendor_model_from_properties(struct node_element *ele,
 					struct l_dbus_message_iter *property)
 {
-	struct {
-		uint16_t v;
-		uint16_t m;
-	} id_pair;
+	struct l_dbus_message_iter ids;
+	uint16_t v;
+	uint16_t m;
 
 	if (!ele->models)
 		ele->models = l_queue_new();
 
-	while (l_dbus_message_iter_next_entry(property, &id_pair)) {
+	if (!l_dbus_message_iter_get_variant(property, "a(qq)", &ids))
+		return;
+
+	while (l_dbus_message_iter_next_entry(&ids, &v, &m)) {
 		struct mesh_model *mod;
-		mod = mesh_model_vendor_new(ele->idx, id_pair.v, id_pair.m);
+
+		mod = mesh_model_vendor_new(ele->idx, v, m);
 		l_queue_push_tail(ele->models, mod);
 	}
 }