[vlc-devel] [PATCH] Fixed warnings on missed struct fields initializers
Rémi Denis-Courmont
remi at remlab.net
Mon Dec 2 13:11:38 CET 2013
On Mon, 02 Dec 2013 13:07:10 +0100, Francois Cartegnie <fcvlcdev at free.fr>
wrote:
> Le 02/12/2013 12:55, Maxim Bublis a écrit :
>> - AVPacket packet = {0};
>> + AVPacket packet;
>
>> - { {0}, { 0, { 0 }, 0, 0 } }
>> + { {0}, { 0, { { {0, 0}, {0, 0} } }, 0, 0 } }
>
> This warning is a gcc bug, fixed in recent versions.
Hmm? Whether the warning is a bug or a feature depends on the case, much
like the infamous "maybe uninitialized" warning. I think GCC zeroes the
missing members anyway.
> Setting it to 0 should initialize the whole struct to 0.
I do not currently believe that 0 would be a syntactically valid structure
or union initializer. (And even if it were, it would be very ugly.)
Nevertheless, I fear that the layout of AVPacket will vary with libavutil
versions, so I agree that omitting initializers may be The Right Thing. By
the way, the GCC warning can be avoided by using designated initializers.
--
Rémi Denis-Courmont
Sent from my collocated server
More information about the vlc-devel
mailing list