This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
off-by-2 error in mips16 strlen
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: newlib at sources dot redhat dot com
- Date: 13 Mar 2002 23:40:20 -0300
- Subject: off-by-2 error in mips16 strlen
- Organization: GCC Team, Red Hat
This patch fixes a thinko (perhaps a typo) in the implementation of
strlen for mips16. I'm checking this in, approved by Jeff Johnston
and Mike Meissner.
Index: newlib/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* libc/machine/mips/strlen.c (strlen) [__mips16]: Fix off-by-two
error.
Index: newlib/libc/machine/mips/strlen.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/mips/strlen.c,v
retrieving revision 1.1
diff -u -p -r1.1 strlen.c
--- newlib/libc/machine/mips/strlen.c 2002/03/11 15:44:35 1.1
+++ newlib/libc/machine/mips/strlen.c 2002/03/14 00:22:10
@@ -2,7 +2,7 @@
* strlen.c -- strlen function. On at least some MIPS chips, a simple
* strlen is faster than the 'optimized' C version.
*
- * Copyright (c) 2001 Red Hat, Inc.
+ * Copyright (c) 2001, 2002 Red Hat, Inc.
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
@@ -29,7 +29,7 @@ strlen (const char *str)
while (*str++ != '\0')
;
- return str - start + 1;
+ return str - start - 1;
}
#elif defined(__mips64)
__asm__("" /* 64-bit MIPS targets */
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer