login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2010
»
January
»
16
Re: [PATCH 4/7] lib: Introduce strnstr()
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Alex Riesen
Subject:
Re: [PATCH 4/7] lib: Introduce strnstr()
Date: Saturday, January 16, 2010 - 4:12 am
On Thu, Jan 14, 2010 at 03:53, Li Zefan <lizf@cn.fujitsu.com> wrote:
quoted text
> @@ -667,7 +667,7 @@ EXPORT_SYMBOL(memscan); > */ > char *strstr(const char *s1, const char *s2) > { > - int l1, l2; > + size_t l1, l2; >
This chunk is not related, is it?
quoted text
> @@ -684,6 +684,31 @@ char *strstr(const char *s1, const char *s2) > EXPORT_SYMBOL(strstr); > #endif > > +#ifndef __HAVE_ARCH_STRNSTR > +/** > + * strnstr - Find the first substring in a length-limited string > + * @s1: The string to be searched > + * @s2: The string to search for > + * @len: the maximum number of characters to search > + */ > +char *strnstr(const char *s1, const char *s2, size_t len) > +{ > + size_t l1 = len, l2;
Are you sure you want to search _past_ the NUL-terminator of s1?
quoted text
> + l2 = strlen(s2); > + if (!l2) > + return (char *)s1; > + while (l1 >= l2) { > + l1--; > + if (!memcmp(s1, s2, l2)) > + return (char *)s1; > + s1++; > + } > + return NULL; > +}
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH 0/7][RESEND] tracing: Fix bugs in string filters.
, Li Zefan
, (Wed Jan 13, 7:52 pm)
[PATCH 1/7] ftrace: Fix MATCH_END_ONLY function filter
, Li Zefan
, (Wed Jan 13, 7:53 pm)
[PATCH 2/7] tracing/filters: Fix MATCH_FRONT_ONLY filter m ...
, Li Zefan
, (Wed Jan 13, 7:53 pm)
[PATCH 3/7] tracing/filters: Fix MATCH_END_ONLY filter mat ...
, Li Zefan
, (Wed Jan 13, 7:53 pm)
[PATCH 4/7] lib: Introduce strnstr()
, Li Zefan
, (Wed Jan 13, 7:53 pm)
[PATCH 5/7] tracing/filters: Fix MATCH_MIDDLE_ONLY filter ...
, Li Zefan
, (Wed Jan 13, 7:54 pm)
[PATCH 6/7] tracing/filters: Fix MATCH_END_ONLY filter mat ...
, Li Zefan
, (Wed Jan 13, 7:54 pm)
[PATCH 7/7] tracing/filters: Add comment for match callbacks
, Li Zefan
, (Wed Jan 13, 7:54 pm)
[tip:tracing/urgent] ftrace: Fix MATCH_END_ONLY function f ...
, tip-bot for Li Zefan
, (Sat Jan 16, 2:42 am)
[tip:tracing/urgent] tracing/filters: Fix MATCH_FRONT_ONLY ...
, tip-bot for Li Zefan
, (Sat Jan 16, 2:43 am)
[tip:tracing/urgent] tracing/filters: Fix MATCH_END_ONLY f ...
, tip-bot for Li Zefan
, (Sat Jan 16, 2:43 am)
[tip:tracing/urgent] lib: Introduce strnstr()
, tip-bot for Li Zefan
, (Sat Jan 16, 2:43 am)
[tip:tracing/urgent] tracing/filters: Fix MATCH_MIDDLE_ONL ...
, tip-bot for Li Zefan
, (Sat Jan 16, 2:43 am)
[tip:tracing/urgent] tracing/filters: Fix MATCH_FULL filte ...
, tip-bot for Li Zefan
, (Sat Jan 16, 2:44 am)
[tip:tracing/urgent] tracing/filters: Add comment for matc ...
, tip-bot for Li Zefan
, (Sat Jan 16, 2:44 am)
Re: [PATCH 4/7] lib: Introduce strnstr()
, Alex Riesen
, (Sat Jan 16, 4:12 am)
Re: [PATCH 4/7] lib: Introduce strnstr()
, Steven Rostedt
, (Mon Jan 18, 7:53 am)
Re: [PATCH 4/7] lib: Introduce strnstr()
, Alex Riesen
, (Mon Jan 18, 8:56 am)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Greg KH
Og dreams of kernels
Jens Axboe
[PATCH 31/33] Fusion: sg chaining support
Arnd Bergmann
Re: finding your own dead "CONFIG_" variables
Mark Brown
[PATCH 2/2] Subject: natsemi: Allow users to disable workaround for DspCfg reset
Tony Breeds
[LGUEST] Look in object dir for .config
git
:
Brian Downing
Re: Git in a Nutshell guide
John Benes
Re: master has some toys
Matthias Lederhofer
[PATCH 4/7] introduce GIT_WORK_TREE to specify the work tree
Alexander Sulfrian
[RFC/PATCH] RE: git calls SSH_ASKPASS even if DISPLAY is not set
Junio C Hamano
Re: Rss produced by git is not valid xml?
git-commits-head
:
Linux Kernel Mailing List
iSeries: fix section mismatch in iseries_veth
Linux Kernel Mailing List
ixbge: remove TX lock and redo TX accounting.
Linux Kernel Mailing List
ixgbe: fix several counter register errata
Linux Kernel Mailing List