Commit 8e9115f0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

variables: use assert() more consistently

parent a31f8ebb
...@@ -266,13 +266,11 @@ int var_Create( vlc_object_t *p_this, const char *psz_name, int i_type ) ...@@ -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->ops = &addr_ops;
p_var->val.p_address = NULL; p_var->val.p_address = NULL;
break; break;
default: case VLC_VAR_VOID:
p_var->ops = &void_ops; p_var->ops = &void_ops;
#ifndef NDEBUG break;
if( (i_type & VLC_VAR_CLASS) != VLC_VAR_VOID ) default:
msg_Err( p_this, "Creating the variable '%s' without a type", assert (0);
psz_name );
#endif
} }
if( i_type & VLC_VAR_DOINHERIT ) 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 ) ...@@ -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 ); pp_var = tsearch( p_var, &p_priv->var_root, varcmp );
if( unlikely(pp_var == NULL) ) if( unlikely(pp_var == NULL) )
ret = VLC_ENOMEM; ret = VLC_ENOMEM;
else if( (p_oldvar = *pp_var) == p_var ) else if( (p_oldvar = *pp_var) == p_var ) /* Variable create */
p_var = NULL; p_var = NULL; /* Variable created */
else if( unlikely((i_type ^ p_oldvar->i_type) & VLC_VAR_CLASS) ) else /* Variable already exists */
{ /* 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
{ {
assert (((i_type ^ p_oldvar->i_type) & VLC_VAR_CLASS) == 0);
p_oldvar->i_usage++; p_oldvar->i_usage++;
p_oldvar->i_type |= i_type & (VLC_VAR_ISCOMMAND|VLC_VAR_HASCHOICE); 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, ...@@ -733,12 +725,7 @@ int var_SetChecked( vlc_object_t *p_this, const char *psz_name,
assert( expected_type == 0 || assert( expected_type == 0 ||
(p_var->i_type & VLC_VAR_CLASS) == expected_type ); (p_var->i_type & VLC_VAR_CLASS) == expected_type );
#ifndef NDEBUG assert ((p_var->i_type & VLC_VAR_CLASS) != VLC_VAR_VOID);
/* 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
WaitUnused( p_this, p_var ); WaitUnused( p_this, p_var );
...@@ -795,16 +782,11 @@ int var_GetChecked( vlc_object_t *p_this, const char *psz_name, ...@@ -795,16 +782,11 @@ int var_GetChecked( vlc_object_t *p_this, const char *psz_name,
{ {
assert( expected_type == 0 || assert( expected_type == 0 ||
(p_var->i_type & VLC_VAR_CLASS) == expected_type ); (p_var->i_type & VLC_VAR_CLASS) == expected_type );
assert ((p_var->i_type & VLC_VAR_CLASS) != VLC_VAR_VOID);
/* Really get the variable */ /* Really get the variable */
*p_val = p_var->val; *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 */ /* Duplicate value if needed */
p_var->ops->pf_dup( p_val ); p_var->ops->pf_dup( p_val );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment