[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: filemode: Add tests.
From: |
Bruno Haible |
Subject: |
Re: filemode: Add tests. |
Date: |
Wed, 19 Jun 2024 09:47:18 +0200 |
Hi Collin,
> I ran into a compilation error a long time ago (not Gnulib related)
> because I declared strmode using the mode_t argument unconditionally.
> This is an issue because FreeBSD uses int as the first argument and
> not mode_t, which is typedef'd to __uint16_t. This test is mostly to
> make sure that doesn't happen due to this module. I've added some
> basic functionality tests too.
Thanks for the test!
> NetBSD fixed that declaration in 1997 [1], FreeBSD did in version
> 14.0 [2]. OpenBSD still has it declared with an int argument even
> though mode_t is a __uint32_t there [3] [4] [5].
Also, macOS is in the same camp as OpenBSD here.
Since the test includes <unistd.h>, it should depend on the 'unistd'
module. Just to make sure we don't encounter a compilation error on
native Windows.
2024-06-19 Bruno Haible <bruno@clisp.org>
filemode tests: Tweak.
* tests/test-filemode.c: Update comment.
* modules/filemode-tests (Depends-on): Add unistd.
diff --git a/modules/filemode-tests b/modules/filemode-tests
index 983bc1e672..985de90272 100644
--- a/modules/filemode-tests
+++ b/modules/filemode-tests
@@ -3,6 +3,7 @@ tests/test-filemode.c
tests/macros.h
Depends-on:
+unistd
configure.ac:
diff --git a/tests/test-filemode.c b/tests/test-filemode.c
index 56c2fdc033..f20211d083 100644
--- a/tests/test-filemode.c
+++ b/tests/test-filemode.c
@@ -24,8 +24,8 @@
#include <sys/stat.h>
/* The strmode function is already defined on some systems in <string.h> or
- <unistd.h>. On FreeBSD versions 13 and lower the function takes an int
- instead of a mode_t (uint16_t) as it's first argument. Include these
+ <unistd.h>. On macOS, FreeBSD < 14.0, OpenBSD, the function takes an int
+ instead of a mode_t (uint16_t) as its first argument. Include these
headers here to make sure our declaration doesn't conflict with system
functions. */
#include <string.h>