osmo-pcu[master]: TS alloc: use standard function

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

Max gerrit-no-reply at lists.osmocom.org
Mon Sep 11 12:05:30 UTC 2017


Patch Set 1:

I've tried to implement this comparison and got really weird results:
...
EC 111.11..: {5} 3 != 4 FAIL
ED 111.11.1: {6} 1 OK
EE 111.111.: {6} 2 OK
EF 111.1111: {7} 1 OK
F0 1111....: {4} 5 != 16 FAIL
F1 1111...1: {5} 1 OK
F2 1111..1.: {5} 2 OK
F3 1111..11: {6} 1 OK
...

This prints the number in question (0..0xFF), it's bit representation, number of bits set, ffs() and 'OK' or psu_lsb() value if differs.

It seems like ffs() does the right thing but psu_lsb() computes every 5th value wrong.

Here is the code:
	uint8_t u = 0, x;
	do {
		fprintf(stderr, "%2X " OSMO_BIT_SPEC ": {%d} %d ", u, OSMO_BIT_PRINT(u), pcu_bitcount(u), ffs(u));
		x = pcu_lsb(u);
		if (ffs(u) != x) {
			fprintf(stderr, "!= %d FAIL\n", x);
		} else
			fprintf(stderr, "OK\n");
		u++;
	} while (u);

I might be missing smth but home come lsb in a byte can be more than 8? Could it be that using negation on unsigned type somehow confused gcc? Or some sort of template optimization magic went wrong?

Anyway, I think it's yet another reason to replace it with standard function which behaves as expected.

-- 
To view, visit https://gerrit.osmocom.org/3896
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I2d14ef327b09173d56ee3bca7e3ca85897d381c7
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-HasComments: No



More information about the gerrit-log mailing list