Commit 5d9d305b authored by Nicolas Pitre's avatar Nicolas Pitre Committed by Russell King

[ARM PATCH] 1293/1: fix to the ARM optimized strchr()

Two bugs here:

1) The return value of strchr("foo",0) should be the start address of
   "foo" + 3, not NULL.

2) Since the second argument for strchr() is defined as an int, some
   characters such as 'é' might validly end up to be the value -23 due to
   signedness issues.  Corectly handle those.
parent 4c286c37
...@@ -15,11 +15,12 @@ ...@@ -15,11 +15,12 @@
.text .text
.align 5 .align 5
ENTRY(strchr) ENTRY(strchr)
and r1, r1, #0xff
1: ldrb r2, [r0], #1 1: ldrb r2, [r0], #1
teq r2, r1 teq r2, r1
teqne r2, #0 teqne r2, #0
bne 1b bne 1b
teq r2, #0 teq r2, r1
moveq r0, #0 movne r0, #0
subne r0, r0, #1 subeq r0, r0, #1
RETINSTR(mov,pc,lr) RETINSTR(mov,pc,lr)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment