[vlc-commits] var_GetAndSet() can fail
Rémi Denis-Courmont
git at videolan.org
Sun Oct 12 20:29:18 CEST 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Oct 12 21:28:49 2014 +0300| [748c53a3ca3faa45f000b6a62b9ace851b32f05e] | committer: Rémi Denis-Courmont
var_GetAndSet() can fail
Return 0 as usual, rather than undefined result.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=748c53a3ca3faa45f000b6a62b9ace851b32f05e
---
include/vlc_variables.h | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/include/vlc_variables.h b/include/vlc_variables.h
index 6f48aa1..8dba51b 100644
--- a/include/vlc_variables.h
+++ b/include/vlc_variables.h
@@ -428,7 +428,8 @@ static inline int64_t var_IncInteger( vlc_object_t *p_obj, const char *psz_name
{
vlc_value_t val;
val.i_int = 1;
- var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val );
+ if( var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val ) )
+ return 0;
return val.i_int;
}
#define var_IncInteger(a,b) var_IncInteger( VLC_OBJECT(a), b )
@@ -442,7 +443,8 @@ static inline int64_t var_DecInteger( vlc_object_t *p_obj, const char *psz_name
{
vlc_value_t val;
val.i_int = -1;
- var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val );
+ if( var_GetAndSet( p_obj, psz_name, VLC_VAR_INTEGER_ADD, &val ) )
+ return 0;
return val.i_int;
}
#define var_DecInteger(a,b) var_DecInteger( VLC_OBJECT(a), b )
@@ -452,7 +454,8 @@ static inline uint64_t var_OrInteger( vlc_object_t *obj, const char *name,
{
vlc_value_t val;
val.i_int = v;
- var_GetAndSet( obj, name, VLC_VAR_INTEGER_OR, &val );
+ if( var_GetAndSet( obj, name, VLC_VAR_INTEGER_OR, &val ) )
+ return 0;
return val.i_int;
}
#define var_OrInteger(a,b,c) var_OrInteger(VLC_OBJECT(a),b,c)
@@ -462,7 +465,8 @@ static inline uint64_t var_NAndInteger( vlc_object_t *obj, const char *name,
{
vlc_value_t val;
val.i_int = v;
- var_GetAndSet( obj, name, VLC_VAR_INTEGER_NAND, &val );
+ if( var_GetAndSet( obj, name, VLC_VAR_INTEGER_NAND, &val ) )
+ return 0;
return val.i_int;
}
#define var_NAndInteger(a,b,c) var_NAndInteger(VLC_OBJECT(a),b,c)
@@ -664,7 +668,8 @@ static inline int var_CountChoices( vlc_object_t *p_obj, const char *psz_name )
static inline bool var_ToggleBool( vlc_object_t *p_obj, const char *psz_name )
{
vlc_value_t val;
- var_GetAndSet( p_obj, psz_name, VLC_VAR_BOOL_TOGGLE, &val );
+ if( var_GetAndSet( p_obj, psz_name, VLC_VAR_BOOL_TOGGLE, &val ) )
+ return false;
return val.b_bool;
}
#define var_ToggleBool(a,b) var_ToggleBool( VLC_OBJECT(a),b )
More information about the vlc-commits
mailing list