diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-07-17 10:14:34 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-07-17 11:35:04 +0200 |
commit | fa8b675ae0c341daa141cce8783c106e048045e1 (patch) | |
tree | d1f1610b1680d48952f9b7ebc0417ec94c92533e /src/nspawn/nspawn-oci.c | |
parent | nspawn: fix memleak in argument parsing (diff) | |
download | systemd-fa8b675ae0c341daa141cce8783c106e048045e1.tar.xz systemd-fa8b675ae0c341daa141cce8783c106e048045e1.zip |
nspawn: fix misplaced parenthesis and merge two error handling paths
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.
Diffstat (limited to '')
-rw-r--r-- | src/nspawn/nspawn-oci.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/nspawn/nspawn-oci.c b/src/nspawn/nspawn-oci.c index ef67731339..4519c74b95 100644 --- a/src/nspawn/nspawn-oci.c +++ b/src/nspawn/nspawn-oci.c @@ -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; |