mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Ismael Luceno <ismael@iodev.co.uk>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] ioctl: Fix implicit constant conversion overflow
Date: Sun, 2 Jun 2024 05:01:10 +0200	[thread overview]
Message-ID: <Zlvgdr9kztoNKDLz@pirotess> (raw)
In-Reply-To: <20240601023429.GJ10433@brightrain.aerifal.cx>

On 31/May/2024 22:34, Rich Felker wrote:
<...>
> > +#define _IOW(a,b,c) _IOC(_IOC_WRITE,(a),(b),(int)sizeof(c))
> > +#define _IOR(a,b,c) _IOC(_IOC_READ,(a),(b),(int)sizeof(c))
> > +#define _IOWR(a,b,c) _IOC(_IOC_READ|_IOC_WRITE,(a),(b),(int)sizeof(c))
> 
> I don't see how this helps with the warning you're trying to suppress,

GCC disagrees; the warnings go away because it's this element that
causes the whole expression to be promoted to unsigned long long,
so making it smaller (we can use unsigned int instead) avoids the
issue.

> since _IOC_{READ,WRITE} already have unsigned type. If you changed
> that, you would then have *real overflows* (undefined behavior)
> instead of the well-defined, valid implicit conversions -Werror is
> complaining about.

This expresssion is supposed to fit 32-bit anyway, isn't it?

  reply	other threads:[~2024-06-02  3:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-01  1:03 Ismael Luceno
2024-06-01  2:34 ` Rich Felker
2024-06-02  3:01   ` Ismael Luceno [this message]
2024-06-02 22:50     ` Rich Felker
2024-06-03  1:57       ` Ismael Luceno
2024-06-10 16:04         ` Rich Felker
2024-06-11 19:02           ` Ismael Luceno

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=Zlvgdr9kztoNKDLz@pirotess \
    --to=ismael@iodev.co.uk \
    --cc=dalias@libc.org \
    --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).