From: Vladimír Čunát Date: Thu, 15 Nov 2018 13:50:27 +0000 (+0100) Subject: daemon/main: work around CI lint:c problem X-Git-Tag: v3.2.0~32^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a90597d7e2feef74dd38ace297b2cd67f4076e4;p=thirdparty%2Fknot-resolver.git daemon/main: work around CI lint:c problem --- diff --git a/daemon/main.c b/daemon/main.c index 7bced7bca..bbe10c6ec 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -513,6 +513,14 @@ static void args_init(struct args *args) args->quiet = false; } +static long strtol_10(const char *s) +{ + if (!s) abort(); + /* ^^ This shouldn't ever happen. When getopt_long() returns an option + * character that has a mandatory parameter, optarg can't be NULL. */ + return strtol(s, NULL, 10); +} + /** Process arguments into struct args. * @return >=0 if main() should be exited immediately. */ @@ -546,17 +554,17 @@ static int parse_args(int argc, char **argv, struct args *args) array_push(args->tls_set, optarg); break; case 'S': - array_push(args->fd_set, strtol(optarg, NULL, 10)); + array_push(args->fd_set, strtol_10(optarg)); break; case 'T': - array_push(args->tls_fd_set, strtol(optarg, NULL, 10)); + array_push(args->tls_fd_set, strtol_10(optarg)); break; case 'c': args->config = optarg; break; case 'f': args->interactive = false; - args->forks = strtol(optarg, NULL, 10); + args->forks = strtol_10(optarg); if (args->forks <= 0) { kr_log_error("[system] error '-f' requires a positive" " number, not '%s'\n", optarg);