[vlc-devel] [PATCH 1/3] fingerprinter: use partial/zero initialization

Alexandre Janniaux ajanni at videolabs.io
Sun Mar 22 17:18:18 CET 2020


On Sun, Mar 22, 2020 at 05:40:18PM +0200, Rémi Denis-Courmont wrote:
> Le sunnuntaina 22. maaliskuuta 2020, 17.21.20 EET Alexandre Janniaux a écrit :
> > Using memset to zero a struct with pointers is undefined behaviour
>
> AFAIK, no, that is not UB. Null pointer representation is implementation-
> defined, also colloqually known as not portable. The diff seems fine but the
> description is misleading.

Sure, I'll fix this.

>
> > and
> > less elegant than using partial initialization.
> > ---
> >  modules/misc/fingerprinter.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/modules/misc/fingerprinter.c b/modules/misc/fingerprinter.c
> > index c96c471eb3..7a6bfc847d 100644
> > --- a/modules/misc/fingerprinter.c
> > +++ b/modules/misc/fingerprinter.c
> > @@ -360,9 +360,8 @@ static void *Run( void *opaque )
> >              char *psz_uri = input_item_GetURI( p_data->p_item );
> >              if ( psz_uri != NULL )
> >              {
> > -                 acoustid_fingerprint_t acoustid_print;
> > +                 acoustid_fingerprint_t acoustid_print = {0};
> >
> > -                 memset( &acoustid_print , 0, sizeof (acoustid_print) );
> >                  /* overwrite with hint, as in this case, fingerprint's
> > session will be truncated */ if ( p_data->i_duration )
> >                       acoustid_print.i_duration = p_data->i_duration;
>
>
> --
> 雷米‧德尼-库尔蒙
> http://www.remlab.net/
>
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list