]> Savannah Git Hosting - gnulib.git/commitdiff
sys_socket tests: Improve checks for socklen_t and sa_family_t.
authorCollin Funk <collin.funk1@gmail.com>
Wed, 24 Jul 2024 02:00:28 +0000 (19:00 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Wed, 24 Jul 2024 02:00:28 +0000 (19:00 -0700)
* modules/sys_socket-tests (Depends-on): Add intprops.
* tests/test-sys_socket.c: Check that socklen_t is at least 32 bits
wide. Check that sa_family_t is unsigned.

ChangeLog
modules/sys_socket-tests
tests/test-sys_socket.c

index 0c252e22d0daa19436df65eb8d7f5ae91bd714e2..cf51073474db1bd761eea2997e25992648ebe4f8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-07-23  Collin Funk  <collin.funk1@gmail.com>
+
+       sys_socket tests: Improve checks for socklen_t and sa_family_t.
+       * modules/sys_socket-tests (Depends-on): Add intprops.
+       * tests/test-sys_socket.c: Check that socklen_t is at least 32 bits
+       wide. Check that sa_family_t is unsigned.
+
 2024-07-23  Bruno Haible  <bruno@clisp.org>
 
        getopt-posix, getopt-gnu tests: Avoid test failure on mingw.
index b0bb4356ca8308dac29b9fa25c088da081005279..0e0ef6c45e4b197dc79798f0b8300499697f108e 100644 (file)
@@ -3,6 +3,7 @@ tests/test-sys_socket.c
 
 Depends-on:
 assert-h
+intprops
 sys_socket-c++-tests
 
 configure.ac:
index 6fbfb98a707c3a774dfae58d8368e6f69b1c8e8a..5c1ad1154074b76f97c4453774e45bcad357bdfd 100644 (file)
@@ -38,6 +38,16 @@ struct msghdr msg;
 
 #include <errno.h>
 
+#include "intprops.h"
+
+/* POSIX requires that 'socklen_t' is an integer type with a width of at
+   least 32 bits.  */
+static_assert (32 <= TYPE_WIDTH (socklen_t));
+
+/* POSIX requires that sa_family_t is an unsigned integer type.  */
+static_assert (! TYPE_SIGNED (sa_family_t));
+
+
 int
 main (void)
 {