From 92cd6dc3e916ae4275ff05d2b238fc778cfbfc6b Mon Sep 17 00:00:00 2001 From: reimar Date: Fri, 1 Jan 2010 13:23:16 +0000 Subject: Simplify range-checking functions for subopt parsing. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30165 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libao2/ao_alsa.c | 4 +--- libvo/vo_jpeg.c | 4 +--- libvo/vo_png.c | 4 +--- subopt-helper.c | 8 ++------ 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c index ba49231b28..70cd92198b 100644 --- a/libao2/ao_alsa.c +++ b/libao2/ao_alsa.c @@ -265,9 +265,7 @@ static void print_help (void) static int str_maxlen(void *strp) { strarg_t *str = strp; - if (str->len > ALSA_DEVICE_SIZE) - return 0; - return 1; + return str->len <= ALSA_DEVICE_SIZE; } static int try_open_device(const char *device, int open_mode, int try_ac3) diff --git a/libvo/vo_jpeg.c b/libvo/vo_jpeg.c index 5f9a5d1f6d..1be11014b0 100644 --- a/libvo/vo_jpeg.c +++ b/libvo/vo_jpeg.c @@ -333,9 +333,7 @@ static void check_events(void) static int int_zero_hundred(void *valp) { int *val = valp; - if ( (*val >=0) && (*val<=100) ) - return 1; - return 0; + return *val >= 0 && *val <= 100; } static int preinit(const char *arg) diff --git a/libvo/vo_png.c b/libvo/vo_png.c index e404785736..94fbdcaf8f 100644 --- a/libvo/vo_png.c +++ b/libvo/vo_png.c @@ -286,9 +286,7 @@ static void check_events(void){} static int int_zero_to_nine(void *value) { int *sh = value; - if ( (*sh < 0) || (*sh > 9) ) - return 0; - return 1; + return *sh >= 0 && *sh <= 9; } static const opt_t subopts[] = { diff --git a/subopt-helper.c b/subopt-helper.c index e40f9f40d0..6167778b9f 100644 --- a/subopt-helper.c +++ b/subopt-helper.c @@ -303,17 +303,13 @@ static char const * parse_str( char const * str, strarg_t * const valp ) int int_non_neg(void *iptr) { int *i = iptr; - if ( *i < 0 ) { return 0; } - - return 1; + return *i >= 0; } /** \brief Test if i is positive. */ int int_pos(void *iptr) { int *i = iptr; - if ( *i > 0 ) { return 1; } - - return 0; + return *i > 0; } /*** little helpers */ -- cgit v1.2.3