[vlc-commits] Return an error with VLC_VAR_GET(MIN|MAX|STEP) of there is no value

Rémi Denis-Courmont git at videolan.org
Sat Oct 1 21:33:50 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct  1 22:06:17 2011 +0300| [de56648c5b0273c7737dafaa262bce761b7346a2] | committer: Rémi Denis-Courmont

Return an error with VLC_VAR_GET(MIN|MAX|STEP) of there is no value

Otherwise, the caller cannot determine that the value is not defined,
such that the vlc_value_t is not set and cannot be used.

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

 src/misc/variables.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/misc/variables.c b/src/misc/variables.c
index e3d480e..5ad8430 100644
--- a/src/misc/variables.c
+++ b/src/misc/variables.c
@@ -391,6 +391,7 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
                 int i_action, vlc_value_t *p_val, vlc_value_t *p_val2 )
 {
     int i;
+    int ret = VLC_SUCCESS;
     variable_t *p_var;
     vlc_value_t oldval;
     vlc_value_t newval;
@@ -422,9 +423,9 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
             break;
         case VLC_VAR_GETMIN:
             if( p_var->i_type & VLC_VAR_HASMIN )
-            {
                 *p_val = p_var->min;
-            }
+            else
+                ret = VLC_EGENERIC;
             break;
         case VLC_VAR_SETMAX:
             if( p_var->i_type & VLC_VAR_HASMAX )
@@ -438,9 +439,9 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
             break;
         case VLC_VAR_GETMAX:
             if( p_var->i_type & VLC_VAR_HASMAX )
-            {
                 *p_val = p_var->max;
-            }
+            else
+                ret = VLC_EGENERIC;
             break;
         case VLC_VAR_SETSTEP:
             if( p_var->i_type & VLC_VAR_HASSTEP )
@@ -454,9 +455,9 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
             break;
         case VLC_VAR_GETSTEP:
             if( p_var->i_type & VLC_VAR_HASSTEP )
-            {
                 *p_val = p_var->step;
-            }
+            else
+                ret = VLC_EGENERIC;
             break;
         case VLC_VAR_ADDCHOICE:
             i = p_var->choices.i_count;
@@ -612,7 +613,7 @@ int var_Change( vlc_object_t *p_this, const char *psz_name,
 
     vlc_mutex_unlock( &p_priv->var_lock );
 
-    return VLC_SUCCESS;
+    return ret;
 }
 
 #undef var_GetAndSet



More information about the vlc-commits mailing list