From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10619 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Using macro CMSG_NXTHDR generates warnings with CLANG Date: Tue, 11 Oct 2016 11:09:01 -0400 Message-ID: <20161011150901.GG19318@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1476198586 16357 195.159.176.226 (11 Oct 2016 15:09:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 11 Oct 2016 15:09:46 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-10632-gllmg-musl=m.gmane.org@lists.openwall.com Tue Oct 11 17:09:42 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1btyg5-00006P-DJ for gllmg-musl@m.gmane.org; Tue, 11 Oct 2016 17:09:13 +0200 Original-Received: (qmail 13752 invoked by uid 550); 11 Oct 2016 15:09:14 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 13731 invoked from network); 11 Oct 2016 15:09:13 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10619 Archived-At: On Mon, Oct 10, 2016 at 10:09:38PM +0000, Jan Vorlicek wrote: > Trying to build a piece of code that uses CMSG_NXTHDR macro using > CLANG (tested with CLANG 3.8) with all warnings enabled using > -Weverything generates the following warnings: > > clang++ -Weverything ./nettest.cpp -c -o nettest.o > > ../nettest.cpp:5:12: warning: cast from 'unsigned char *' to 'struct cmsghdr *' increases required alignment from 1 to 4 [-Wcast-align] > return CMSG_NXTHDR(mhdr, cmsg); > ^~~~~~~~~~~~~~~~~~~~~~~ > /usr/include/sys/socket.h:270:8: note: expanded from macro 'CMSG_NXTHDR' > ? 0 : (struct cmsghdr *)__CMSG_NEXT(cmsg)) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../nettest.cpp:5:12: warning: comparison of integers of different signs: 'unsigned long' and 'long' [-Wsign-compare] > return CMSG_NXTHDR(mhdr, cmsg); > ^~~~~~~~~~~~~~~~~~~~~~~ > /usr/include/sys/socket.h:269:44: note: expanded from macro 'CMSG_NXTHDR' > __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \ > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 2 warnings generated. > > The testing source is below: > > #include > cmsghdr* GET_CMSG_NXTHDR(msghdr* mhdr, cmsghdr* cmsg); > > 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. Rich