From: Collin Funk Date: Wed, 24 Jul 2024 02:00:28 +0000 (-0700) Subject: sys_socket tests: Improve checks for socklen_t and sa_family_t. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=24e4b2dca4ac04795211d307a2ee20c62184d2b5;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 0c252e22d0..cf51073474 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-07-23 Collin Funk + + 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 getopt-posix, getopt-gnu tests: Avoid test failure on mingw. diff --git a/modules/sys_socket-tests b/modules/sys_socket-tests index b0bb4356ca..0e0ef6c45e 100644 --- a/modules/sys_socket-tests +++ b/modules/sys_socket-tests @@ -3,6 +3,7 @@ tests/test-sys_socket.c Depends-on: assert-h +intprops sys_socket-c++-tests configure.ac: diff --git a/tests/test-sys_socket.c b/tests/test-sys_socket.c index 6fbfb98a70..5c1ad11540 100644 --- a/tests/test-sys_socket.c +++ b/tests/test-sys_socket.c @@ -38,6 +38,16 @@ struct msghdr msg; #include +#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) {