diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2016-08-14 19:45:25 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2016-08-14 19:45:25 +0000 |
commit | 452ef85199ea5dc2a9b2d6af9caba6b2133683fb (patch) | |
tree | a818910000d2e869767e16084aa6ec5f9991ebab /bin/csh/misc.c | |
parent | 6c7d48270e79e74d0ed5b35f023264ebec017f30 (diff) |
Don't call sysconf() in a loop conditional when the loop won't affect it
ok natano@ tedu@
Diffstat (limited to 'bin/csh/misc.c')
-rw-r--r-- | bin/csh/misc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/csh/misc.c b/bin/csh/misc.c index 3a3ab323090..d62b23db6e6 100644 --- a/bin/csh/misc.c +++ b/bin/csh/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.18 2015/12/26 13:48:38 mestre Exp $ */ +/* $OpenBSD: misc.c,v 1.19 2016/08/14 19:45:24 guenther Exp $ */ /* $NetBSD: misc.c,v 1.6 1995/03/21 09:03:09 cgd Exp $ */ /*- @@ -170,8 +170,9 @@ void closem(void) { int f; + int max = sysconf(_SC_OPEN_MAX); - for (f = 0; f < sysconf(_SC_OPEN_MAX); f++) + for (f = 0; f < max; f++) if (f != SHIN && f != SHOUT && f != SHERR && f != OLDSTD && f != FSHTTY) (void) close(f); |