Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Fri, 29 Mar 2024 16:50:47 +0000
From: Denis Ovsienko <denis@...ienko.info>
To: musl@...ts.openwall.com
Subject: musl CMSG_NXTHDR() triggers a -Wsign-compare from Clang

Hello all.

To see how well libpcap compiles with musl libc, I used Alpine Linux
3.19 and noticed that one of the musl headers triggers warnings in
libpcap source, which in development environments tends to use -Werror
because normally it produces no compiler warnings.  The warning in musl
libc <sys/socket.h> becomes a warning in libpcap pcap-bt-linux.c and
fails the build.  The workaround is not difficult, but fixing it in
upstream would make more sense from my point of view.  The problem
reproduces using Clang only.

$ /usr/lib/libc.so
musl libc (x86_64)
Version 1.2.4_git20230717
Dynamic Program Loader
Usage: /usr/lib/libc.so [options] [--] pathname [args]

$ clang --version
Alpine clang version 17.0.5
Target: x86_64-alpine-linux-musl
Thread model: posix
InstalledDir: /usr/bin
Configuration file: /etc/clang17/x86_64-alpine-linux-musl.cfg

$ clang
-fvisibility=hidden -W
-Wall -Wcomma
-Wdocumentation
-Wformat-nonliteral -Wmissing-noreturn -Wmissing-prototypes
-Wmissing-variable-declarations -Wnull-pointer-subtraction
-Wpointer-arith -Wpointer-sign -Wshadow -Wshorten-64-to-32
-Wsign-compare -Wstrict-prototypes -Wundef -Wunreachable-code
-Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-parameter
-Wused-but-marked-unused  -fpic -I.  -I/usr/include/libnl3
-I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -DBUILDING_PCAP
-Dpcap_EXPORTS -DHAVE_CONFIG_H  -Werror -c ./pcap-bt-linux.c

./pcap-bt-linux.c:373:10: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare]
  373 |                 cmsg = CMSG_NXTHDR(&msg, cmsg);
      |                        ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/sys/socket.h:358:44: note: expanded from macro 'CMSG_NXTHDR'
  358 |         __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make: *** [Makefile:87: pcap-bt-linux.o] Error 1

-- 
    Denis Ovsienko

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.