minix/lib/nbsd_libc/sys-minix/m_closefrom.c
Thomas Veerman 92b61c816d Fix many more comiler warnings
Most warnings were harmless, some real bugs. Test set should now compile
cleanly with ack, gcc, and clang.
2011-11-28 10:07:55 +00:00

23 lines
347 B
C

#include <sys/cdefs.h>
#include "namespace.h"
#include <lib.h>
#include <stdlib.h>
#include <unistd.h>
PUBLIC int closefrom(int fd)
{
int f, ok = 0, e = 0;
for(f = fd; f < __MINIX_OPEN_MAX; f++) {
if(close(f) >= 0)
ok = 1;
else
e = errno;
}
if(ok)
return 0;
/* all failed - return last valid error */
errno = e;
return -1;
}