diff options
author | Pádraig Brady <P@draigBrady.com> | 2016-04-20 18:26:58 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2016-04-21 19:41:58 +0100 |
commit | 2ef621251992bc0b9fbc9ada98606996047ed8a3 (patch) | |
tree | 7f69527bb8493d73b82ec785e8822f598ec5732c /src | |
parent | ff6cc22d062c493c9fee27cfe1d2e6328d502a43 (diff) | |
download | coreutils-2ef621251992bc0b9fbc9ada98606996047ed8a3.tar.xz |
sleep,timeout: support overflowing floating point values
* src/sleep.c (main): Allow ERANGE since we allow "inf" values.
* src/timeout.c (parse_duration): Likewise.
* tests/misc/sleep.sh: New file. Tests for sleep(1).
* tests/misc/timeout-parameters.sh: Add case for newly allowed
$LDBL_MAX. Also use returns_ throughout the file. Also avoid
small timeout values which might give false failures under load.
Diffstat (limited to 'src')
-rw-r--r-- | src/sleep.c | 2 | ||||
-rw-r--r-- | src/timeout.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/sleep.c b/src/sleep.c index a865c766d..acee3bbfe 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -124,7 +124,7 @@ main (int argc, char **argv) { double s; const char *p; - if (! xstrtod (argv[i], &p, &s, c_strtod) + if (! (xstrtod (argv[i], &p, &s, c_strtod) || errno == ERANGE) /* Nonnegative interval. */ || ! (0 <= s) /* No extra chars after the number and an optional s,m,h,d char. */ diff --git a/src/timeout.c b/src/timeout.c index 9c31df529..462ef6b81 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -314,7 +314,7 @@ parse_duration (const char* str) double duration; const char *ep; - if (!xstrtod (str, &ep, &duration, c_strtod) + if (! (xstrtod (str, &ep, &duration, c_strtod) || errno == ERANGE) /* Nonnegative interval. */ || ! (0 <= duration) /* No extra chars after the number and an optional s,m,h,d char. */ |