[U-Boot-Users] [PATCH 02/17] examples/eepro100_eeprom: Fix memcpy to return destination pointer
Jean-Christophe PLAGNIOL-VILLARD
plagnioj at jcrosoft.com
Mon May 19 03:22:11 CEST 2008
On 01:03 Mon 19 May , Wolfgang Denk wrote:
> In message <20080518222019.GC19480 at game.jcrosoft.org> you wrote:
> >
> > > > static inline void *memcpy(void *dst, const void *src, unsigned int len)
> > > > {
> > > > char *ret = dst;
> > > > +
> > > > while (len-- > 0) {
> > > > *ret++ = *((char *)src);
> > > > src++;
> > > > }
> > > > - return (void *)ret;
> > > > +
> > > > + return (void *)dst;
> > >
> > > While technically correct, this is bogus. We have a variable ret, but
> > > we don't return it. And we have a variable dst, but we don't use it as
> > > destination pointer.
> > >
> > > Please change the
> > > *ret++ = *((char *)src);
> > > into
> > > *dst++ = *((char *)src);
> > > and leave all the rest.
> > You can not do this because dst is a void
>
> Why not? src is void, too.
gcc will claim about the cast.
we can do this
void *ret = dst;
char *d = dst;
const char *s = src;
while (len-- > 0)
*d++ = *s++;
return ret;
Best Regards,
J.
More information about the U-Boot
mailing list