diff --git a/newlib/libc/posix/opendir.c b/newlib/libc/posix/opendir.c index 1416f1053..650cbfe8d 100644 --- a/newlib/libc/posix/opendir.c +++ b/newlib/libc/posix/opendir.c @@ -49,17 +49,12 @@ static char sccsid[] = "@(#)opendir.c 5.11 (Berkeley) 2/23/91"; DIR * opendir (const char *name) { - register DIR *dirp; - register int fd; - int rc = 0; + DIR *dirp; + int fd; - if ((fd = open(name, 0)) == -1) + if ((fd = open(name, O_RDONLY | O_DIRECTORY | O_CLOEXEC)) == -1) return NULL; -#ifdef HAVE_FCNTL - rc = fcntl(fd, F_SETFD, 1); -#endif - if (rc == -1 || - (dirp = (DIR *)malloc(sizeof(DIR))) == NULL) { + if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) { close (fd); return NULL; }