From: Jo-Philipp Wich Date: Mon, 18 Nov 2013 12:36:45 +0000 (+0000) Subject: Change fw3_parse_options() to indicate whether all options where parsed successfully X-Git-Url: http://git.archive.openwrt.org/?p=project%2Ffirewall3.git;a=commitdiff_plain;h=3b4303ddcf81b281321a2ee486bbcdd2f2671fef;ds=sidebyside Change fw3_parse_options() to indicate whether all options where parsed successfully --- diff --git a/options.c b/options.c index 6f96681..c212218 100644 --- a/options.c +++ b/options.c @@ -853,7 +853,7 @@ fw3_parse_setmatch(void *ptr, const char *val, bool is_list) } -void +bool fw3_parse_options(void *s, const struct fw3_option *opts, struct uci_section *section) { @@ -863,6 +863,7 @@ fw3_parse_options(void *s, const struct fw3_option *opts, struct uci_option *o; const struct fw3_option *opt; struct list_head *dest; + bool valid = true; uci_foreach_element(§ion->options, e) { @@ -882,6 +883,7 @@ fw3_parse_options(void *s, const struct fw3_option *opts, if (!opt->elem_size) { warn_elem(e, "must not be a list"); + valid = false; } else { @@ -895,6 +897,7 @@ fw3_parse_options(void *s, const struct fw3_option *opts, if (!opt->parse(dest, l->name, true)) { warn_elem(e, "has invalid value '%s'", l->name); + valid = false; continue; } } @@ -910,7 +913,10 @@ fw3_parse_options(void *s, const struct fw3_option *opts, if (!opt->elem_size) { if (!opt->parse((char *)s + opt->offset, o->v.string, false)) + { warn_elem(e, "has invalid value '%s'", o->v.string); + valid = false; + } } else { @@ -921,6 +927,7 @@ fw3_parse_options(void *s, const struct fw3_option *opts, if (!opt->parse(dest, p, true)) { warn_elem(e, "has invalid value '%s'", p); + valid = false; continue; } } @@ -934,6 +941,8 @@ fw3_parse_options(void *s, const struct fw3_option *opts, if (!known) warn_elem(e, "is unknown"); } + + return valid; } diff --git a/options.h b/options.h index 88c98a0..262a21b 100644 --- a/options.h +++ b/options.h @@ -514,7 +514,7 @@ bool fw3_parse_monthdays(void *ptr, const char *val, bool is_list); bool fw3_parse_mark(void *ptr, const char *val, bool is_list); bool fw3_parse_setmatch(void *ptr, const char *val, bool is_list); -void fw3_parse_options(void *s, const struct fw3_option *opts, +bool fw3_parse_options(void *s, const struct fw3_option *opts, struct uci_section *section); const char * fw3_address_to_string(struct fw3_address *address,