All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: "RISKÓ Gergely" <gergely@risko.hu>
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	linux-bluetooth@vger.kernel.org,
	Context Devel mailing list <context-devel@projects.maemo.org>
Subject: Re: [PATCH] Add introspection interface to the output of introspection calls.
Date: Tue, 15 Sep 2009 18:22:40 +0300	[thread overview]
Message-ID: <20090915152240.GA4378@jh-x301> (raw)
In-Reply-To: <87ws40e6iz.fsf@bubble.risko.hu>

Hi,

The general idea of the patch looks good but there are a few things I'd
still fix:

On Tue, Sep 15, 2009, RISKÓ Gergely wrote:
> -static DBusHandlerResult introspect(DBusConnection *connection,
> -				DBusMessage *message, struct generic_data *data)
> +static DBusMessage *introspect(DBusConnection *connection,
> +				DBusMessage *message, void *data_)

s/data_/user_data/ (to conform to the rest of the code and glib
conventions)

> +	struct generic_data *data = (struct generic_data *) data_;

Unnecessary explicit type-cast of a void pointer.

>  static struct generic_data *object_path_ref(DBusConnection *connection,
>  							const char *path)
>  {
>  	struct generic_data *data;
> +	struct interface_data *iface;
>  
>  	if (dbus_connection_get_object_path_data(connection, path,
>  						(void *) &data) == TRUE) {
> @@ -363,12 +355,23 @@ static struct generic_data *object_path_ref(DBusConnection *connection,
>  
>  	invalidate_parent_data(connection, path);
>  
> +	/* Register the introspection interface */
> +	iface = g_new0(struct interface_data, 1);
> +	iface->name = g_strdup("org.freedesktop.DBus.Introspectable"); // TODO: macro

Either add the macro or remove this comment. Also, we don't use C++ style
commenting.

> +	iface->methods = introspect_methods;
> +	iface->signals = NULL;
> +	iface->properties = NULL;
> +	iface->user_data = data;
> +	iface->destroy = NULL;
> +	data->interfaces = g_slist_append(data->interfaces, iface);
> +

Instead of this duplicate interface initialization code I think it would
make sense to refactor and create a new private function, e.g

static void add_interface(struct generic_cata *data, ...

and call that from the necessary places (afaics there are two of them)

> +	/* Free the introspection interface */
> +	iface = find_interface(data->interfaces, "org.freedesktop.DBus.Introspectable");
> +	if (iface) {
> +		data->interfaces = g_slist_remove(data->interfaces, iface);
> +
> +		if (iface->destroy)
> +			iface->destroy(iface->user_data);
> +
> +		g_free(iface->name);
> +		g_free(iface);

Would it make sense to refactor create a remove_interface function for
this too (to balance with the add_interface function)?

Johan

  reply	other threads:[~2009-09-15 15:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-01 14:10 [PATCH] bluez git HEAD doesn't put introspection methods into the introspection output RISKÓ Gergely
2009-09-02 10:00 ` [PATCH] Add introspection interface to the output of introspection calls RISKÓ Gergely
2009-09-02 14:46   ` Luiz Augusto von Dentz
2009-09-02 17:48     ` RISKÓ Gergely
2009-09-14 14:18       ` Johan Hedberg
2009-09-14 14:52         ` RISKÓ Gergely
2009-09-14 21:11           ` Johan Hedberg
2009-09-15 10:50             ` Luiz Augusto von Dentz
2009-09-15 12:28               ` RISKÓ Gergely
2009-09-15 15:22                 ` Johan Hedberg [this message]
2009-09-15 17:27                   ` Marcel Holtmann
2009-09-15 17:55                     ` Johan Hedberg
2009-09-15 19:25                       ` RISKÓ Gergely
2009-09-16 11:07                   ` RISKÓ Gergely
2009-09-16 11:39                     ` Johan Hedberg
2009-09-16 12:03                       ` RISKÓ Gergely
2009-09-24 17:22                         ` Johan Hedberg

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=20090915152240.GA4378@jh-x301 \
    --to=johan.hedberg@gmail.com \
    --cc=context-devel@projects.maemo.org \
    --cc=gergely@risko.hu \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /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.