[U-Boot] [PATCH] arm: lib: memcpy: Do not copy to same address
Alexander Holler
holler at ahsoftware.de
Mon May 23 12:01:05 CEST 2011
Hello,
Am 23.05.2011 11:49, schrieb Albert ARIBAUD:
>> The standard clearly say to both memory regions should not overlap when
>> memcpy() is used, so I would say this is the wrong place to fix that.
>
> I think the intent here is not to enforce the standard but to handle an
> actual, and degenerate, copy request in the most efficient manner, and
> in that respect, the patch does its job.
>
> Besides, if the patch was about enforcing the standard, then I would
> consider it highly more efficient to check the areas once in the memcpy
> function than duplicating this check before each call to the function,
> considering that the place where the copy happens is not necessarily the
> one where the source and destination were computed.
A fool proof solution would be to always use memmove() and get rid of
memcpy(). But checking for overlapped regions in memcpy() is imho the
wrong way. This just leads to more possible wrong code which uses
memcpy() when it should use memmove().
Regards,
Alexander
More information about the U-Boot
mailing list