From: Nicolas Pitre <nico@cam.org>
To: lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] fix to strchr() in lib/string.c
Date: Sat, 21 Sep 2002 12:25:59 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.44.0209211209390.15918-100000@xanadu.home> (raw)
The return value of strchr("foo",0) should be the start address of
"foo" + 3, not NULL.
--- linux/lib/string.c Thu Aug 1 17:16:34 2002
+++ linux/lib/string.c Sat Sep 21 12:21:54 2002
@@ -190,10 +190,11 @@
*/
char * strchr(const char * s, int c)
{
- for(; *s != (char) c; ++s)
- if (*s == '\0')
- return NULL;
- return (char *) s;
+ do {
+ if (*s == (char) c)
+ return (char *) s;
+ } while (*s++);
+ return NULL;
}
#endif
next reply other threads:[~2002-09-21 16:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-21 16:25 Nicolas Pitre [this message]
2002-09-21 17:30 ` [PATCH] fix to strchr() in lib/string.c Dan Aloni
2002-09-21 19:28 ` Nicolas Pitre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.44.0209211209390.15918-100000@xanadu.home \
--to=nico@cam.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).