shithub: riscv

Download patch

ref: 5494e2fa4ea1347b5676b25860d0abf2b850d524
parent: a15d6fcb8f44153e4a3054279935cb4b041373d1
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Feb 15 19:55:57 EST 2024

ext4srv: fix/simplify ext4_bmap_bits_free

--- a/sys/src/cmd/ext4srv/ext4_bitmap.c
+++ b/sys/src/cmd/ext4srv/ext4_bitmap.c
@@ -8,15 +8,10 @@
 {
 	u32int i = sbit;
 
-	while (i & 7) {
-
-		if (!bcnt)
+	while(i & 7){
+		if(bcnt-- == 0)
 			return;
-
-		ext4_bmap_bit_clr(bmap, i);
-
-		bcnt--;
-		i++;
+		ext4_bmap_bit_clr(bmap, i++);
 	}
 	sbit = i;
 	bmap += sbit >> 3;
@@ -23,10 +18,10 @@
 
 	memset(bmap, 0, bcnt >> 3);
 	bmap += bcnt >> 3;
+	bcnt &= 7;
 
-	for (i = 0; i < bcnt; ++i) {
-		ext4_bmap_bit_clr(bmap, i);
-	}
+	while(bcnt > 0)
+		ext4_bmap_bit_clr(bmap, --bcnt);
 }
 
 int ext4_bmap_bit_find_clr(u8int *bmap, u32int sbit, u32int ebit,