2019-07-04 12:34:26

by Michał Lowas-Rzechonek

[permalink] [raw]
Subject: [PATCH BlueZ v5 1/5] mesh: Cleanup l_dbus_message_... API usage in models

---
mesh/model.c | 34 ++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)

diff --git a/mesh/model.c b/mesh/model.c
index 7401dcecb..868fe9e52 100644
--- a/mesh/model.c
+++ b/mesh/model.c
@@ -249,10 +249,10 @@ static void config_update_model_pub_period(struct mesh_node *node,
&period);

l_dbus_message_builder_leave_array(builder);
- if (l_dbus_message_builder_finalize(builder))
- l_dbus_send(dbus, msg);
-
+ l_dbus_message_builder_finalize(builder);
l_dbus_message_builder_destroy(builder);
+
+ l_dbus_send(dbus, msg);
}

static void append_dict_uint16_array(struct l_dbus_message_builder *builder,
@@ -291,10 +291,10 @@ static void config_update_model_bindings(struct mesh_node *node,
append_dict_uint16_array(builder, mod->bindings, "Bindings");

l_dbus_message_builder_leave_array(builder);
- if (l_dbus_message_builder_finalize(builder))
- l_dbus_send(dbus, msg);
-
+ l_dbus_message_builder_finalize(builder);
l_dbus_message_builder_destroy(builder);
+
+ l_dbus_send(dbus, msg);
}

static void forward_model(void *a, void *b)
@@ -714,25 +714,15 @@ static void send_msg_rcvd(struct mesh_node *node, uint8_t ele_idx, bool is_sub,

builder = l_dbus_message_builder_new(msg);

- if (!l_dbus_message_builder_append_basic(builder, 'q', &src))
- goto error;
+ l_dbus_message_builder_append_basic(builder, 'q', &src);
+ l_dbus_message_builder_append_basic(builder, 'q', &key_idx);
+ l_dbus_message_builder_append_basic(builder, 'b', &is_sub);
+ dbus_append_byte_array(builder, data, size);

- if (!l_dbus_message_builder_append_basic(builder, 'q', &key_idx))
- goto error;
-
- if (!l_dbus_message_builder_append_basic(builder, 'b', &is_sub))
- goto error;
-
- if (!dbus_append_byte_array(builder, data, size))
- goto error;
-
- if (!l_dbus_message_builder_finalize(builder))
- goto error;
+ l_dbus_message_builder_finalize(builder);
+ l_dbus_message_builder_destroy(builder);

l_dbus_send(dbus, msg);
-
-error:
- l_dbus_message_builder_destroy(builder);
}

bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0,
--
2.19.1


2019-07-04 18:16:51

by Gix, Brian

[permalink] [raw]
Subject: Re: [PATCH BlueZ v5 1/5] mesh: Cleanup l_dbus_message_... API usage in models

Applied entire patch-set *except* patch 1, which is a functional
duplicate of the same l_dbus clean-up that Inga submitted.

This has been run and build tested, but since this affects hard to
reproduce *error* handling, please double-check the final result.



On Thu, 2019-07-04 at 14:33 +0200, Michał Lowas-Rzechonek wrote:
> ---
> mesh/model.c | 34 ++++++++++++----------------------
> 1 file changed, 12 insertions(+), 22 deletions(-)
>
> diff --git a/mesh/model.c b/mesh/model.c
> index 7401dcecb..868fe9e52 100644
> --- a/mesh/model.c
> +++ b/mesh/model.c
> @@ -249,10 +249,10 @@ static void
> config_update_model_pub_period(struct mesh_node *node,
> &period
> );
>
> l_dbus_message_builder_leave_array(builder);
> - if (l_dbus_message_builder_finalize(builder))
> - l_dbus_send(dbus, msg);
> -
> + l_dbus_message_builder_finalize(builder);
> l_dbus_message_builder_destroy(builder);
> +
> + l_dbus_send(dbus, msg);
> }
>
> static void append_dict_uint16_array(struct l_dbus_message_builder
> *builder,
> @@ -291,10 +291,10 @@ static void config_update_model_bindings(struct
> mesh_node *node,
> append_dict_uint16_array(builder, mod->bindings, "Bindings");
>
> l_dbus_message_builder_leave_array(builder);
> - if (l_dbus_message_builder_finalize(builder))
> - l_dbus_send(dbus, msg);
> -
> + l_dbus_message_builder_finalize(builder);
> l_dbus_message_builder_destroy(builder);
> +
> + l_dbus_send(dbus, msg);
> }
>
> static void forward_model(void *a, void *b)
> @@ -714,25 +714,15 @@ static void send_msg_rcvd(struct mesh_node
> *node, uint8_t ele_idx, bool is_sub,
>
> builder = l_dbus_message_builder_new(msg);
>
> - if (!l_dbus_message_builder_append_basic(builder, 'q', &src))
> - goto error;
> + l_dbus_message_builder_append_basic(builder, 'q', &src);
> + l_dbus_message_builder_append_basic(builder, 'q', &key_idx);
> + l_dbus_message_builder_append_basic(builder, 'b', &is_sub);
> + dbus_append_byte_array(builder, data, size);
>
> - if (!l_dbus_message_builder_append_basic(builder, 'q',
> &key_idx))
> - goto error;
> -
> - if (!l_dbus_message_builder_append_basic(builder, 'b',
> &is_sub))
> - goto error;
> -
> - if (!dbus_append_byte_array(builder, data, size))
> - goto error;
> -
> - if (!l_dbus_message_builder_finalize(builder))
> - goto error;
> + l_dbus_message_builder_finalize(builder);
> + l_dbus_message_builder_destroy(builder);
>
> l_dbus_send(dbus, msg);
> -
> -error:
> - l_dbus_message_builder_destroy(builder);
> }
>
> bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t
> seq0,