conf_ports_range_except() generates errors if asked to map an address of
a family that's not available. This is quite late to perform the check,
most callsites pass a NULL address, making the test moot, the one remaining
can check the address earlier. Move the check there, simplifying the
lower level function.
Signed-off-by: David Gibson
---
conf.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/conf.c b/conf.c
index dc9468c2..d4c2a013 100644
--- a/conf.c
+++ b/conf.c
@@ -160,16 +160,6 @@ static void conf_ports_range_except(const struct ctx *c, char optname,
else
assert(0);
- if (addr) {
- if (!c->ifi4 && inany_v4(addr)) {
- die("IPv4 is disabled, can't use -%c %s",
- optname, optarg);
- } else if (!c->ifi6 && !inany_v4(addr)) {
- die("IPv6 is disabled, can't use -%c %s",
- optname, optarg);
- }
- }
-
for (base = first; base <= last; base++) {
if (exclude && bitmap_isset(exclude, base))
continue;
@@ -335,6 +325,16 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg,
addr = NULL;
}
+ if (addr) {
+ if (!c->ifi4 && inany_v4(addr)) {
+ die("IPv4 is disabled, can't use -%c %s",
+ optname, optarg);
+ } else if (!c->ifi6 && !inany_v4(addr)) {
+ die("IPv6 is disabled, can't use -%c %s",
+ optname, optarg);
+ }
+ }
+
/* Mark all exclusions first, they might be given after base ranges */
p = spec;
do {
--
2.53.0