0-size array marshaling ?
Jean Parpaillon
jean.parpaillon at free.fr
Mon Jul 18 09:08:37 UTC 2016
Hi,
Thanks for the tip.
Answer is: always pad, even with 0-size array.
Test code in attachment.
I think I've fixed dbus-java code in https://github.com/jeanparpaillon/
dbus-java
Would be glad to push into the right repository, but freedesktop one
does not seem to be up-to-date (no 2.8 tag).
Regards
Jean
Le mardi 05 juillet 2016 à 10:41 +0100, Simon McVittie a écrit :
> 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
>
> re>).
>
> 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
--
Jean Parpaillon
--
Open Source Consultant
Director @ OW2 Consortium
OCCIware Strategic Orientation Committee Chairman
Research Engineer @ Inria
--
Phone: +33 6 30 10 92 86
im: jean.parpaillon at gmail.com
skype: jean.parpaillon
linkedin: http://www.linkedin.com/in/jeanparpaillon/en
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dbus/attachments/20160718/af28068f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: marshal.c
Type: text/x-csrc
Size: 783 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/dbus/attachments/20160718/af28068f/attachment.c>
More information about the dbus
mailing list