bits: remove unnecessary xor

main
anna 3 years ago
parent 16a229c936
commit e561adbb6f
Signed by: fef
GPG Key ID: EC22E476DC2D3D84

@ -14,7 +14,7 @@ void bit_set_range(unsigned long *bitfield, usize first, usize count)
/* test if the entire bit range is contained within this longword */
if (bit + count < LONG_BIT) {
unsigned long low_mask = (1lu << bit) - 1; /* 0b000..011 */
unsigned long high_mask = ~0lu ^ ((1lu << (bit + count)) - 1); /* 0b110..000 */
unsigned long high_mask = ~( (1lu << (bit + count)) - 1 ); /* 0b110..000 */
*bitfield |= ~(low_mask | high_mask);
} else {
/* if the first bit isn't longword aligned, manually set the upper
@ -47,7 +47,7 @@ void bit_clr_range(unsigned long *bitfield, usize first, usize count)
if (bit + count < LONG_BIT) {
unsigned long low_mask = (1lu << bit) - 1;
unsigned long high_mask = ~0lu ^ ((1lu << (bit + count)) - 1);
unsigned long high_mask = ~( (1lu << (bit + count)) - 1 );
*bitfield &= low_mask | high_mask;
} else {
if (bit != 0) {

Loading…
Cancel
Save