RISC-V: fix strncmp for shorter 2nd strings

A patch from »RISC-V: fix strncmp for shorter 2nd strings« in state Obsolete for linux-kernel

From: Heiko Stuebner <heiko.stuebner@...> Date: Thu, 23 Feb 2023 12:04:19 +0100

Commit-Message

The strncmp implementation didn't handle the case correctly when the second string was a lot shorter than the first one, so the 0-byte detection didn't trigger for the 1st string. To fix this look for 0-bytes in each block of the second string as well and jump to the tail processing in that case, similar to how its done for the first string. Reported-by: Reported-by: Guenter Roeck <linux@...> Fixes: b6fcdb191e36 ("RISC-V: add zbb support to string functions") Signed-off-by: Heiko Stuebner <heiko.stuebner@...>

Patch-Comment

arch/riscv/lib/strncmp.S | 2 ++ 1 file changed, 2 insertions(+)

Statistics

  • 2 lines added
  • 0 lines removed

Changes

--------------------------- arch/riscv/lib/strncmp.S ---------------------------
index ee49595075be..e047a3ab8233 100644
@@ -83,6 +83,8 @@ strncmp_zbb:
REG_L t1, 0(a1)
orc.b t3, t0
bne t3, t5, 2f
+ orc.b t3, t1
+ bne t3, t5, 2f
addi a0, a0, SZREG
addi a1, a1, SZREG
beq t0, t1, 1b
 
 

Recent Patches

About Us

Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer.

Read More...