From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2] memcpy/memmove: Do not copy to same address
Date: Mon, 23 May 2011 23:55:33 +0200 [thread overview]
Message-ID: <20110523215533.7B6FCCF5CA6@gemini.denx.de> (raw)
In-Reply-To: <4DDACC8B.6090507@ahsoftware.de>
Dear Alexander Holler,
In message <4DDACC8B.6090507@ahsoftware.de> you wrote:
>
> > --- a/lib/string.c
> > +++ b/lib/string.c
> > @@ -467,6 +467,9 @@ void * memcpy(void *dest, const void *src, size_t count)
> > unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src;
> > char *d8, *s8;
> >
> > + if (src == dest)
> > + return dest;
> > +
>
> here is the same, as in the patch I've commented before. There exist no
> reason to add a check for identity to memcpy() because memcpy doesn't
> support overlapping regions (and identity is just a special case of
> overlapping regions). If something might call memcpy() with overlapping
> or identical regions, it should use memmove().
In an ideal world, nobody will ever use any interfces in a
non-compliant or incorrect way.
In reality, all kind of errors happen. A little defensive programming
like the one above helps a lot, so please stop complaining even if you
think you don't need this.
Thanks.
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Mirrors should reflect a little before throwing back images.
- Jean Cocteau
next prev parent reply other threads:[~2011-05-23 21:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-12 6:58 [U-Boot] [PATCH] Do not copy to same address Matthias Weisser
2011-04-12 7:05 ` Mike Frysinger
2011-04-12 7:16 ` Matthias Weißer
2011-04-12 7:06 ` Albert ARIBAUD
2011-04-12 7:13 ` Matthias Weißer
2011-04-12 7:27 ` Albert ARIBAUD
2011-04-12 7:49 ` Matthias Weißer
2011-04-14 6:28 ` Albert ARIBAUD
2011-05-23 9:03 ` [U-Boot] [PATCH V2] memcpy/memmove: " Matthias Weisser
2011-05-23 21:07 ` Alexander Holler
2011-05-23 21:55 ` Wolfgang Denk [this message]
2011-05-23 22:12 ` Alexander Holler
2011-05-23 22:22 ` Wolfgang Denk
2011-05-23 22:38 ` Alexander Holler
2011-05-24 3:47 ` Mike Frysinger
2011-05-24 13:03 ` Alexander Holler
2011-05-24 19:37 ` Scott Wood
2011-05-24 20:39 ` Wolfgang Denk
2011-06-14 6:18 ` Matthias Weißer
2011-06-16 16:04 ` Matthias Weisser
2011-06-30 6:31 ` Matthias Weißer
2011-07-25 22:28 ` Wolfgang Denk
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=20110523215533.7B6FCCF5CA6@gemini.denx.de \
--to=wd@denx.de \
--cc=u-boot@lists.denx.de \
/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