diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2020-08-12 01:23:46 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2020-08-12 01:23:46 +0000 |
commit | 876c286a4e065eefe0291b5cc434280748d8b93a (patch) | |
tree | be611908010cca567e9bb21f27dfb56eff1a9e6c /usr.bin/ssh | |
parent | 1ea1f46ab945c63fe1eca8a726854e312f93ba42 (diff) |
ssh-keyscan(1): simplify conloop() with timercmp(3), timersub(3); ok djm@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r-- | usr.bin/ssh/ssh-keyscan.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/usr.bin/ssh/ssh-keyscan.c b/usr.bin/ssh/ssh-keyscan.c index 2c7c28c8401..108645a6a46 100644 --- a/usr.bin/ssh/ssh-keyscan.c +++ b/usr.bin/ssh/ssh-keyscan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keyscan.c,v 1.131 2019/12/15 19:47:10 djm Exp $ */ +/* $OpenBSD: ssh-keyscan.c,v 1.132 2020/08/12 01:23:45 cheloha Exp $ */ /* * Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>. * @@ -566,16 +566,9 @@ conloop(void) monotime_tv(&now); c = TAILQ_FIRST(&tq); - if (c && (c->c_tv.tv_sec > now.tv_sec || - (c->c_tv.tv_sec == now.tv_sec && c->c_tv.tv_usec > now.tv_usec))) { - seltime = c->c_tv; - seltime.tv_sec -= now.tv_sec; - seltime.tv_usec -= now.tv_usec; - if (seltime.tv_usec < 0) { - seltime.tv_usec += 1000000; - seltime.tv_sec--; - } - } else + if (c && timercmp(&c->c_tv, &now, >)) + timersub(&c->c_tv, &now, &seltime); + else timerclear(&seltime); r = xcalloc(read_wait_nfdset, sizeof(fd_mask)); @@ -598,8 +591,7 @@ conloop(void) free(e); c = TAILQ_FIRST(&tq); - while (c && (c->c_tv.tv_sec < now.tv_sec || - (c->c_tv.tv_sec == now.tv_sec && c->c_tv.tv_usec < now.tv_usec))) { + while (c && timercmp(&c->c_tv, &now, <)) { int s = c->c_fd; c = TAILQ_NEXT(c, c_link); |