From: Jan Vorlicek <janvorli@microsoft.com>
To: "musl@lists.openwall.com" <musl@lists.openwall.com>
Subject: Using macro CMSG_NXTHDR generates warnings with CLANG
Date: Mon, 10 Oct 2016 22:09:38 +0000 [thread overview]
Message-ID: <HE1PR83MB0058EC22A38BBBAE5E0DA1AECADB0@HE1PR83MB0058.EURPRD83.prod.outlook.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1580 bytes --]
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 <sys/socket.h>
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!
Jan
[-- Attachment #2: Type: text/html, Size: 4782 bytes --]
next reply other threads:[~2016-10-10 22:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-10 22:09 Jan Vorlicek [this message]
2016-10-11 14:45 ` Markus Wichmann
2016-10-11 15:09 ` Rich Felker
2016-10-11 15:17 ` Alexander Monakov
2016-10-11 15:22 ` Rich Felker
2016-10-11 15:25 ` Jan Vorlicek
2016-10-11 15:31 ` Szabolcs Nagy
2016-10-11 15:38 ` Jan Vorlicek
2016-10-11 16:43 ` Szabolcs Nagy
2016-10-11 16:46 ` Rich Felker
2018-03-06 17:16 ` Jacob Welsh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=HE1PR83MB0058EC22A38BBBAE5E0DA1AECADB0@HE1PR83MB0058.EURPRD83.prod.outlook.com \
--to=janvorli@microsoft.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).