lib: sbi: fix ctz bug
PATCH 1/1 lib: sbi: fix ctz bug
The original version of ctz will cause an endless loop, if the parameter passed in is 0. This commit fixes this bug.
--- lib/sbi/riscv_asm.c | 3 +++ 1 file changed, 3 insertions(+)
lib/sbi/riscv_asm.c +3 -0
@@ -213,6 +213,9 @@ static unsigned long ctz(unsigned long x) {unsigned long ret =0 ; +if (x ==0 ) +return 8 *sizeof (x); +while (!(x &1UL )) { ret++; x = x >>1 ;
Signature · 1 line
2.30.2
PATCH 1/1 lib: sbi: fix ctz bug
Quoted 14 lines · Xiang W
The original version of ctz will cause an endless loop, if the parameter passed in is 0. This commit fixes this bug.
Signed-off-by Xiang W <[email protected]>--- lib/sbi/riscv_asm.c | 3 +++ 1 file changed, 3 insertions(+)lib/sbi/riscv_asm.c +0
-0
lib/sbi/riscv_asm.c static unsigned long ctz(unsigned long x) · line 221
Quoted 9 lines
lib/sbi/riscv_asm.c +3
-0@@ -213,6 +213,9 @@ static unsigned long ctz(unsigned long x) {unsigned long ret =0 ; +if (x ==0 ) +return 8 *sizeof (x); +while (!(x &1UL )) { ret++; x = x >>1 ;
PATCH 1/1 lib: sbi: fix ctz bug
Quoted 19 lines · Bin Meng
Quoted 17 lines · Xiang W
The original version of ctz will cause an endless loop, if the parameter passed in is 0. This commit fixes this bug.
Signed-off-by Xiang W <[email protected]>--- lib/sbi/riscv_asm.c | 3 +++ 1 file changed, 3 insertions(+)lib/sbi/riscv_asm.c +0
-0@@ -213,6 +213,9 @@ static unsigned long ctz(unsigned long x) {unsigned long ret =0 ;
Quoted 8 lines
lib/sbi/riscv_asm.c static unsigned long ctz(unsigned long x) · line 221
Quoted 6 lines
lib/sbi/riscv_asm.c +3
-0+if (x ==0 ) +return 8 *sizeof (x); +while (!(x &1UL )) { ret++; x = x >>1 ;Reviewed-by Bin Meng <[email protected]>
Looks good to me.
Regards,
Anup
Quoted 5 lines
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
Anup Patel
AppliedPATCH 1/1 lib: sbi: fix ctz bug
Quoted 30 lines · Anup Patel
Quoted 19 lines · Bin Meng
Quoted 17 lines · Xiang W
The original version of ctz will cause an endless loop, if the parameter passed in is 0. This commit fixes this bug.
Signed-off-by Xiang W <[email protected]>--- lib/sbi/riscv_asm.c | 3 +++ 1 file changed, 3 insertions(+)lib/sbi/riscv_asm.c +0
-0@@ -213,6 +213,9 @@ static unsigned long ctz(unsigned long x) {unsigned long ret =0 ;Quoted 8 lines
lib/sbi/riscv_asm.c static unsigned long ctz(unsigned long x) · line 221
Quoted 6 lines
lib/sbi/riscv_asm.c +3
-0+if (x ==0 ) +return 8 *sizeof (x); +while (!(x &1UL )) { ret++; x = x >>1 ;Reviewed-by Bin Meng <[email protected]>
Quoted 3 lines
Looks good to me.
Reviewed-by Anup Patel <[email protected]>
Applied this to the riscv/opensbi repo as well.
Regards,
Anup
Quoted 9 lines
Regards,
AnupQuoted 5 lines
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi