wrong decoding of bit vectors

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

Andreas.Eversberg Andreas.Eversberg at versatel.de
Thu Oct 21 06:51:42 UTC 2010


/* check if the bit is L or H for a given position inside a bitvec */
enum bit_value bitvec_get_bit_pos_high(const struct bitvec *bv,
                                        unsigned int bitnr)
{
        unsigned int bytenum = bytenum_from_bitnum(bitnr);
        unsigned int bitnum = 7 - (bitnr % 8);
        uint8_t bitval;
 
        if (bytenum >= bv->data_len)
                return -EINVAL;
 
        bitval = bitval2mask(H, bitnum);
 
        if (bv->data[bytenum] & bitval)
                return H;
 
        return L;
}
 
hi,

this is part of bitvec.c of libosmocore. it returns if a given bit in
the vector is "high" or "low". the bitval that represents "high" depends
on the bit position. bitval2mask returns that. so we must check if the
bit in the vector equals the returned bitval. i suggest to fix it that
way:

        if (bv->data[bytenum] & (1 << bitnum) == bitval)
                return H;

any complains?

without it we cannot check the system information's rest octets. they
are essential for any multiband mobile.

regards,

andreas





More information about the baseband-devel mailing list