From: Andrew Morton <akpm@linux-foundation.org>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Grant Likely <grant.likely@linaro.org>,
Andi Kleen <ak@linux.intel.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib: string.c: Added a funktion function strzcpy
Date: Tue, 23 Sep 2014 15:40:46 -0700 [thread overview]
Message-ID: <20140923154046.1e57134bdb7e3143c0a5b6c9@linux-foundation.org> (raw)
In-Reply-To: <1411510416-16655-2-git-send-email-rickard_strandqvist@spectrumdigital.se>
On Wed, 24 Sep 2014 00:13:36 +0200 Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> wrote:
> +/**
> + * strzcpy - Copy a length-limited, C-string
> + * @dest: Where to copy the string to
> + * @src: Where to copy the string from
> + * @count: The maximum number of bytes to copy
> + *
> + * The result is %NUL-terminated,
> + * as long as count is greater than zero.
> + *
> + * In the case where the length of @src is less than that of
> + * count, the remainder of @dest will be padded with %NUL.
As far as I can tell, this sentence describes the only difference
between strzcpy() and strlcpy(). Only the sentence is wrong - the
implementation doesn't actually do that.
> + */
> +char *strzcpy(char *dest, const char *src, size_t count)
> +{
> + char *tmp = dest;
> +
> + while (count) {
> + if ((*tmp = *src) != 0)
> + src++;
> + tmp++;
> + count--;
> + }
> +
> + if (dest != tmp)
> + *--tmp = '\0';
> +
> + return dest;
> +}
> +EXPORT_SYMBOL(strzcpy);
next prev parent reply other threads:[~2014-09-23 22:40 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-23 22:13 Rickard Strandqvist
2014-09-23 22:13 ` Rickard Strandqvist
2014-09-23 22:40 ` Andrew Morton [this message]
2014-09-24 1:17 ` Andi Kleen
2014-09-24 7:52 ` Dan Carpenter
2014-09-24 14:14 ` Lennart Sorensen
2014-09-24 14:35 ` Andi Kleen
[not found] ` <CAFo99gZUfFUB9xX0GYW=hJMNouiU-M9apZ8KtPg9MW3x7gxZcg@mail.gmail.com>
2014-09-24 14:58 ` Andi Kleen
2014-09-24 15:41 ` Dan Carpenter
2014-09-24 20:51 ` Rickard Strandqvist
2014-09-24 21:26 ` Andrew Morton
2014-09-24 21:49 ` Rickard Strandqvist
2014-09-24 22:55 ` Andi Kleen
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=20140923154046.1e57134bdb7e3143c0a5b6c9@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=ak@linux.intel.com \
--cc=dan.carpenter@oracle.com \
--cc=grant.likely@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rickard_strandqvist@spectrumdigital.se \
/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
all inboxes | Powered by JetHome®