[PATCH 1/1] Check error beofre call dbus_message_get_args to acquire arguments.

Marcel Holtmann marcel at holtmann.org
Mon Apr 26 20:17:42 PDT 2010


Hi Martin,

I think you see the spelling mistake in the subject after me point you
at it ;)

And please figure out why this email gets threaded as part of an old
thread. It should be a new one actually.

> Function dbus_message_get_args just checks the signature which may
> happens to be s(string), then it will just return TRUE, and the wrong
> error message is gotten.

Actually this is not correct. No error message at all gets retrieved and
the error message is treated as valid return value. Just some semantics.

> So dbus_set_error_from_message is used to check the error, before
> call dbus_message_get_args.
> ---
>  plugins/bluetooth.c |   37 +++++++++++++++++++++++++++++++++----
>  1 files changed, 33 insertions(+), 4 deletions(-)
> 
> diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
> index 1c0fa96..f5b4081 100644
> --- a/plugins/bluetooth.c
> +++ b/plugins/bluetooth.c
> @@ -85,9 +85,15 @@ static void connect_reply(DBusPendingCall *call, void *user_data)
>  
>  	DBG("network %p", network);
>  
> +	dbus_error_init(&error);
> +
>  	reply = dbus_pending_call_steal_reply(call);
> +	if (dbus_set_error_from_message(&error, reply)) {
> +		connman_error("%s", error.message);
> +		dbus_error_free(&error);

actually prefer a bit different order.

	reply = dbus_pending...

	dbus_error_init(...

	if (dbus_set_error(...) == TRUE)

Don't forget the == TRUE here.

Regards

Marcel





More information about the connman mailing list