From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Xiang Xiao <xiaoxiang781216@gmail.com>
Cc: rdunlap@infradead.org, gregkh@linuxfoundation.org,
alexander.shishkin@linux.intel.com, ohad@wizery.com,
bjorn.andersson@linaro.org, wendy.liang@xilinx.com,
arnaud.pouliquen@st.com, kumar.gala@linaro.org,
linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
Xiang Xiao <xiaoxiang@xiaomi.com>
Subject: Re: [PATCH V2 1/2] lib/string: add memrchr function
Date: Thu, 14 Feb 2019 14:53:47 +0200 [thread overview]
Message-ID: <20190214125347.GU9224@smile.fi.intel.com> (raw)
In-Reply-To: <1550124158-1111-1-git-send-email-xiaoxiang@xiaomi.com>
On Thu, Feb 14, 2019 at 02:02:37PM +0800, Xiang Xiao wrote:
> Here is the detailed description for memrchr:
>
> void *memrchr(const void *s, int c, size_t n);
>
> The memrchr() function is like the memchr() function, except
> that it searches backward from the end of the n bytes pointed
> to by s instead of forward from the beginning.
>
> The memrchr() functions return a pointer to the matching byte
> or NULL if the character does not occur in the given memory
> area.
> +void *memrchr(const void *s, int c, size_t n)
> +{
> + const unsigned char *p = s + n;
> +
> + while (n-- != 0) {
Simple:
while (n--) {
> + if ((unsigned char)c == *--p)
> + return (void *)p;
> + }
> + return NULL;
> +}
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2019-02-14 12:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-14 6:02 [PATCH V2 1/2] lib/string: add memrchr function Xiang Xiao
2019-02-14 6:02 ` [PATCH V2 2/2] rpmsg: add syslog redirection driver Xiang Xiao
2019-02-14 13:09 ` Andy Shevchenko
2019-02-14 13:11 ` Andy Shevchenko
2019-02-14 16:31 ` xiang xiao
2019-02-15 15:06 ` Andy Shevchenko
2019-02-16 16:52 ` xiang xiao
2019-02-14 12:53 ` Andy Shevchenko [this message]
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=20190214125347.GU9224@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=arnaud.pouliquen@st.com \
--cc=bjorn.andersson@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=kumar.gala@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=ohad@wizery.com \
--cc=rdunlap@infradead.org \
--cc=wendy.liang@xilinx.com \
--cc=xiaoxiang781216@gmail.com \
--cc=xiaoxiang@xiaomi.com \
/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