mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Subject: Re: Using macro CMSG_NXTHDR generates warnings with CLANG
Date: Tue, 11 Oct 2016 17:31:01 +0200	[thread overview]
Message-ID: <20161011153100.GM28065@port70.net> (raw)
In-Reply-To: <20161011150901.GG19318@brightrain.aerifal.cx>

* Rich Felker <dalias@libc.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).


  parent reply	other threads:[~2016-10-11 15:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10 22:09 Jan Vorlicek
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 [this message]
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=20161011153100.GM28065@port70.net \
    --to=nsz@port70.net \
    --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).