From 6a4f420af5f91f5b3129394d287bbacf0408c767 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 16 Jul 2025 23:21:23 -0700 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20optimize=20insert-file-contents?= =?utf8?q?=20for=20GNU?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * src/fileio.c (Finsert_file_contents): Remove a microoptimization for GNU/Linux and Android. (cherry picked from commit 15570b7b95da3461feb51cf1bfe3b6337f5a67cd) --- src/fileio.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index e33ac4afabf..a9e5975a2eb 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -4187,16 +4187,14 @@ by calling `format-decode', which see. */) if (emacs_fd_fstat (fd, &st) < 0) report_file_error ("Input file status", orig_filename); - /* For backwards compatibility to traditional Unix, - POSIX allows the 'read' syscall to succeed on directories. - However, we want to fail, to be consistent across platforms - and to let callers rely on this function failing on directories. - There is no need to check on platforms where it is known that the - 'read' syscall always fails on a directory. */ -#if ! (defined GNU_LINUX || defined __ANDROID__) + /* Normally there is no need for an S_ISDIR test here, + as the first 'read' syscall will fail with EISDIR. + However, for backwards compatibility to traditional Unix, + POSIX allows 'read' to succeed on directories. + So do an explicit S_ISDIR test now, so that callers can rely on + this function rejecting directories on all platforms. */ if (S_ISDIR (st.st_mode)) report_file_errno ("Read error", orig_filename, EISDIR); -#endif regular = S_ISREG (st.st_mode) != 0; bool memory_object = S_TYPEISSHM (&st) || S_TYPEISTMO (&st); -- 2.39.5