]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: fix misplaced parenthesis and merge two error handling paths
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 17 Jul 2019 08:14:34 +0000 (10:14 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 17 Jul 2019 09:35:04 +0000 (11:35 +0200)
I don't think we need to provide the two separate error messages,
let's shorten the code a bit by merging them.

Coverity CID#1402320.

src/nspawn/nspawn-oci.c

index ef67731339ffd3a851f2540b810a3554002e207f..4519c74b95b3582778f4bfd53ecfaa9e46d8c424 100644 (file)
@@ -2092,13 +2092,9 @@ static int oci_hook_timeout(const char *name, JsonVariant *v, JsonDispatchFlags
         uintmax_t k;
 
         k = json_variant_unsigned(v);
-        if (k == 0)
-                return json_log(v, flags, SYNTHETIC_ERRNO(EINVAL),
-                                "Hook timeout cannot be zero.");
-
-        if (k > (UINT64_MAX-1/USEC_PER_SEC))
-                return json_log(v, flags, SYNTHETIC_ERRNO(EINVAL),
-                                "Hook timeout too large.");
+        if (k == 0 || k > (UINT64_MAX-1)/USEC_PER_SEC)
+                return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
+                                "Hook timeout value out of range.");
 
         *u = k * USEC_PER_SEC;
         return 0;