[vlc-commits] variables: voidify callback addition functions

Rémi Denis-Courmont git at videolan.org
Sat Nov 28 11:51:06 CET 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Nov 28 12:32:11 2015 +0200| [0b5188ff963e59c5406187fab4c421a172ee87fe] | committer: Rémi Denis-Courmont

variables: voidify callback addition functions

In case of memory error, the functions will abort (table macros). Even
if it did not, callback deletion would later abort failing to find the
callback instead. (The API could be redesigned not to require memory
allocation if necessary.)

In case of nonexistent variable, log an error and fail safe as before.
This lead to deadlocks of misbehaviours as before - no changes here.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0b5188ff963e59c5406187fab4c421a172ee87fe
---

 include/vlc_variables.h |    4 ++--
 src/misc/variables.c    |   18 ++++++++----------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/include/vlc_variables.h b/include/vlc_variables.h
index a7829b5..77b4682 100644
--- a/include/vlc_variables.h
+++ b/include/vlc_variables.h
@@ -171,11 +171,11 @@ VLC_API void var_FreeList( vlc_value_t *, vlc_value_t * );
  *                 vlc_value_t newvalue,
  *                 void *p_data);
  *****************************************************************************/
-VLC_API int var_AddCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
+VLC_API void var_AddCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
 VLC_API void var_DelCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
 VLC_API void var_TriggerCallback( vlc_object_t *, const char * );
 
-VLC_API int var_AddListCallback( vlc_object_t *, const char *, vlc_list_callback_t, void * );
+VLC_API void var_AddListCallback( vlc_object_t *, const char *, vlc_list_callback_t, void * );
 VLC_API void var_DelListCallback( vlc_object_t *, const char *, vlc_list_callback_t, void * );
 
 #define var_AddCallback(a,b,c,d) var_AddCallback( VLC_OBJECT(a), b, c, d )
diff --git a/src/misc/variables.c b/src/misc/variables.c
index 50d06e8..b500ec4 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -892,7 +892,7 @@ int var_Get( vlc_object_t *p_this, const char *psz_name, vlc_value_t *p_val )
     return var_GetChecked( p_this, psz_name, 0, p_val );
 }
 
-static int AddCallback( vlc_object_t *p_this, const char *psz_name,
+static void AddCallback( vlc_object_t *p_this, const char *psz_name,
                         callback_entry_t entry, vlc_callback_type_t i_type )
 {
     variable_t *p_var;
@@ -907,7 +907,7 @@ static int AddCallback( vlc_object_t *p_this, const char *psz_name,
         vlc_mutex_unlock( &p_priv->var_lock );
         msg_Err( p_this, "cannot add callback %p to nonexistent variable '%s'",
                  entry.p_callback, psz_name );
-        return VLC_ENOVAR;
+        return;
     }
 
     WaitUnused( p_this, p_var );
@@ -923,8 +923,6 @@ static int AddCallback( vlc_object_t *p_this, const char *psz_name,
                  entry);
 
     vlc_mutex_unlock( &p_priv->var_lock );
-
-    return VLC_SUCCESS;
 }
 
 #undef var_AddCallback
@@ -944,14 +942,14 @@ static int AddCallback( vlc_object_t *p_this, const char *psz_name,
  *          the variable. Use proper locking. This thread may not have much
  *          time to spare, so keep callback functions short.
  */
-int var_AddCallback( vlc_object_t *p_this, const char *psz_name,
-                     vlc_callback_t pf_callback, void *p_data )
+void var_AddCallback( vlc_object_t *p_this, const char *psz_name,
+                      vlc_callback_t pf_callback, void *p_data )
 {
     callback_entry_t entry;
     entry.pf_value_callback = pf_callback;
     entry.p_data = p_data;
 
-    return AddCallback(p_this, psz_name, entry, vlc_value_callback);
+    AddCallback(p_this, psz_name, entry, vlc_value_callback);
 }
 
 static void DelCallback( vlc_object_t *p_this, const char *psz_name,
@@ -1062,14 +1060,14 @@ void var_TriggerCallback( vlc_object_t *p_this, const char *psz_name )
  *
  * See var_AddCallback().
  */
-int var_AddListCallback( vlc_object_t *p_this, const char *psz_name,
-                         vlc_list_callback_t pf_callback, void *p_data )
+void var_AddListCallback( vlc_object_t *p_this, const char *psz_name,
+                          vlc_list_callback_t pf_callback, void *p_data )
 {
     callback_entry_t entry;
     entry.pf_list_callback = pf_callback;
     entry.p_data = p_data;
 
-    return AddCallback(p_this, psz_name, entry, vlc_list_callback);
+    AddCallback(p_this, psz_name, entry, vlc_list_callback);
 }
 
 #undef var_DelListCallback



More information about the vlc-commits mailing list