lib: Cleanup bitfield to use unsigned values

Getting these messages:
./bgp_lu_topo2.test_bgp_lu2/R1/bgpd.err:bgpd/bgp_labelpool.c:310:3: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
./bgp_lu_topo2.test_bgp_lu2/R4/bgpd.err:bgpd/bgp_labelpool.c:310:3: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
./bgp_lu_topo2.test_bgp_lu2/R4/bgpd.err:bgpd/bgp_labelpool.c:497:5: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
./bgp_lu_topo2.test_bgp_lu2/R4/bgpd.err:bgpd/bgp_labelpool.c:499:5: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2024-05-23 06:55:42 -04:00
parent deb31c86e8
commit 99ffa9f6bf

View file

@ -83,11 +83,11 @@ DECLARE_MTYPE(BITFIELD);
* return an id to bitfield v
*/
#define bf_release_index(v, id) \
(v).data[bf_index(id)] &= ~(1 << (bf_offset(id)))
(v).data[bf_index(id)] &= ~(1U << (bf_offset(id)))
/* check if an id is in use */
#define bf_test_index(v, id) \
((v).data[bf_index(id)] & (1 << (bf_offset(id))))
((v).data[bf_index(id)] & (1U << (bf_offset(id))))
/* check if the bit field has been setup */
#define bf_is_inited(v) ((v).data)
@ -110,7 +110,7 @@ DECLARE_MTYPE(BITFIELD);
#define bf_set_bit(v, b) \
do { \
size_t w = bf_index(b); \
(v).data[w] |= 1 << (bf_offset(b)); \
(v).data[w] |= 1U << (bf_offset(b)); \
(v).n += ((v).data[w] == WORD_MAX); \
if ((v).n == (v).m) { \
(v).m = (v).m + 1; \