<html><head></head><body><div>Hi,</div><div>Thanks for the tip.</div><div>Answer is: always pad, even with 0-size array.</div><div>Test code in attachment.</div><div><br></div><div>I think I've fixed dbus-java code in <a href="https://github.com/jeanparpaillon/dbus-java">https://github.com/jeanparpaillon/dbus-java</a></div><div>Would be glad to push into the right repository, but freedesktop one does not seem to be up-to-date (no 2.8 tag).</div><div><br></div><div>Regards</div><div>Jean</div><div><br></div><div>Le mardi 05 juillet 2016 à 10:41 +0100, Simon McVittie a écrit :</div><blockquote type="cite"><div>On 04/07/16 14:43, Jean Parpaillon wrote:</div><blockquote type="cite"><div>The question is: for 0-size array, is padding to the alignment boundary</div><div>of the array element type required ?</div></blockquote><div><br></div><div>libdbus (dbus.git) is the reference implementation. What does it do?</div><div>That's your answer. I would be happy to review a spec patch that</div><div>clarifies what the right thing is (via</div><div><https://bugs.freedesktop.org/enter_bug.cgi?product=dbus&component=core>).</div><div><br></div><div>Because the array length is aligned to a 4-byte boundary, I would</div><div>suggest serializing this message:</div><div><br></div><div>- type 'u', uint32 0x11223344 (to make it easy to find the payload)</div><div>- type 'y', byte with arbitrary non-zero value, say 0x42</div><div>- type 'at', empty array of uint64</div><div>- type 'y', byte with arbitrary non-zero value, say 0x23</div><div><br></div><div>and looking at the resulting serialized bytes. If arrays of length 0 do</div><div>insert padding appropriate for the content, I would expect this hex-dump:</div><div><br></div><div>44 33 22 11 # uint32 (I've assumed little-endian)</div><div> 42 # first byte</div><div> 00 00 00 # pad to 4-byte boundary</div><div>00 00 00 00 # array length</div><div> 00 00 00 00 # pad to 8-byte boundary</div><div> # no array contents</div><div>23 # second byte</div><div><br></div><div>and if they don't, I would expect:</div><div><br></div><div>44 33 22 11 # uint32 (I've assumed little-endian)</div><div> 42 # first byte</div><div> 00 00 00 # pad to 4-byte boundary</div><div>00 00 00 00 # array length</div><div> # no padding, no array contents</div><div> 23 # second byte</div><div><br></div><div>Whichever one libdbus does, that's correct and the other one is wrong.</div><div><br></div><div>Regards,</div><div> S</div></blockquote><div><span><pre><pre>--
</pre>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@gmail.com
skype: jean.parpaillon
linkedin: http://www.linkedin.com/in/jeanparpaillon/en</pre></span></div></body></html>