[PATCH] logind: Use dbus_bool_t for bool types in dbus calls

David Herrmann dh.herrmann at gmail.com
Wed Nov 20 23:40:42 PST 2013


Hi

On Thu, Nov 21, 2013 at 1:39 AM, Kristian Høgsberg <krh at bitplanet.net> wrote:
> The gcc built-in 'bool' type is not the same size as dbus_bool_t, which is
> an uint32_t.  Passing a pointer to bool where dbus expects a uint32_t *
> doesn't work.

Nice catch! I hate dbus for that type.. happens to me all the time.
Reviewed-by: David Herrmann <dh.herrmann at gmail.com>

> ---
>  src/logind-util.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> David,
>
> This fixes a crash that Artie hit when testing this.  Btw, did you get
> a chance to update the logind error paths to return -1 and set errno
> like we discussed?

I tried that, but systemd and dbus both return negative error codes
instead of errno+-1. So I have to change like 90 places to do:
  errno = -r;
  r = -1;

I can do that, but I thought it looked ugly. As a compromise, I can
only make the public logind-functions do that in the error-path? That
would be only 5 places. Comments?

Thanks
David

> diff --git a/src/logind-util.c b/src/logind-util.c
> index 6bd0c26..a58265c 100644
> --- a/src/logind-util.c
> +++ b/src/logind-util.c
> @@ -69,8 +69,9 @@ weston_logind_take_device(struct weston_logind *wl, uint32_t major,
>                           uint32_t minor, bool *paused_out)
>  {
>         DBusMessage *m, *reply;
> -       bool b, paused;
> +       bool b;
>         int r, fd;
> +       dbus_bool_t paused;
>
>         m = dbus_message_new_method_call("org.freedesktop.login1",
>                                          wl->spath,
> @@ -287,7 +288,7 @@ get_active_cb(DBusPendingCall *pending, void *data)
>         DBusMessage *m;
>         DBusMessageIter iter, sub;
>         int type;
> -       bool b;
> +       dbus_bool_t b;
>
>         dbus_pending_call_unref(wl->pending_active);
>         wl->pending_active = NULL;
> --
> 1.8.3.1
>


More information about the wayland-devel mailing list