bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sethostname tests: Fix a compilation error on FreeBSD 14.0


From: Bruno Haible
Subject: sethostname tests: Fix a compilation error on FreeBSD 14.0
Date: Fri, 01 Dec 2023 11:48:31 +0100

On FreeBSD 14.0/x86_64, I see this compilation error in a testdir:

../../gltests/test-sethostname1.c:23:1: error: incompatible function pointer 
types initializing 'int (*)(const char *, size_t)' (aka 'int (*)(const char *, 
unsigned long)') with an expression of type 'int (const char *, int)' 
[-Wincompatible-function-pointer-types]
SIGNATURE_CHECK (sethostname, int, (const char *, size_t));
^                ~~~~~~~~~~~
../../gltests/signature.h:39:3: note: expanded from macro 'SIGNATURE_CHECK'
  SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
  ^                 ~~
../../gltests/signature.h:44:3: note: expanded from macro 'SIGNATURE_CHECK1'
  SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */
  ^                 ~~
../../gltests/signature.h:46:27: note: expanded from macro 'SIGNATURE_CHECK2'
  _GL_UNUSED static ret (*signature_check ## id) args = fn
                          ^                             ~~
<scratch space>:122:1: note: expanded from here
signature_check23
^
1 error generated.

The sethostname() prototype has not changed. What has changed is that
FreeBSD is now using clang 16, and clang 16 is more picky regarding function
prototype mismatches than earlier releases.

This patch provides a fix.


2023-12-01  Bruno Haible  <bruno@clisp.org>

        sethostname tests: Fix a compilation error on FreeBSD 14.0.
        * tests/test-sethostname1.c: Skip the SIGNATURE_CHECK on some platforms.
        * doc/glibc-functions/sethostname.texi: Update platforms list.

diff --git a/doc/glibc-functions/sethostname.texi 
b/doc/glibc-functions/sethostname.texi
index 9d6852d63e..fdfe1af4ed 100644
--- a/doc/glibc-functions/sethostname.texi
+++ b/doc/glibc-functions/sethostname.texi
@@ -39,5 +39,5 @@
 @item
 The second parameter is @code{int} instead of @code{size_t}
 on some platforms:
-macOS 11.1, MidnightBSD 2.0, Solaris 11 2010-11.
+macOS 12.5, FreeBSD 14.0, MidnightBSD 3.0, IRIX 6.5, Solaris 11 2010-11, 
Solaris 11 OpenIndiana, Solaris 11 OmniOS.
 @end itemize
diff --git a/tests/test-sethostname1.c b/tests/test-sethostname1.c
index f3fa7cb89f..7dc62ac7a2 100644
--- a/tests/test-sethostname1.c
+++ b/tests/test-sethostname1.c
@@ -20,7 +20,9 @@
 #include <unistd.h>
 
 #include "signature.h"
+#if !((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || 
defined __sgi || defined __sun)
 SIGNATURE_CHECK (sethostname, int, (const char *, size_t));
+#endif
 
 int do_dangerous_things;
 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]