[vlc-devel] [vlc-commits] modules: Adjust integer limits

Filip Roséen filip at atch.se
Fri Oct 14 19:40:54 CEST 2016


Ops..

On 2016-10-14 19:39, Filip Roséen wrote:

> Hi again,
> 
> On 2016-10-14 19:26, Filip Roséen wrote:
> 
> > Another way of fixing the described issues is to only apply
> > `VLC_VAR_SETMINMAX` if the associated module configuration for int and
> > float variables, respectivally, differ from `[0,0]` and `[NaN,NaN]`.
> > 
> > That way we can set the default to the mentioned ranges (because it
> > certainly does not make sense to specify either `[0,0]` as range, or
> > `[NaN,NaN]`.
> > 
> > See attached patch.
> 
> I just realized that the check for `== 0` and `isnan` in
> `src/config/help.c` is redundant and can be dropped (given that
> `VLC_VAR_SETMINMAX` will not be invoked for such values).
> 
> If we agree that the patch (disregarding what is mentioned above) is a
> valid approach to the problem we are currently facing I'd be happy to
> supply a *clean-up* or a *fixed* patch.
> 
> Sorry about that; wrote the patch a little bit too fast.

Haha, and now I replied too fast - I assumed there wsa a path checking
whether `VLC_VAR_SETMINMAX` was applied to the variable or not (but
that is of course not the case).

The patch is fine as is.. maybe I should get some sleep.

> 
> > > 
> > > Regards,
> > > _______________________________________________
> > > vlc-devel mailing list
> > > To unsubscribe or modify your subscription options:
> > > https://mailman.videolan.org/listinfo/vlc-devel
> 
> > From 7b5bc6c2be7376b2b985c5b1b98308d12b4e820f Mon Sep 17 00:00:00 2001
> > From: =?UTF-8?q?Filip=20Ros=C3=A9en?= <filip at atch.se>
> > Date: Fri, 14 Oct 2016 19:00:48 +0200
> > Subject: [PATCH] config/{chain,cmdline} + module-conf: variable range fixes
> > 
> > These changes makes it so that we do not invoke VLC_VAR_SETMINMAX for
> > variables that has not received an explicit range by its associated
> > module configuration (if any).
> > 
> > ---
> >  src/config/chain.c   | 19 +++++++++++++------
> >  src/config/cmdline.c | 19 +++++++++++++------
> >  src/config/help.c    |  6 +++---
> >  src/modules/entry.c  | 10 +++++-----
> >  4 files changed, 34 insertions(+), 20 deletions(-)
> > 
> > diff --git a/src/config/chain.c b/src/config/chain.c
> > index 660ad8f..332e48d 100644
> > --- a/src/config/chain.c
> > +++ b/src/config/chain.c
> > @@ -35,6 +35,7 @@
> >  #include "libvlc.h"
> >  #include <vlc_charset.h>
> >  #include <vlc_plugin.h>
> > +#include <math.h>
> >  
> >  #include "vlc_interface.h"
> >  #include "configuration.h"
> > @@ -293,14 +294,20 @@ void config_ChainParse( vlc_object_t *p_this, const char *psz_prefix,
> >              switch( CONFIG_CLASS( p_conf->i_type ) )
> >              {
> >                  case CONFIG_ITEM_INTEGER:
> > -                    var_Change( p_this, name, VLC_VAR_SETMINMAX,
> > -                        &(vlc_value_t){ .i_int = p_conf->min.i },
> > -                        &(vlc_value_t){ .i_int = p_conf->max.i } );
> > +                    if( !( p_conf->min.i == 0 && p_conf->max.i == 0 ) )
> > +                    {
> > +                        var_Change( p_this, name, VLC_VAR_SETMINMAX,
> > +                            &(vlc_value_t){ .i_int = p_conf->min.i },
> > +                            &(vlc_value_t){ .i_int = p_conf->max.i } );
> > +                    }
> >                      break;
> >                  case CONFIG_ITEM_FLOAT:
> > -                    var_Change( p_this, name, VLC_VAR_SETMINMAX,
> > -                        &(vlc_value_t){ .f_float = p_conf->min.f },
> > -                        &(vlc_value_t){ .f_float = p_conf->max.f } );
> > +                    if( !( isnan( p_conf->min.f ) && isnan( p_conf->max.f ) ) )
> > +                    {
> > +                        var_Change( p_this, name, VLC_VAR_SETMINMAX,
> > +                            &(vlc_value_t){ .f_float = p_conf->min.f },
> > +                            &(vlc_value_t){ .f_float = p_conf->max.f } );
> > +                    }
> >                      break;
> >              }
> >          }
> > diff --git a/src/config/cmdline.c b/src/config/cmdline.c
> > index 5f1e390..98d7947 100644
> > --- a/src/config/cmdline.c
> > +++ b/src/config/cmdline.c
> > @@ -38,6 +38,7 @@
> >  #include "modules/modules.h"
> >  
> >  #include <assert.h>
> > +#include <math.h>
> >  
> >  #undef config_LoadCmdLine
> >  /**
> > @@ -239,17 +240,23 @@ int config_LoadCmdLine( vlc_object_t *p_this, int i_argc,
> >                          break;
> >                      case CONFIG_ITEM_INTEGER:
> >                          var_Create( p_this, psz_name, VLC_VAR_INTEGER );
> > -                        var_Change( p_this, psz_name, VLC_VAR_SETMINMAX,
> > -                            &(vlc_value_t){ .i_int = p_conf->min.i },
> > -                            &(vlc_value_t){ .i_int = p_conf->max.i } );
> > +                        if( !( p_conf->min.i == 0 && p_conf->max.i == 0 ) )
> > +                        {
> > +                            var_Change( p_this, psz_name, VLC_VAR_SETMINMAX,
> > +                                &(vlc_value_t){ .i_int = p_conf->min.i },
> > +                                &(vlc_value_t){ .i_int = p_conf->max.i } );
> > +                        }
> >                          var_SetInteger( p_this, psz_name,
> >                                          strtoll(state.arg, NULL, 0));
> >                          break;
> >                      case CONFIG_ITEM_FLOAT:
> >                          var_Create( p_this, psz_name, VLC_VAR_FLOAT );
> > -                        var_Change( p_this, psz_name, VLC_VAR_SETMINMAX,
> > -                            &(vlc_value_t){ .f_float = p_conf->min.f },
> > -                            &(vlc_value_t){ .f_float = p_conf->max.f } );
> > +                        if( !( isnan( p_conf->min.f ) && !isnan( p_conf->max.f ) ) )
> > +                        {
> > +                            var_Change( p_this, psz_name, VLC_VAR_SETMINMAX,
> > +                                &(vlc_value_t){ .f_float = p_conf->min.f },
> > +                                &(vlc_value_t){ .f_float = p_conf->max.f } );
> > +                        }
> >                          var_SetFloat( p_this, psz_name, us_atof(state.arg) );
> >                          break;
> >                      case CONFIG_ITEM_BOOL:
> > diff --git a/src/config/help.c b/src/config/help.c
> > index 16afba3..8e7afe4 100644
> > --- a/src/config/help.c
> > +++ b/src/config/help.c
> > @@ -28,7 +28,7 @@
> >  #include <wchar.h>
> >  #include <wctype.h>
> >  #include <limits.h>
> > -#include <float.h>
> > +#include <math.h>
> >  
> >  #include <vlc_common.h>
> >  #include <vlc_modules.h>
> > @@ -434,7 +434,7 @@ static void print_item(const module_t *m, const module_config_t *item,
> >                              module_gettext(m, item->list_text[i]));
> >                  }
> >              }
> > -            else if (item->min.i != INT_MIN || item->max.i != INT_MAX)
> > +            else if (!(item->min.i == 0 && item->max.i == 0))
> >              {
> >                  if (asprintf(&typebuf, "%s [%"PRId64" .. %"PRId64"]",
> >                               type, item->min.i, item->max.i) >= 0)
> > @@ -446,7 +446,7 @@ static void print_item(const module_t *m, const module_config_t *item,
> >  
> >          case CONFIG_ITEM_FLOAT:
> >              type = _("float");
> > -            if (item->min.f != FLT_MIN || item->max.f != FLT_MAX)
> > +            if (!(isnan(item->min.f) && isnan(item->max.f)))
> >              {
> >                  if (asprintf(&typebuf, "%s [%f .. %f]", type,
> >                               item->min.f, item->max.f) >= 0)
> > diff --git a/src/modules/entry.c b/src/modules/entry.c
> > index 7698499..a1cfc6c 100644
> > --- a/src/modules/entry.c
> > +++ b/src/modules/entry.c
> > @@ -29,7 +29,7 @@
> >  #include <assert.h>
> >  #include <stdarg.h>
> >  #include <limits.h>
> > -#include <float.h>
> > +#include <math.h>
> >  
> >  #include "modules/modules.h"
> >  #include "config/configuration.h"
> > @@ -129,13 +129,13 @@ static module_config_t *vlc_config_create (module_t *module, int type)
> >      memset (tab + confsize, 0, sizeof (tab[confsize]));
> >      if (IsConfigIntegerType (type))
> >      {
> > -        tab[confsize].max.i = INT64_MAX;
> > -        tab[confsize].min.i = INT64_MIN;
> > +        tab[confsize].max.i = 0;
> > +        tab[confsize].min.i = 0;
> >      }
> >      else if( IsConfigFloatType (type))
> >      {
> > -        tab[confsize].max.f = FLT_MAX;
> > -        tab[confsize].min.f = FLT_MIN;
> > +        tab[confsize].max.f = NAN;
> > +        tab[confsize].min.f = NAN;
> >      }
> >      tab[confsize].i_type = type;
> >  
> > -- 
> > 2.10.0
> > 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20161014/74a17b6d/attachment.html>


More information about the vlc-devel mailing list