[PATCH 05/11] Add utility functions to convert uints to bytes

Anton Lundin glance at acc.umu.se
Mon Dec 15 14:59:03 PST 2014


On 15 December, 2014 - Jef Driesen wrote:

> 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.
> 

As you wish. Fixed

> >+	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.
> 

Fixed.

//Anton

-- 
Anton Lundin	+46702-161604


More information about the devel mailing list