wrong decoding of bit vectors

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;

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

        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.



More information about the baseband-devel mailing list