BUG/MEDIUM: log/tools: fix cbor binary integer encoding regression with x86_64 systems
A regression was introduced in commit
c1abbb11f ("OPTIM: log/tools:
switch from function pointer design to dual mode HEX/BIN design for
CBOR encoding").
Indeed, it was assumed that for x86_64 systems that the byte order
for uint64_t was already correct and that the value could be written
as-is. This is totally wrong, because x86_64 is little endian while
CBOR is big endian. Because of this mistake, values greater than 24
were written in reverse/incorrect order when using
cbor_encode_uint64_prefix_bin().
To fix the issue, instead of completely ditching the fast-path,
let's leverage htons, htonl and my_htonll for 2, 4 and 8 bytes
value respectively (since the value length is known under the
function), as they are less expensive than writing the value 1
byte at a time.
Many thanks to Dragan Dosen and Martin Mirchev for having reported the
issue.
No backport needed.