Skip to content

Commit 12a2eb8

Browse files
GitMenschrocallahan
authored andcommitted
portability for scm_rights using cast and print modifier for msghrd->controllen
The Linux Manpage says: > According to POSIX.1-2001, the msg_controllen field of the msghdr structure should be typed as socklen_t, but glibc currently types it as size_t. > `socklen_t` Describes the length of a socket address. This is an integer type of at least 32 bits. So "unsigned int" as defined in Alpine is fine, but break the compilation because of the formatting. The Debian manpage mentions: > Most of the integer types described in this page don't have a corresponding length modifier for the printf(3) [...] families of functions. To print a value of an integer type that doesn't have a length modifier, it should be converted to intmax_t or uintmax_t by an explicit cast. [...]
1 parent 1c14eb8 commit 12a2eb8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/test/scm_rights.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ static void child(int sock, int fd_minus_one) {
3737
atomic_printf("c: receiving msg ...\n");
3838
nread = recvmsg(sock, &msg, 0);
3939

40-
atomic_printf("c: ... got %#x (%zd bytes), %zu control bytes\n",
41-
mbuf.ints[0], nread, msg.msg_controllen);
40+
atomic_printf("c: ... got %#x (%zd bytes), %ju control bytes\n",
41+
mbuf.ints[0], nread, (uintmax_t)msg.msg_controllen);
4242
test_assert(nread == sizeof(mbuf.ints[0]));
4343
test_assert(MAGIC == mbuf.ints[0]);
4444
test_assert(~MAGIC == mbuf.ints[1]);

0 commit comments

Comments
 (0)