* tests/test-openat.c (main): Work even if AT_FDCWD == -1.
+2025-09-01 Paul Eggert <eggert@cs.ucla.edu>
+
+ openat2-tests: fix AT_FDCWD portability
+ * tests/test-openat.c (main): Work even if AT_FDCWD == -1.
+
2025-08-31 Collin Funk <collin.funk1@gmail.com>
u64: Allow the header to be included twice.
@samp{POSIX_FADV_NORMAL}, @samp{POSIX_FADV_RANDOM},
@samp{POSIX_FADV_SEQUENTIAL}, and @samp{POSIX_FADV_WILLNEED} are not
defined on some platforms.
+
+@item
+POSIX allows @samp{AT_FDCWD} to be @minus{}1.
+Even though @samp{AT_FDCWD} is less than @minus{}1 on all
+known practical platforms,
+it is better to not assume that @minus{}1 is an invalid argument
+to functions like @samp{openat}.
@end itemize
/* Test behaviour for invalid file descriptors. */
{
errno = 0;
- ASSERT (openat (-1, "foo", O_RDONLY) == -1);
+ ASSERT (openat (AT_FDCWD == -1 ? -2 : -1, "foo", O_RDONLY) == -1);
ASSERT (errno == EBADF);
}
{