All of lore.kernel.org
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ell@lists.01.org
Subject: Re: [PATCH 1/2] dbus: Add private _dbus_message_new_error
Date: Mon, 18 Apr 2016 21:37:49 -0500	[thread overview]
Message-ID: <571599FD.8050407@gmail.com> (raw)
In-Reply-To: <1460989877-20113-1-git-send-email-andrew.zaborowski@intel.com>

[-- Attachment #1: Type: text/plain, Size: 3497 bytes --]

Hi Andrew,

On 04/18/2016 09:31 AM, Andrew Zaborowski wrote:
> ---
>   ell/dbus-message.c | 47 +++++++++++++++++++++++++++++++----------------
>   ell/dbus-private.h |  5 +++++
>   2 files changed, 36 insertions(+), 16 deletions(-)
>
> diff --git a/ell/dbus-message.c b/ell/dbus-message.c
> index a409e53..86cec96 100644
> --- a/ell/dbus-message.c
> +++ b/ell/dbus-message.c
> @@ -328,33 +328,32 @@ LIB_EXPORT struct l_dbus_message *l_dbus_message_new_method_return(
>   	return message;
>   }
>
> -LIB_EXPORT struct l_dbus_message *l_dbus_message_new_error_valist(
> -					struct l_dbus_message *method_call,
> -					const char *name,
> -					const char *format, va_list args)
> +struct l_dbus_message *_dbus_message_new_error(uint8_t version,
> +						uint32_t reply_serial,
> +						const char *destination,
> +						const char *name,
> +						const char *error)
>   {
> -	char str[1024];
>   	struct l_dbus_message *reply;
> -	struct dbus_header *hdr = method_call->header;
> -	const char *sender;
> +	bool r;
>
>   	if (!_dbus_valid_interface(name))
>   		return NULL;
>
> -	vsnprintf(str, sizeof(str), format, args);
>   	reply = message_new_common(DBUS_MESSAGE_TYPE_ERROR,
>   					DBUS_MESSAGE_FLAG_NO_REPLY_EXPECTED,
> -					hdr->version);
> -
> -	reply->reply_serial = _dbus_message_get_serial(method_call);
> -
> -	sender = l_dbus_message_get_sender(method_call);
> -	if (sender)
> -		reply->destination = l_strdup(sender);
> +					version);
>
>   	reply->error_name = l_strdup(name);
> +	reply->destination = l_strdup(destination);
> +	reply->reply_serial = reply_serial;
>
> -	if (!l_dbus_message_set_arguments(reply, "s", str)) {
> +	if (error)
> +		r = l_dbus_message_set_arguments(reply, "s", error);
> +	else
> +		r = l_dbus_message_set_arguments(reply, "");

Under what circumstances would we want to create an error without at 
least a single string argument?

> +
> +	if (!r) {
>   		l_dbus_message_unref(reply);
>   		return NULL;
>   	}
> @@ -362,6 +361,22 @@ LIB_EXPORT struct l_dbus_message *l_dbus_message_new_error_valist(
>   	return reply;
>   }
>
> +LIB_EXPORT struct l_dbus_message *l_dbus_message_new_error_valist(
> +					struct l_dbus_message *method_call,
> +					const char *name,
> +					const char *format, va_list args)
> +{
> +	char str[1024];
> +	struct dbus_header *hdr = method_call->header;
> +
> +	vsnprintf(str, sizeof(str), format, args);
> +
> +	return _dbus_message_new_error(hdr->version,
> +					_dbus_message_get_serial(method_call),
> +					l_dbus_message_get_sender(method_call),
> +					name, str);
> +}
> +
>   LIB_EXPORT struct l_dbus_message *l_dbus_message_new_error(
>   					struct l_dbus_message *method_call,
>   					const char *name,
> diff --git a/ell/dbus-private.h b/ell/dbus-private.h
> index 63c239b..030ce0b 100644
> --- a/ell/dbus-private.h
> +++ b/ell/dbus-private.h
> @@ -141,6 +141,11 @@ struct l_dbus_message *_dbus_message_new_signal(uint8_t version,
>   						const char *path,
>   						const char *interface,
>   						const char *name);
> +struct l_dbus_message *_dbus_message_new_error(uint8_t version,
> +						uint32_t reply_serial,
> +						const char *destination,
> +						const char *name,
> +						const char *error);
>
>   struct l_dbus_message *dbus_message_from_blob(const void *data, size_t size);
>   struct l_dbus_message *dbus_message_build(void *header, size_t header_size,
>

Regards,
-Denis

  parent reply	other threads:[~2016-04-19  2:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18 14:31 [PATCH 1/2] dbus: Add private _dbus_message_new_error Andrew Zaborowski
2016-04-18 14:31 ` [PATCH 2/2] dbus: Handle kdbus KDBUS_ITEM_REPLY_TIMEOUT / _DEAD Andrew Zaborowski
2016-04-18 14:31 ` [PATCH] dbus: Check message->sealed before get_header_field() Andrew Zaborowski
2016-04-19  2:39   ` Denis Kenzior
2016-04-18 14:31 ` [PATCH] dbus: Don't send replies to messages with no reply flag Andrew Zaborowski
2016-04-18 14:31 ` [PATCH] unit: Add test-dbus-properties --kdbus option Andrew Zaborowski
2016-04-19  2:41   ` Denis Kenzior
2016-04-18 14:31 ` [PATCH 1/5] dbus: Add a Bus Name cache Andrew Zaborowski
2016-04-21  3:30   ` Denis Kenzior
2016-04-18 14:31 ` [PATCH 2/5] dbus: Use the name cache API in _dbus_filter Andrew Zaborowski
2016-04-18 14:31 ` [PATCH 3/5] unit: Update _dbus_filter usage in test-dbus-watch Andrew Zaborowski
2016-04-18 14:31 ` [PATCH 4/5] dbus: Add service watch API based on the name cache Andrew Zaborowski
2016-04-18 14:31 ` [PATCH 5/5] dbus: Use the name cache for public service watches Andrew Zaborowski
2016-04-19  2:37 ` Denis Kenzior [this message]
2016-04-22  0:03   ` [PATCH 1/2] dbus: Add private _dbus_message_new_error Andrzej Zaborowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=571599FD.8050407@gmail.com \
    --to=denkenz@gmail.com \
    --cc=ell@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.