|
Message-ID: <20161011153100.GM28065@port70.net> Date: Tue, 11 Oct 2016 17:31:01 +0200 From: Szabolcs Nagy <nsz@...t70.net> To: musl@...ts.openwall.com Subject: Re: Using macro CMSG_NXTHDR generates warnings with CLANG * Rich Felker <dalias@...c.org> [2016-10-11 11:09:01 -0400]: > On Mon, Oct 10, 2016 at 10:09:38PM +0000, Jan Vorlicek wrote: > > The testing source is below: > > > > #include <sys/socket.h> > > cmsghdr* GET_CMSG_NXTHDR(msghdr* mhdr, cmsghdr* cmsg); > > this is invalid c code (you cannot leave 'struct' off). > > cmsghdr* GET_CMSG_NXTHDR(msghdr* mhdr, cmsghdr* cmsg) > > { > > return CMSG_NXTHDR(mhdr, cmsg); > > } > > > > Would it be possible to fix it so that no warnings are generated? We > > are building our application with -Weverything and currently we need > > to disable these two warnings around the CMSG_NXTHDR macro > > invocation. > > Thank you in advance for considering that! > > As these are system headers, the compiler should not be producing any > warnings from them. If it does that's a compiler bug. Are you perhaps > using an odd setup where musl's headers aren't in the default system > include path but instead passed in via -I rather than -isystem? If you > have a minimal test file I could see if the same warnings appear with > clang on Alpine Linux. > fwiw i see the warnings with clang -c -Wcast-align test.c i assume they cannot easily tell if they should warn when a macro defined in a system header expanded with user arguments. i think this warning is problematic: it warns about casting char*, but not about casting void* which has the exact same issue. so if you have apis that uses char* instead of void* for generic pointers (e.g. for abi compat reasons), then you get loads of false positives (which is what happens here). it can be worked around by adding a void* cast (but in my opinion that makes things worse: users will add more casts to get rid of the warning which has the opposite effect than what you would want).
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.