[PATCH 4/5] Expand bitvec interface

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/OpenBSC@lists.osmocom.org/.

Holger Freyther holger at freyther.de
Tue Jan 26 13:32:31 UTC 2016


> On 26 Jan 2016, at 12:17, Jacob Erlbeck <jerlbeck at sysmocom.de> wrote:
> 
> On 26.01.2016 11:22, Holger Freyther wrote:
>> 
>>> On 22 Jan 2016, at 16:46, suraev at alumni.ntnu.no wrote:
> 
>>> +/* we assume that x have at least 1 non-b bit */
>>> +static inline unsigned _leading_bits(uint8_t x, bool b)
>>> +{
>>> +	if (b) {
>>> +		if (x < 0x80) return 0;
>>> +		if (x < 0xC0) return 1;
>>> +		if (x < 0xE0) return 2;
>>> +		if (x < 0xF0) return 3;
>>> +		if (x < 0xF8) return 4;
>>> +		if (x < 0xFC) return 5;
>>> +		if (x < 0xFE) return 6;
>>> +	} else {
>>> +		if (x > 0x7F) return 0;
>>> +		if (x > 0x3F) return 1;
>>> +		if (x > 0x1F) return 2;
>>> +		if (x > 0xF) return 3;
>>> +		if (x > 7) return 4;
>>> +		if (x > 3) return 5;
>>> +		if (x > 1) return 6;
>>> +	}
>> 
>> 	same coding style thing
> 
> In such cases, the readability would suffer when putting the returns in
> the next line. I'd rather right align the numbers after the '>', but YMMV.

sure or somemthing like
	case 0xff..0x80:
		return 0;
	case 0x7F..0xC0:
		return 1;

anyway, the above is okay and something we can argue with but if it is more
than a "look-up table" then we should break the line.






More information about the OpenBSC mailing list