[PATCH 05/11] Add utility functions to convert uints to bytes
Jef Driesen
jef at libdivecomputer.org
Mon Dec 15 08:22:35 PST 2014
On 21-11-14 21:28, Anton Lundin wrote:
> unsigned int
> +uint32_le_array (const unsigned int input, unsigned char data[])
The array part in the function name is supposed to be the file prefix. So in
that regard your functions are named a bit strange. Can you rename them to
array_uintXX_{le,be}_set? And while doing that, swap the order of the two
parameters, and make the function return value void.
> + data[0] = input & 0xFF;
> + data[1] = input >> 8 & 0xFF;
> + data[2] = input >> 16 & 0xFF;
> + data[3] = input >> 24 & 0xFF;
I also like to see parentheses around the shift. Not strictly necessary, but it
leaves no doubt for the reader.
Jef
More information about the devel
mailing list