[FFmpeg-devel] [PATCH] utils.c: avoid FFSWAP of identical buffers

Måns Rullgård mans
Wed Nov 12 16:36:00 CET 2008


Jindrich Makovicka wrote:
> On Mon, Nov 10, 2008 at 15:31, M?ns Rullg?rd <mans at mansr.com> wrote:
>>
>> Jindrich Makovicka wrote:
>>> Hi,
>>>
>>> the attached patch skips doing FFSWAP() if the buffers are actually
>>> the same, to avoid useless copying and to suppress a "memcpy() with
>>> overlapping src and dest" warning in Valgrind.
>>
>> While avoiding useless copying is of course good, the cause of the valgrind
>> warning is a gcc bug.  Unless the compiler can prove that the source and
>> destination do not overlap, it must not issue a memcpy() call to effect a
>> struct assignment.  The C standard specifically allows assignment with
>> source equal to destination, whereas memcpy() does not.
>
> Right, I recall some flames about this here or on the MPlayer list.
>
> Do you find this change justifiable by the former reason?

Not really, since gcc should be doing that check.  Has this been reported
to gcc devs?

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list