]> granicus.if.org Git - strace/commitdiff
tests/inet-cmsg.c: fix musl libc compilation warnings
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 12 Jan 2016 00:00:47 +0000 (00:00 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 12 Jan 2016 00:00:47 +0000 (00:00 +0000)
The types that are used to define msg_namelen member of struct msghdr
and cmsg_len member of struct cmsghdr differ between libcs.
For example, glibc defines them as size_t, while musl libc - as type
socklen_t.  Print these fields using %lu format to avoid issues caused
by libc differences.

* tests/inet-cmsg.c (main): Cast mh.msg_controllen and c->cmsg_len
to unsigned long and print them using %lu format.

tests/inet-cmsg.c

index 799f40514022e9c80d6ba68ec2bc2bfd0ab8d515..2e8c63d7a23299ac78271d8b9e9af8b6ec58ae83 100644 (file)
@@ -146,9 +146,9 @@ main(void)
 
        printf("recvmsg(0, {msg_name(%u)={sa_family=AF_INET, sin_port=htons(%u)"
               ", sin_addr=inet_addr(\"127.0.0.1\")}, msg_iov(1)=[{\"%s\", %zu}]"
-              ", msg_controllen=%zu, [",
+              ", msg_controllen=%lu, [",
               (unsigned) mh.msg_namelen, ntohs(addr.sin_port),
-              data, size, mh.msg_controllen);
+              data, size, (unsigned long) mh.msg_controllen);
 
        struct cmsghdr *c;
        for (c = CMSG_FIRSTHDR(&mh); c; c = CMSG_NXTHDR(&mh, c)) {
@@ -156,8 +156,8 @@ main(void)
                        continue;
                if (c != control)
                        printf(", ");
-               printf("{cmsg_len=%zu, cmsg_level=SOL_IP, cmsg_type=",
-                      c->cmsg_len);
+               printf("{cmsg_len=%lu, cmsg_level=SOL_IP, cmsg_type=",
+                      (unsigned long) c->cmsg_len);
                switch (c->cmsg_type) {
                        case IP_PKTINFO:
                                print_pktinfo(c);