From 8c2b78ea5ad8db5c721ffb732e9b54239dc8541d Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 1 Dec 2014 15:29:02 +0100 Subject: options: simplify channel map validation The min=-1 case was never used, and the channel map must always be valid (or in some cases, invalid but empty). --- options/m_option.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'options') diff --git a/options/m_option.c b/options/m_option.c index ce86db0696..cb398f6bb9 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -2114,8 +2114,9 @@ const m_option_type_t m_option_type_afmt = { static int parse_chmap(struct mp_log *log, const m_option_t *opt, struct bstr name, struct bstr param, void *dst) { - // min>0: at least min channels, min=0: empty ok, min=-1: invalid ok + // min>0: at least min channels, min=0: empty ok int min_ch = (opt->flags & M_OPT_MIN) ? opt->min : 1; + assert(min_ch >= 0); if (bstr_equals0(param, "help")) { mp_chmap_print_help(log); @@ -2131,9 +2132,7 @@ static int parse_chmap(struct mp_log *log, const m_option_t *opt, return M_OPT_INVALID; } - if ((min_ch >= 0 && !mp_chmap_is_valid(&res)) && - !(min_ch == 0 && mp_chmap_is_empty(&res))) - { + if (!mp_chmap_is_valid(&res) && !(min_ch == 0 && mp_chmap_is_empty(&res))) { mp_err(log, "Invalid channel layout: %.*s\n", BSTR_P(param)); return M_OPT_INVALID; } -- cgit v1.2.3