[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] errno: make EEXIST != ENOTEMPTY on AIX
From: |
Bruno Haible |
Subject: |
Re: [PATCH] errno: make EEXIST != ENOTEMPTY on AIX |
Date: |
Thu, 01 Aug 2024 13:41:25 +0200 |
Hi Paul,
> * m4/calloc.m4 (gl_FUNC_CALLOC_GNU):
> * m4/malloc.m4 (gl_FUNC_MALLOC_GNU):
> * m4/realloc.m4 (gl_FUNC_REALLOC_GNU):
> * m4/scandir.m4 (gl_FUNC_SCANDIR):
> Define _LINUX_SOURCE_COMPAT, as this can sometimes help on AIX.
> * m4/errno_h.m4 (gl_HEADER_ERRNO_H):
> Define _LINUX_SOURCE_COMPAT, to make EEXIST != ENOTEMPTY.
> * m4/strerror_r.m4 (gl_FUNC_STRERROR_R):
> Define _LINUX_SOURCE_COMPAT, in case someone else does.
On AIX 7.1 (machine: gcc111.fsffrance.org), a testdir of the modules
calloc-gnu malloc-gnu realloc-gnu scandir strerror_r-posix,
that previously passed all its tests, now has two test failures:
FAIL: test-error.sh
===================
--- /tmp/dkvt7aa 2024-08-01 03:35:10.000000000 -0700
+++ err2 2024-08-01 03:35:10.000000000 -0700
@@ -9,5 +9,5 @@
hammer
boing 123 is too large
d2/bar.c:11: bark too loud
- test-error: can't steal: Permission denied
+ test-error: can't steal: Unknown system error
test-error: fatal error
FAIL test-error.sh (exit status: 1)
FAIL: test-strerror_r
=====================
../../gltests/test-strerror_r.c:39: assertion 'buf[0] != '\0'' failed
FAIL test-strerror_r (exit status: 134)
A strerror_r function that, for EACCESS, returns "Unknown system error" instead
of "Permission denied", is pretty much completely unusable.
The cause is that our strerror_r replacement tests STRERROR_R_CHAR_P but then,
after a '#undef strerror_r' (which is necessary in order to avoid endless
recursion), uses the original strerror_r function, with return type 'int',
not 'char *'. The fix is to ignore STRERROR_R_CHAR_P there.
But then, the change to m4/strerror_r.m4 doesn't make sense either:
- Regardless whether _LINUX_SOURCE_COMPAT is defined, strerror_r.c uses
the original strerror_r function.
- There is no reason to even ask for the glibc-compatible strerror_r,
since the glibc strerror_r has been recognized as a mistake and gnulib
therefore offers only a 'strerror_r-posix' module.
This patch fixes both issues.
2024-08-01 Bruno Haible <bruno@clisp.org>
strerror_r: Fix for AIX (regression yesterday).
* lib/strerror_r.c: Ignore the value of STRERROR_R_CHAR_P on AIX.
* m4/strerror_r.m4 (gl_FUNC_STRERROR_R): Don't define
_LINUX_SOURCE_COMPAT, since it provides no advantage for strerror_r.
diff --git a/lib/strerror_r.c b/lib/strerror_r.c
index 0cd28ade6e..87fc114262 100644
--- a/lib/strerror_r.c
+++ b/lib/strerror_r.c
@@ -34,7 +34,7 @@
#include "strerror-override.h"
-#if STRERROR_R_CHAR_P
+#if STRERROR_R_CHAR_P && !defined _AIX
# if HAVE___XPG_STRERROR_R
_GL_EXTERN_C int __xpg_strerror_r (int errnum, char *buf, size_t buflen);
@@ -159,7 +159,10 @@ strerror_r (int errnum, char *buf, size_t buflen)
int ret;
int saved_errno = errno;
-#if STRERROR_R_CHAR_P
+ /* Due to the '#undef strerror_r' above, on AIX, we're always using
+ the POSIX-compatible strerror_r function, regardless whether
+ _LINUX_SOURCE_COMPAT is defined or not. */
+#if STRERROR_R_CHAR_P && !defined _AIX
{
ret = 0;
diff --git a/m4/strerror_r.m4 b/m4/strerror_r.m4
index eae9f1c419..5353972172 100644
--- a/m4/strerror_r.m4
+++ b/m4/strerror_r.m4
@@ -1,5 +1,5 @@
# strerror_r.m4
-# serial 27
+# serial 28
dnl Copyright (C) 2002, 2007-2024 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -10,13 +10,6 @@ AC_DEFUN([gl_FUNC_STRERROR_R]
AC_REQUIRE([gl_STRING_H_DEFAULTS])
AC_REQUIRE([gl_FUNC_STRERROR_R_WORKS])
- dnl On AIX, ask for the GNU/Linux API. Other modules might ask for
- dnl that API for other reasons, so we will will need override it because
- dnl we cannot easily ask AIX for the GNU/Linux API for everything
- dnl but strerror_r.
- AC_DEFINE([_LINUX_SOURCE_COMPAT], [1],
- [Define so that AIX headers are more compatible with GNU/Linux.])
-
dnl Some systems don't declare strerror_r() if _THREAD_SAFE and _REENTRANT
dnl are not defined.
AC_CHECK_DECLS_ONCE([strerror_r])
- Re: [PATCH] errno: make EEXIST != ENOTEMPTY on AIX,
Bruno Haible <=