Now that we know that opendir, fdopendir, closedir (and openat, lstat) are
known to set errno upon failure, the same behaviour follows for getcwd() and
then also for xgetcwd().


2020-06-26  Bruno Haible  <[email protected]>

        xgetcwd: Improve documentation.
        * lib/xgetcwd.c (xgetcwd): Document the failure return convention.

2020-06-26  Bruno Haible  <[email protected]>

        getcwd: Improve documentation.
        * lib/getcwd.c (__getcwd): Document the failure return convention.

>From e75484521cc31641f8e6855a7317988af30cf989 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sat, 27 Jun 2020 02:59:07 +0200
Subject: [PATCH 1/3] getcwd: Improve documentation.

* lib/getcwd.c (__getcwd): Document the failure return convention.
---
 ChangeLog    | 5 +++++
 lib/getcwd.c | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c047c41..49422d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2020-06-26  Bruno Haible  <[email protected]>
 
+	getcwd: Improve documentation.
+	* lib/getcwd.c (__getcwd): Document the failure return convention.
+
+2020-06-26  Bruno Haible  <[email protected]>
+
 	fchdir: Improve documentation.
 	* lib/fchdir.c (get_name, _gl_register_fd): Document the failure return
 	convention.
diff --git a/lib/getcwd.c b/lib/getcwd.c
index 45470fc..1a42ef1 100644
--- a/lib/getcwd.c
+++ b/lib/getcwd.c
@@ -133,10 +133,10 @@ getcwd_nothrow (char *buf, size_t size)
 #endif
 
 /* Get the name of the current working directory, and put it in SIZE
-   bytes of BUF.  Returns NULL if the directory couldn't be determined or
-   SIZE was too small.  If successful, returns BUF.  In GNU, if BUF is
-   NULL, an array is allocated with 'malloc'; the array is SIZE bytes long,
-   unless SIZE == 0, in which case it is as big as necessary.  */
+   bytes of BUF.  Returns NULL with errno set if the directory couldn't be
+   determined or SIZE was too small.  If successful, returns BUF.  In GNU,
+   if BUF is NULL, an array is allocated with 'malloc'; the array is SIZE
+   bytes long, unless SIZE == 0, in which case it is as big as necessary.  */
 
 char *
 __getcwd (char *buf, size_t size)
-- 
2.7.4

>From b7e52f508ecb769b69975976be5aaa3a9a0b1ca2 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sat, 27 Jun 2020 03:00:01 +0200
Subject: [PATCH 2/3] xgetcwd: Improve documentation.

* lib/xgetcwd.c (xgetcwd): Document the failure return convention.
---
 ChangeLog     | 5 +++++
 lib/xgetcwd.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 49422d3..7016db3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2020-06-26  Bruno Haible  <[email protected]>
 
+	xgetcwd: Improve documentation.
+	* lib/xgetcwd.c (xgetcwd): Document the failure return convention.
+
+2020-06-26  Bruno Haible  <[email protected]>
+
 	getcwd: Improve documentation.
 	* lib/getcwd.c (__getcwd): Document the failure return convention.
 
diff --git a/lib/xgetcwd.c b/lib/xgetcwd.c
index 62b8c8c..8fb9342 100644
--- a/lib/xgetcwd.c
+++ b/lib/xgetcwd.c
@@ -29,7 +29,7 @@
 
 /* Return the current directory, newly allocated.
    Upon an out-of-memory error, call xalloc_die.
-   Upon any other type of error, return NULL.  */
+   Upon any other type of error, return NULL with errno set.  */
 
 char *
 xgetcwd (void)
-- 
2.7.4

Reply via email to