They aren’t needed in packages that use xstdopen
* lib/save-cwd.c: Do not include unistd--.h.
(GNULIB_FCNTL_SAFER): Do not define.
(save_cwd): Do not use fd_safer_flag, as the package should use
either fcntl-safer+unistd-safer or xstdopen if it cares about
closed stdin.
* modules/save-cwd (Depends-on): Remove fd-safer-flag, unistd-safer.
---
 ChangeLog        | 9 +++++++++
 lib/save-cwd.c   | 5 -----
 modules/save-cwd | 2 --
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 97ef0310fe..6ff94a9616 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2024-11-06  Paul Eggert  <egg...@cs.ucla.edu>
 
+       save-cwd: don’t depend on fd-safer-flag, unistd-safer
+       They aren’t needed in packages that use xstdopen
+       * lib/save-cwd.c: Do not include unistd--.h.
+       (GNULIB_FCNTL_SAFER): Do not define.
+       (save_cwd): Do not use fd_safer_flag, as the package should use
+       either fcntl-safer+unistd-safer or xstdopen if it cares about
+       closed stdin.
+       * modules/save-cwd (Depends-on): Remove fd-safer-flag, unistd-safer.
+
        error: tune a bit for xstdopen
        * lib/error.c (flush_stdout): Also optimize if GNULIB_XSTDOPEN.
 
diff --git a/lib/save-cwd.c b/lib/save-cwd.c
index 47f888c0bb..cf9405ebb5 100644
--- a/lib/save-cwd.c
+++ b/lib/save-cwd.c
@@ -28,12 +28,9 @@
 #include <stdlib.h>
 
 #include "chdir-long.h"
-#include "unistd--.h"
 
 #if GNULIB_FCNTL_SAFER
 # include "fcntl--.h"
-#else
-# define GNULIB_FCNTL_SAFER 0
 #endif
 
 /* Record the location of the current working directory in CWD so that
@@ -63,8 +60,6 @@ save_cwd (struct saved_cwd *cwd)
   cwd->name = NULL;
 
   cwd->desc = open (".", O_SEARCH | O_CLOEXEC);
-  if (!GNULIB_FCNTL_SAFER)
-    cwd->desc = fd_safer_flag (cwd->desc, O_CLOEXEC);
   if (cwd->desc < 0)
     {
       cwd->name = getcwd (NULL, 0);
diff --git a/modules/save-cwd b/modules/save-cwd
index 52bf3311df..12eb8f1b90 100644
--- a/modules/save-cwd
+++ b/modules/save-cwd
@@ -9,11 +9,9 @@ m4/save-cwd.m4
 Depends-on:
 chdir-long
 fchdir
-fd-safer-flag
 getcwd-lgpl
 open
 stdbool
-unistd-safer
 
 configure.ac:
 gl_SAVE_CWD
-- 
2.43.0


Reply via email to