[PATCH] Add generic LE/BE load/store uint type convertors and use them in msgb

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/baseband-devel@lists.osmocom.org/.

Holger Hans Peter Freyther holger at freyther.de
Wed Feb 5 09:00:21 UTC 2014


On Fri, Jan 31, 2014 at 03:10:48PM +0100, ☎ wrote:
> v3 attached, comments are inline.

> > this is not lisp.
> 
> Yepp, that makes me sad too :)
> Anyway, fixed.

hmm.. another lisp comment.

> +/* Load unaligned 16-bit integer (little-endian encoding) */
> +static inline uint16_t osmo_load16le(const uint8_t *p)
> +{
> +	return ((uint16_t)p[0]) | ((uint16_t)p[1] << 8);
> +}

do you really need to cast both of them to uint16_t? isn't the
result enough?

> +/* Store unaligned 16-bit integer (little-endian encoding) */
> +static inline void osmo_store16le(uint16_t a, uint8_t *p)
> +{
> +	((uint8_t *)p)[0] = (a) & 0xFF;
> +	((uint8_t *)p)[1] = (a >> 8) & 0xFF;
> +}

these and the below uint8_t casts are not needed for sure.
p is already a uint8_t *. No need to write it down?


sorry. I try to integrate v4 more quickly. :}




More information about the baseband-devel mailing list