[vlc-devel] [PATCH 5/5] variables: warn when a variable is created twice in the same object

Steve Lhomme robux4 at ycbcr.xyz
Fri Mar 13 15:00:32 CET 2020


Only in debug builds.

Currently the command line options are created twice in libvlc.
---
 src/misc/variables.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/misc/variables.c b/src/misc/variables.c
index ed284cf4f4c..acabc0ea59c 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -350,6 +350,16 @@ int (var_Create)( vlc_object_t *p_this, const char *psz_name, int i_type )
 
     if (i_type & VLC_VAR_DOINHERIT)
         var_Inherit(p_this, psz_name, i_type, &p_var->val);
+#ifndef _NDEBUG
+    else
+    {
+        vlc_value_t val;
+        if (var_GetChecked( p_this, psz_name, i_type & VLC_VAR_CLASS, &val ) ==
+            VLC_SUCCESS)
+            msg_Warn( p_this, "variable '%s' already created in '%s'",
+                      psz_name, vlc_object_typename(p_this) );
+    }
+#endif
 
     vlc_object_internals_t *p_priv = vlc_internals( p_this );
     void **pp_var;
-- 
2.17.1



More information about the vlc-devel mailing list