From: Michael Orlitzky Date: Mon, 26 Feb 2018 01:11:54 +0000 (-0500) Subject: Eliminate the one remaining use of is_directory(). X-Git-Tag: v0.1.0~24 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=1be99786d05f3a7a75a17badae7b42491442a17a;p=apply-default-acl.git 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. --- 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)");