summaryrefslogtreecommitdiff
path: root/src/sleep.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-12-25 20:00:21 +0000
committerJim Meyering <jim@meyering.net>1999-12-25 20:00:21 +0000
commit64003d937bd510d7f3e0d279d9a351afd32a362e (patch)
tree1ac1a0dbdb355348386698aa3a7397c4d9a8a893 /src/sleep.c
parent936a26728a776afbba4e62ece5a460a93f26a89f (diff)
downloadcoreutils-64003d937bd510d7f3e0d279d9a351afd32a362e.tar.xz
Use < rather than >.
(main): Normalize ts_stop.
Diffstat (limited to 'src/sleep.c')
-rw-r--r--src/sleep.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/sleep.c b/src/sleep.c
index f1e778109..57d2de778 100644
--- a/src/sleep.c
+++ b/src/sleep.c
@@ -126,7 +126,7 @@ timespec_subtract (struct timespec *diff,
y->tv_sec += nsec;
}
- if (x->tv_nsec - y->tv_nsec > 1000000000)
+ if (1000000000 < x->tv_nsec - y->tv_nsec)
{
int nsec = (y->tv_nsec - x->tv_nsec) / 1000000000;
y->tv_nsec += 1000000000 * nsec;
@@ -210,13 +210,13 @@ main (int argc, char **argv)
/* No negative intervals. */
|| s < 0
/* S must fit in a time_t. */
- || s > TIME_T_MAX
+ || TIME_T_MAX < s
/* No extra chars after the number and an optional s,m,h,d char. */
|| (*p && *(p+1))
/* Check any suffix char and update S based on the suffix. */
|| apply_suffix (&s, *p)
/* Make sure the sum fits in a time_t. */
- || (seconds += s) > TIME_T_MAX
+ || TIME_T_MAX < (seconds += s)
)
{
error (0, 0, _("invalid time interval `%s'"), argv[i]);
@@ -237,6 +237,11 @@ main (int argc, char **argv)
ts_stop.tv_sec = ts_start.tv_sec + ts_sleep.tv_sec;
ts_stop.tv_nsec = ts_start.tv_nsec + ts_sleep.tv_nsec;
+ if (1000000000 <= ts_stop.tv_nsec)
+ {
+ ++ts_stop.tv_sec;
+ ts_stop.tv_nsec -= 1000000000;
+ }
while (1)
{