[systemd-devel] [PATCH] Big endian and the size of the gcc builtin type bool from stdbool.h

Dr. Werner Fink werner at suse.de
Thu Sep 18 04:36:47 PDT 2014


On Thu, Sep 18, 2014 at 01:20:47PM +0200, David Herrmann wrote:
> Hi
> 
> On Thu, Sep 18, 2014 at 12:57 PM, Dr. Werner Fink <werner at suse.de> wrote:
> > On Thu, Sep 18, 2014 at 12:43:00PM +0200, David Herrmann wrote:
> >> Hi
> >>
> >> On Thu, Sep 18, 2014 at 11:16 AM, Werner Fink <werner at suse.de> wrote:
> >> > On s390 the big endianness and cast from pointers of integers to
> >> > the type of bool leads to the funny status messages that e.g.
> >> > all targets are set to AllowIsolate=no even for multi-user.target.
> >> >
> >> > The gcc builtin type bool or _Bool has the size of one byte which
> >> > should be taken into account in sd_bus_message_read_basic() as well
> >> > as in bus_message_append_ap()
> >>
> >> We don't support "bool" in public APIs. sd-bus requires you to use
> >> "int" for boolean types. If a caller uses "bool", they must be fixed.
> >
> > Then I'd like to know why the header <stdbool.h> together with the
> > therein provided type _Bool aka bool is used overall systemd. Also
> 
> We use stdbool internally quite a lot. Especially bit-fields are
> really nice if implemented as bool. We just don't use bool in public
> APIs. We also avoid it in combination with va_arg() and with pointers,
> as in both cases the behavior is non-obvious and often done wrong.

Hmmm ... I'm familiar with big endian (IMHO the natural byte order:)

> > it is systemctl which does use sd_bus_message_read_basic() to parse
> > the answer received over sd_bus of the status question send over
> > sd_bus?
> 
> All uses of sd-bus with "bool" are bugs and need to be fixed. See the
> history of bus-message.c:
> 
> commit 9bcbce4201afada1c0ad8ada0cbfbbf58a52a6a7
> Author: Kay Sievers <kay at vrfy.org>
> Date:   Tue Oct 22 03:27:38 2013 +0200
> 
>     bus: avoid 'bool' storage when retrieving 'b' from the message
> 
> commit 102d8f8169427cb68cdebf5ee0f0e07788e9c2b2
> Author: Kay Sievers <kay at vrfy.org>
> Date:   Thu Nov 7 02:03:10 2013 +0100
> 
>     consistently use "int" when retrieving "bool" from bus messages

The only problem which remains: on s390 the sd_bus_message_read_basic()
does it internal wrong (IMHO).  If a bool is internal used and send
over the dbus then the internal of sd_bus_message_read_basic()
or at least bus_print_property() should be able to handle this.

Werner

-- 
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20140918/8bb5356c/attachment.sig>


More information about the systemd-devel mailing list