--- a/io/tst-closefrom.c +++ b/io/tst-closefrom.c @@ -39,7 +39,7 @@ const int maximum_fd = lowfd + NFDS - 1; const int half_fd = lowfd + NFDS / 2; - const int gap = maximum_fd / 4; + const int gap = lowfd + NFDS / 4; /* Close half of the descriptors and check result. */ closefrom (half_fd); @@ -49,7 +49,7 @@ TEST_COMPARE (fcntl (i, F_GETFL), -1); TEST_COMPARE (errno, EBADF); } - for (int i = 0; i < half_fd; i++) + for (int i = lowfd; i < half_fd; i++) TEST_VERIFY (fcntl (i, F_GETFL) > -1); /* Create some gaps, close up to a threshold, and check result. */ @@ -65,7 +65,7 @@ TEST_COMPARE (fcntl (i, F_GETFL), -1); TEST_COMPARE (errno, EBADF); } - for (int i = 0; i < gap; i++) + for (int i = lowfd; i < gap; i++) TEST_VERIFY (fcntl (i, F_GETFL) > -1); /* Close the remmaining but the last one. */ --- a/sysdeps/unix/sysv/linux/tst-close_range.c +++ b/sysdeps/unix/sysv/linux/tst-close_range.c @@ -189,7 +189,7 @@ support_stack_free (&stack); - for (int i = 0; i < NFDS; i++) + for (int i = lowfd; i < lowfd + NFDS; i++) TEST_VERIFY (fcntl (i, F_GETFL) > -1); support_descriptors_check (descrs2);