From: Alexander Monakov <amonakov@ispras.ru>
To: musl@lists.openwall.com
Subject: Re: [musl] Musl's FD_{SET,ISSET,CLR} macros from sys/select.h trigger gcc's -Wsign-conversion warnings
Date: Sun, 2 Aug 2020 21:56:41 +0300 (MSK) [thread overview]
Message-ID: <alpine.LNX.2.20.13.2008022154570.2454@monopod.intra.ispras.ru> (raw)
In-Reply-To: <alpine.LNX.2.20.13.2008022148160.2454@monopod.intra.ispras.ru>
[-- Attachment #1: Type: text/plain, Size: 1155 bytes --]
On Sun, 2 Aug 2020, Alexander Monakov wrote:
> On Sun, 2 Aug 2020, Petr Skocik wrote:
>
> > #define FD_SET(d, s) ((s)->fds_bits[(d)/(8*(int)sizeof(long))] |=
> > (1UL<<((d)%(8*(int)sizeof(long)))))
> > #define FD_CLR(d, s) ((s)->fds_bits[(d)/(8*(int)sizeof(long))] &=
> > ~(1UL<<((d)%(8*(int)sizeof(long)))))
> > #define FD_ISSET(d, s) !!((s)->fds_bits[(d)/(8*(int)sizeof(long))] &
> > (1UL<<((d)%(8*(int)sizeof(long)))))
> >
> > You might want to add them.
>
> (casting 'd' to size_t would have been more appropriate, as there's no need
> to perform signed division and modulus here)
>
> This is one of the cases where the warning should have been suppressed by
> GCC unless -Wsystem-headers is also given: the problem appears when expanding
> a macro defined in a system header, so the user can't cleanly avoid it.
I meant to also mention that as -Wsign-conversion is not part of -Wall -Wextra,
it's relatively rarely used, so lack of suppression is probably just an
oversight in the implementation, not a deliberate choice on GCC part.
> Would you care to open an issue in the GCC Bugzilla about it?
>
> Alexander
next prev parent reply other threads:[~2020-08-02 18:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-02 18:24 Petr Skocik
2020-08-02 18:53 ` Alexander Monakov
2020-08-02 18:56 ` Alexander Monakov [this message]
2020-08-02 19:43 ` Petr Skocik
2020-08-03 5:43 ` Markus Wichmann
2020-08-03 17:47 ` Rich Felker
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=alpine.LNX.2.20.13.2008022154570.2454@monopod.intra.ispras.ru \
--to=amonakov@ispras.ru \
--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).