mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] remove redundant condition in memccpy
Date: Fri, 20 Mar 2020 15:46:30 -0400	[thread overview]
Message-ID: <20200320194630.GE11469@brightrain.aerifal.cx> (raw)
In-Reply-To: <20200309183216.31559-1-amonakov@ispras.ru>

On Mon, Mar 09, 2020 at 09:32:16PM +0300, Alexander Monakov wrote:
> 
> Commit d9bdfd164 ("fix memccpy to not access buffer past given size")
> correctly added a check for 'n' nonzero, but made the pre-existing test
> '*s==c' redundant: n!=0 implies *s==c. Remove the unnecessary check.
> 
> Reported by Alexey Izbyshev.
> ---
> 
> Let me also point out that the aforementioned change did not appear
> on this mailing list.
> 
> Alexander
> 
>  src/string/memccpy.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

> diff --git a/src/string/memccpy.c b/src/string/memccpy.c
> index 00c18e2b..3b0a3700 100644
> --- a/src/string/memccpy.c
> +++ b/src/string/memccpy.c
> @@ -29,6 +29,6 @@ void *memccpy(void *restrict dest, const void *restrict src, int c, size_t n)
>  #endif
>  	for (; n && (*d=*s)!=c; n--, s++, d++);
>  tail:
> -	if (n && *s==c) return d+1;
> +	if (n) return d+1;
>  	return 0;
>  }


Thanks, applying.

Rich

      reply	other threads:[~2020-03-20 19:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09 18:32 Alexander Monakov
2020-03-20 19:46 ` Rich Felker [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=20200320194630.GE11469@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).