The new bytearray.h
Andreas Schneider
asn at samba.org
Thu Mar 5 07:23:00 UTC 2020
Hello!
TL;DR: Please use (PUSH|PULL)_(U|I)_(8|16|32|64) instead of e.g. SVIAL.
You might have recognized that we have a new header called lib/util/
bytearray.h. The file will replace the lib/util/byterorder.h.
As other code I've written bytearray.h for libssh originally. It doesn't
depend on undefined behavior which byteorder.h did. Yes, libubsan complained
about code which used byteorder.h. The byteorder.h has been change to use the
functions from bytearray.h.
Also I followed the naming form NDR. So the function names are for example:
* PUSH_BE_U32() to push an uint32_t to array in big endian order.
* PULL_LE_64() to pull an uin64_t from an array in little endian order.
I find those names much more descriptive than e.g. SIVAL(). I never know what
that thing actually does until I take a look what the macro does.
Please if you write or modify code, please use the new macros! The plan is to
get rid of byteorder.h one day.
Thanks,
Andreas
--
Andreas Schneider asn at samba.org
Samba Team www.samba.org
GPG-ID: 8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D
More information about the samba-technical
mailing list