From 09244c002e00fe24571c50d249bc649694fb1837 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 5 Dec 2013 19:43:34 +0000 Subject: * cygheap.h (cygheap_fdnew): Avoid setting errno directly since it will have been set by a previous function. * dtable.h (dtable::extend): Accept second size_t argument. * dtable.cc (dtable::extend): Accept second "min" argument which allows checking for OPEN_MAX_MAX boundary conditions. (dtable_init): Accommodate second argument to dtable::extend. (dtable::find_unused_handle): Ditto. * syscalls.cc (setdtablesize): Ditto. (dup): Return any error passed by cygheap_fdnew() directly. (getdtablesize): Just return dtable size directly. --- winsup/cygwin/syscalls.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'winsup/cygwin/syscalls.cc') diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 8769eb582..cb9709165 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -120,7 +120,12 @@ close_all_files (bool norelease) extern "C" int dup (int fd) { - int res = cygheap->fdtab.dup3 (fd, cygheap_fdnew (), 0); + int res; + int newfd = cygheap_fdnew (); + if (newfd < 0) + res = -1; + else + res = cygheap->fdtab.dup3 (fd, newfd, 0); syscall_printf ("%R = dup(%d)", res, fd); return res; } @@ -2611,7 +2616,8 @@ setdtablesize (int size) return -1; } - if (size <= (int)cygheap->fdtab.size || cygheap->fdtab.extend (size - cygheap->fdtab.size)) + if (size <= (int) cygheap->fdtab.size + || cygheap->fdtab.extend (size - cygheap->fdtab.size, OPEN_MAX_MAX)) return 0; return -1; @@ -2620,7 +2626,7 @@ setdtablesize (int size) extern "C" int getdtablesize () { - return cygheap->fdtab.size > OPEN_MAX ? cygheap->fdtab.size : OPEN_MAX; + return cygheap->fdtab.size; } extern "C" int -- cgit v1.2.3