From 1be99786d05f3a7a75a17badae7b42491442a17a Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 25 Feb 2018 20:11:54 -0500 Subject: [PATCH] Eliminate the one remaining use of is_directory(). The is_directory() function was called once, in a place where we already had access to its argument's stat structure. Instead, we now just use S_ISDIR, and the is_directory() function has met its end. --- src/apply-default-acl.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/src/apply-default-acl.c b/src/apply-default-acl.c index 29ca5fa..d2f8f53 100644 --- a/src/apply-default-acl.c +++ b/src/apply-default-acl.c @@ -92,29 +92,6 @@ bool is_path_directory(const char* path) { } -/** - * @brief Determine whether or not the given file descriptor is for - * a directory. - * - * @param fd - * The file descriptor whose directoryness is in question. - * - * @return true if @c fd describes a directory, and false otherwise. - */ -bool is_directory(int fd) { - if (fd <= 0) { - return false; - } - - struct stat s; - if (fstat(fd, &s) == 0) { - return S_ISDIR(s.st_mode); - } - else { - return false; - } -} - /** @@ -641,7 +618,7 @@ int apply_default_acl(const char* path, bool no_exec_mask) { if (!no_exec_mask) { /* Never mask the execute bit on directories. */ - int ace_result = any_can_execute(fd) || is_directory(fd); + int ace_result = any_can_execute(fd) || S_ISDIR(s.st_mode); if (ace_result == ACL_ERROR) { perror("apply_default_acl (any_can_execute)"); -- 2.43.2