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

Måns Rullgård mans
Wed Nov 12 17:54:45 CET 2008


M?ns Rullg?rd wrote:
>
> 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?

There are several entries in gcc bugzilla for this and similar issues,
some of which have been fixed, others denied in usual fashion.

This one admits there's a problem, but reckons it's not that important:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32667

These are similar, but target more specific cases:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19410
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22237
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19419

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




More information about the ffmpeg-devel mailing list