[vlc-commits] variables: voidify callback deletion 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:26:34 2015 +0200| [d0a860da52adda89ee427269bf34df9c9e083f07] | committer: Rémi Denis-Courmont

variables: voidify callback deletion functions

If the callback does not exist, the program aborts anyway, so the
error value was mostly useless, and indeed always ignored.

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

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

diff --git a/include/vlc_variables.h b/include/vlc_variables.h
index 0a732f6..a7829b5 100644
--- a/include/vlc_variables.h
+++ b/include/vlc_variables.h
@@ -172,11 +172,11 @@ VLC_API void var_FreeList( vlc_value_t *, vlc_value_t * );
  *                 void *p_data);
  *****************************************************************************/
 VLC_API int var_AddCallback( vlc_object_t *, const char *, vlc_callback_t, void * );
-VLC_API int var_DelCallback( 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 int var_DelListCallback( 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 )
 #define var_DelCallback(a,b,c,d) var_DelCallback( VLC_OBJECT(a), b, c, d )
diff --git a/src/misc/variables.c b/src/misc/variables.c
index bc481ba..50d06e8 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -954,8 +954,8 @@ int var_AddCallback( vlc_object_t *p_this, const char *psz_name,
     return AddCallback(p_this, psz_name, entry, vlc_value_callback);
 }
 
-static int DelCallback( vlc_object_t *p_this, const char *psz_name,
-                        callback_entry_t entry, vlc_callback_type_t i_type )
+static void DelCallback( vlc_object_t *p_this, const char *psz_name,
+                         callback_entry_t entry, vlc_callback_type_t i_type )
 {
     int i_entry;
     variable_t *p_var;
@@ -971,7 +971,9 @@ static int DelCallback( vlc_object_t *p_this, const char *psz_name,
     if( p_var == NULL )
     {
         vlc_mutex_unlock( &p_priv->var_lock );
-        return VLC_ENOVAR;
+        msg_Err( p_this, "cannot delete callback %p from nonexistent "
+                 "variable '%s'", entry.p_callback, psz_name );
+        return;
     }
 
     WaitUnused( p_this, p_var );
@@ -1004,14 +1006,12 @@ static int DelCallback( vlc_object_t *p_this, const char *psz_name,
         vlc_assert_unreachable();
 #endif
         vlc_mutex_unlock( &p_priv->var_lock );
-        return VLC_EGENERIC;
+        return;
     }
 
     REMOVE_ELEM( p_table->p_entries, p_table->i_entries, i_entry );
 
     vlc_mutex_unlock( &p_priv->var_lock );
-
-    return VLC_SUCCESS;
 }
 
 #undef var_DelCallback
@@ -1021,14 +1021,14 @@ static int DelCallback( vlc_object_t *p_this, const char *psz_name,
  * pf_callback and p_data have to be given again, because different objects
  * might have registered the same callback function.
  */
-int var_DelCallback( vlc_object_t *p_this, const char *psz_name,
-                     vlc_callback_t pf_callback, void *p_data )
+void var_DelCallback( 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 DelCallback(p_this, psz_name, entry, vlc_value_callback);
+    DelCallback(p_this, psz_name, entry, vlc_value_callback);
 }
 
 #undef var_TriggerCallback
@@ -1078,14 +1078,14 @@ int var_AddListCallback( vlc_object_t *p_this, const char *psz_name,
  *
  * See var_DelCallback().
  */
-int var_DelListCallback( vlc_object_t *p_this, const char *psz_name,
-                         vlc_list_callback_t pf_callback, void *p_data )
+void var_DelListCallback( 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 DelCallback(p_this, psz_name, entry, vlc_list_callback);
+    DelCallback(p_this, psz_name, entry, vlc_list_callback);
 }
 
 /** Parse a stringified option



More information about the vlc-commits mailing list