[vlc-devel] [vlc-commits] commit: stats: fix initialization on 32bits builds ( Rafaël Carré )
fenrir at elivagar.org
Tue Nov 2 10:50:42 CET 2010
On Tue, Nov 02, 2010 at 10:11:47AM +0100, Rafaël Carré wrote:
> On Tue, 2 Nov 2010 10:00:13 +0100
> Laurent Aimar <fenrir at elivagar.org> wrote:
> > yn Tue, Nov 02, 2010 at 07:16:03AM +0100, git at videolan.org wrote:
> > > vlc | branch: master | Rafaël Carré <rafael.carre at gmail.com> | Tue
> > > Nov 2 07:15:00 2010 +0100|
> > > [03c9cf61730535306dfb6d6b6b8ec473c8c7adb0] | committer: Rafaël
> > > Carré
> > >
> > > stats: fix initialization on 32bits builds
> > >
> > > using psz_string to initialize will leave the top 32bits
> > > uninitialized
> > > - p_new->value.psz_string = NULL;
> > > + p_new->value.i_int = 0;
> > Wouldn't memset(&p_new->value, 0, sizeof(p_new->value)) be safer
> > then?
> Yes but since i_int is 64 bits and is also the biggest element in the
> union, setting i_int will work fine until we add a >64bits element in
> the union.
That's the thing, the memset() doesn't suppose that everyone remembers
who did a supposition like that (and where).
But IMHO the issue is more related to the stat API. Initializing an union
like that is not quite right. It's just by chance that it happens that 0 is
the right value for all the fields of vlc_value_t...
More information about the vlc-devel