]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/main: work around CI lint:c problem
authorVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 15 Nov 2018 13:50:27 +0000 (14:50 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 15 Nov 2018 13:50:27 +0000 (14:50 +0100)
daemon/main.c

index 7bced7bcae216e47d1f3e71091554efb8eed1b47..bbe10c6ec082c077b4dc9aed0f4c4c4962682ab9 100644 (file)
@@ -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);