[vlc-devel] [PATCH 5/5] variables: warn when a variable is created twice in the same object

Steve Lhomme robux4 at ycbcr.xyz
Fri Mar 13 15:56:56 CET 2020


On 2020-03-13 15:33, Alexandre Janniaux wrote:
> Hi,
> 
> On Fri, Mar 13, 2020 at 03:00:32PM +0100, Steve Lhomme wrote:
>> Only in debug builds.
>>
>> Currently the command line options are created twice in libvlc.
>> ---
>>   src/misc/variables.c | 10 ++++++++++
>>   1 file changed, 10 insertions(+)
>>
>> diff --git a/src/misc/variables.c b/src/misc/variables.c
>> index ed284cf4f4c..acabc0ea59c 100644
>> --- a/src/misc/variables.c
>> +++ b/src/misc/variables.c
>> @@ -350,6 +350,16 @@ int (var_Create)( vlc_object_t *p_this, const char *psz_name, int i_type )
>>
>>       if (i_type & VLC_VAR_DOINHERIT)
>>           var_Inherit(p_this, psz_name, i_type, &p_var->val);
>> +#ifndef _NDEBUG
> 
> This should probably be NDEBUG according to git grep.

Indeed. Also it leaks if the type is a string. That can be fixed. As 
we're in variables.c we can call Lookup( p_this, psz_name ) directly.

> I'm not sure why you would do this only in debug, or even
> here, you want to remove duplicate var_Create?

The original intent was to assert. But given there's an issue (not 
easily fixed) in libvlc that would assert all the time.

That warning is useless for regular users, it's only useful when coding.

>> +    else
>> +    {
>> +        vlc_value_t val;
>> +        if (var_GetChecked( p_this, psz_name, i_type & VLC_VAR_CLASS, &val ) ==
>> +            VLC_SUCCESS)
>> +            msg_Warn( p_this, "variable '%s' already created in '%s'",
>> +                      psz_name, vlc_object_typename(p_this) );
>> +    }
>> +#endif
>>
>>       vlc_object_internals_t *p_priv = vlc_internals( p_this );
>>       void **pp_var;
>> --
>> 2.17.1
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> 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