From 05c7e329977d7e8bbc487c584a4f327e8626c77c Mon Sep 17 00:00:00 2001 From: Moritz Grimm Date: Wed, 6 May 2015 16:59:05 +0000 Subject: [PATCH] Fix command line parsing regression --- src/cfg.c | 2 +- src/cmdline.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cfg.c b/src/cfg.c index 7a95f23..c707a9f 100644 --- a/src/cfg.c +++ b/src/cfg.c @@ -171,7 +171,7 @@ cfg_set_program_name(const char *progname, const char **errstrp) int cfg_set_program_config_type(enum cfg_config_type type, const char **errstrp) { - if (type >= CFG_TYPE_MAX) { + if (CFG_TYPE_MIN > type || CFG_TYPE_MAX < type) { if (NULL != errstrp) *errstrp = "invalid"; return (-1); diff --git a/src/cmdline.c b/src/cmdline.c index 027e07a..32573ae 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -20,6 +20,7 @@ #include "compat.h" +#include #include #ifdef HAVE_UNISTD_H # include @@ -105,8 +106,9 @@ cmdline_parse(int argc, char *argv[], int *ret_p) switch (ch) { case OPT_CONFIGFILE: - if (0 > cfg_set_program_config_file(optarg, &err_str) || - 0 > cfg_set_program_config_type(CFG_TYPE_XMLFILE, NULL)) { + assert(0 == cfg_set_program_config_type(CFG_TYPE_XMLFILE, + NULL)); + if (0 > cfg_set_program_config_file(optarg, &err_str)) { fprintf(stderr, "-%c: argument %s\n", OPT_CONFIGFILE, err_str); _usage();