From: Jerry Van Baren <gvb.uboot@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot-Users] [PATCH 02/17] examples/eepro100_eeprom: Fix memcpy to return destination pointer
Date: Sun, 18 May 2008 22:38:33 -0400 [thread overview]
Message-ID: <4830E829.7020100@gmail.com> (raw)
In-Reply-To: <20080519012211.GD19480@game.jcrosoft.org>
Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 01:03 Mon 19 May , Wolfgang Denk wrote:
>> In message <20080518222019.GC19480@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.
YES! YES! YES! This gets my vote. I marked the start of this thread
meaning to suggest using temp variables of the right type and get rid of
the complex casting crap, exactly what you did here.
Thanks,
gvb
next prev parent reply other threads:[~2008-05-19 2:38 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-18 17:09 [U-Boot-Users] [PATCH 00/17] x86: Fix warning: type qualifiers ignored on function return type Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 01/17] example/82559_eeprom: Fix multiple warnings and errors Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 02/17] examples/eepro100_eeprom: Fix memcpy to return destination pointer Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 03/17] example/gitignore: update with all generated examples Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 04/17] i386: Fix global_data declaration Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 05/17] i386/bootm: remove unused var Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 06/17] ds1722: Fix mutliple warnings and errors and active the ssi for SC520 boards Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 07/17] drivers/pcmcia: add missing i82365 Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 08/17] marabun_pcmcia: Move compile condition to the Makefile Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 09/17] pxa_pcmcia: " Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 10/17] pcmcia/ti_pci1410a: " Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 11/17] Include pcmcia.h only when the drivers is used Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 12/17] ti_pci1410a: Fix multiple warnings and errors Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 13/17] sc520_spunk: Fix multiple warnings Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 14/17] sc520_spunk: Fix flash Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 15/17] sc530_spunk: add missing SOBJS entry Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 16/17] i386: Fix multipple definition of __show_boot_progress Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 17:09 ` [U-Boot-Users] [PATCH 17/17] sc520_cdp: Fix multiple warnings Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 23:00 ` Wolfgang Denk
2008-05-18 22:59 ` [U-Boot-Users] [PATCH 16/17] i386: Fix multipple definition of __show_boot_progress Wolfgang Denk
2008-05-18 22:57 ` [U-Boot-Users] [PATCH 15/17] sc530_spunk: add missing SOBJS entry Wolfgang Denk
2008-05-18 22:57 ` [U-Boot-Users] [PATCH 14/17] sc520_spunk: Fix flash Wolfgang Denk
2008-05-18 22:55 ` [U-Boot-Users] [PATCH 13/17] sc520_spunk: Fix multiple warnings Wolfgang Denk
2008-05-18 22:51 ` [U-Boot-Users] [PATCH 12/17] ti_pci1410a: Fix multiple warnings and errors Wolfgang Denk
2008-05-18 22:44 ` [U-Boot-Users] [PATCH 11/17] Include pcmcia.h only when the drivers is used Wolfgang Denk
2008-07-05 22:32 ` [U-Boot-Users] [PATCH 10/17] pcmcia/ti_pci1410a: Move compile condition to the Makefile Wolfgang Denk
2008-07-05 22:32 ` [U-Boot-Users] [PATCH 09/17] pxa_pcmcia: " Wolfgang Denk
2008-05-18 23:04 ` [U-Boot-Users] [PATCH 08/17] marabun_pcmcia: " Wolfgang Denk
2008-07-05 22:32 ` Wolfgang Denk
2008-05-18 22:40 ` [U-Boot-Users] [PATCH 07/17] drivers/pcmcia: add missing i82365 Wolfgang Denk
2008-05-18 22:39 ` [U-Boot-Users] [PATCH 06/17] ds1722: Fix mutliple warnings and errors and active the ssi for SC520 boards Wolfgang Denk
2008-05-18 22:37 ` [U-Boot-Users] [PATCH 05/17] i386/bootm: remove unused var Wolfgang Denk
2008-05-18 22:36 ` [U-Boot-Users] [PATCH 04/17] i386: Fix global_data declaration Wolfgang Denk
2008-05-18 22:30 ` [U-Boot-Users] [PATCH 03/17] example/gitignore: update with all generated examples Wolfgang Denk
2008-05-18 22:28 ` [U-Boot-Users] [PATCH 02/17] examples/eepro100_eeprom: Fix memcpy to return destination pointer Wolfgang Denk
2008-05-18 22:20 ` Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 23:03 ` Wolfgang Denk
2008-05-19 1:22 ` Jean-Christophe PLAGNIOL-VILLARD
2008-05-19 2:38 ` Jerry Van Baren [this message]
2008-05-19 7:51 ` Markus Klotzbücher
2008-05-18 22:21 ` [U-Boot-Users] [PATCH 01/17] example/82559_eeprom: Fix multiple warnings and errors Wolfgang Denk
2008-05-18 22:18 ` [U-Boot-Users] [PATCH 00/17] x86: Fix warning: type qualifiers ignored on function return type Wolfgang Denk
2008-05-18 22:10 ` Jean-Christophe PLAGNIOL-VILLARD
2008-05-18 23:01 ` 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=4830E829.7020100@gmail.com \
--to=gvb.uboot@gmail.com \
--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