X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmisc%2Fvariables.c;h=138b664f9f09cd9bcec97417a769cf2f25688383;hb=8e9115f03b5579bfd9dcfccf34300e006dcb283b;hp=c447949b997d0562a95364b813b83c5ebc1cfc97;hpb=a31f8ebb74ea9c7f9b2f9f078321c1c2d9d79925;p=vlc diff --git a/src/misc/variables.c b/src/misc/variables.c index c447949b99..138b664f9f 100644 --- a/src/misc/variables.c +++ b/src/misc/variables.c @@ -266,13 +266,11 @@ int var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) p_var->ops = &addr_ops; p_var->val.p_address = NULL; break; - default: + case VLC_VAR_VOID: p_var->ops = &void_ops; -#ifndef NDEBUG - if( (i_type & VLC_VAR_CLASS) != VLC_VAR_VOID ) - msg_Err( p_this, "Creating the variable '%s' without a type", - psz_name ); -#endif + break; + default: + assert (0); } if( i_type & VLC_VAR_DOINHERIT ) @@ -302,17 +300,11 @@ int var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) pp_var = tsearch( p_var, &p_priv->var_root, varcmp ); if( unlikely(pp_var == NULL) ) ret = VLC_ENOMEM; - else if( (p_oldvar = *pp_var) == p_var ) - p_var = NULL; - else if( unlikely((i_type ^ p_oldvar->i_type) & VLC_VAR_CLASS) ) - { /* If the types differ, variable creation failed. */ - msg_Err( p_this, "Variable '%s' (0x%04x) already exist " - "but with a different type (0x%04x)", - psz_name, p_oldvar->i_type, i_type ); - ret = VLC_EBADVAR; - } - else + else if( (p_oldvar = *pp_var) == p_var ) /* Variable create */ + p_var = NULL; /* Variable created */ + else /* Variable already exists */ { + assert (((i_type ^ p_oldvar->i_type) & VLC_VAR_CLASS) == 0); p_oldvar->i_usage++; p_oldvar->i_type |= i_type & (VLC_VAR_ISCOMMAND|VLC_VAR_HASCHOICE); } @@ -733,12 +725,7 @@ int var_SetChecked( vlc_object_t *p_this, const char *psz_name, assert( expected_type == 0 || (p_var->i_type & VLC_VAR_CLASS) == expected_type ); -#ifndef NDEBUG - /* Alert if the type is VLC_VAR_VOID */ - if( ( p_var->i_type & VLC_VAR_TYPE ) == VLC_VAR_VOID ) - msg_Warn( p_this, "Calling var_Set on the void variable '%s' (0x%04x)", psz_name, p_var->i_type ); -#endif - + assert ((p_var->i_type & VLC_VAR_CLASS) != VLC_VAR_VOID); WaitUnused( p_this, p_var ); @@ -795,16 +782,11 @@ int var_GetChecked( vlc_object_t *p_this, const char *psz_name, { assert( expected_type == 0 || (p_var->i_type & VLC_VAR_CLASS) == expected_type ); + assert ((p_var->i_type & VLC_VAR_CLASS) != VLC_VAR_VOID); /* Really get the variable */ *p_val = p_var->val; -#ifndef NDEBUG - /* Alert if the type is VLC_VAR_VOID */ - if( ( p_var->i_type & VLC_VAR_TYPE ) == VLC_VAR_VOID ) - msg_Warn( p_this, "Calling var_Get on the void variable '%s' (0x%04x)", psz_name, p_var->i_type ); -#endif - /* Duplicate value if needed */ p_var->ops->pf_dup( p_val ); }