Module Name:    src
Committed By:   khorben
Date:           Mon Sep 22 20:31:56 UTC 2014

Modified Files:
        src/common/lib/libc/arch/i386/string/small: strchr.S

Log Message:
Look for the character to locate before checking for the NUL character

As documented in PR port-i386/49208, this fixes strchr(s, '\0'), as used by
the FAT first-stage bootloader on x86 (bootxx_msdos).
strchr(s, '\0') is otherwise equivalent to strlen(string), which would
probably look nicer in the original file, dosfs.c from libsa.

Confirmed working in qemu and on real hardware.
ok joerg@

XXX pull-up to netbsd-6 and netbsd-7


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/common/lib/libc/arch/i386/string/small/strchr.S

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libc/arch/i386/string/small/strchr.S
diff -u src/common/lib/libc/arch/i386/string/small/strchr.S:1.2 src/common/lib/libc/arch/i386/string/small/strchr.S:1.3
--- src/common/lib/libc/arch/i386/string/small/strchr.S:1.2	Sat Mar 22 19:38:46 2014
+++ src/common/lib/libc/arch/i386/string/small/strchr.S	Mon Sep 22 20:31:56 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: strchr.S,v 1.2 2014/03/22 19:38:46 jakllsch Exp $	*/
+/*	$NetBSD: strchr.S,v 1.3 2014/09/22 20:31:56 khorben Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <machine/asm.h>
-	RCSID("$NetBSD: strchr.S,v 1.2 2014/03/22 19:38:46 jakllsch Exp $")
+	RCSID("$NetBSD: strchr.S,v 1.3 2014/09/22 20:31:56 khorben Exp $")
 
 ENTRY(strchr)
 	popl	%edx		/* Return address */
@@ -39,10 +39,10 @@ ENTRY(strchr)
 	pushl	%eax
 	pushl	%edx
 1:
-	cmpb	$0, 0(%eax)
-	je 2f
 	cmpb	%cl, 0(%eax)
 	je 3f
+	cmpb	$0, 0(%eax)
+	je 2f
 	incl	%eax
 	jmp 1b
 2:

Reply via email to