Re: 0-size array marshaling ?

Simon McVittie <simon.mcvittie-ZGY8ohtN/[email protected]>
Newsgroups gmane.comp.freedesktop.dbus
Organization Collabora Ltd.
Message-ID <[email protected]>
On 04/07/16 14:43, Jean Parpaillon wrote:
> The question is: for 0-size array, is padding to the alignment boundary
> of the array element type required ?

libdbus (dbus.git) is the reference implementation. What does it do?
That's your answer. I would be happy to review a spec patch that
clarifies what the right thing is (via
<https://bugs.freedesktop.org/enter_bug.cgi?product=dbus&component=core>).

Because the array length is aligned to a 4-byte boundary, I would
suggest serializing this message:

- type 'u', uint32 0x11223344 (to make it easy to find the payload)
- type 'y', byte with arbitrary non-zero value, say 0x42
- type 'at', empty array of uint64
- type 'y', byte with arbitrary non-zero value, say 0x23

and looking at the resulting serialized bytes. If arrays of length 0 do
insert padding appropriate for the content, I would expect this hex-dump:

44 33 22 11                 # uint32 (I've assumed little-endian)
            42              # first byte
               00 00 00     # pad to 4-byte boundary
00 00 00 00                 # array length
            00 00 00 00     # pad to 8-byte boundary
                            # no array contents
23                          # second byte

and if they don't, I would expect:

44 33 22 11                 # uint32 (I've assumed little-endian)
            42              # first byte
               00 00 00     # pad to 4-byte boundary
00 00 00 00                 # array length
                            # no padding, no array contents
            23              # second byte

Whichever one libdbus does, that's correct and the other one is wrong.

Regards,
    S
-- 
Simon McVittie
Collabora Ltd. <http://www.collabora.com/>

_______________________________________________
dbus mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dbus
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.