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

Jacob Erlbeck jerlbeck at sysmocom.de
Tue Jan 26 11:17:46 UTC 2016


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.

Jacob


-- 
- Jacob Erlbeck <jerlbeck at sysmocom.de>       http://www.sysmocom.de/
=======================================================================
* sysmocom - systems for mobile communications GmbH
* Alt-Moabit 93
* 10559 Berlin, Germany
* Sitz / Registered office: Berlin, HRB 134158 B
* Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte



More information about the OpenBSC mailing list