Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240602225026.GK10433@brightrain.aerifal.cx>
Date: Sun, 2 Jun 2024 18:50:26 -0400
From: Rich Felker <dalias@...c.org>
To: Ismael Luceno <ismael@...ev.co.uk>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH] ioctl: Fix implicit constant conversion overflow

On Sun, Jun 02, 2024 at 05:01:10AM +0200, Ismael Luceno wrote:
> 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.

In that case gcc is just being inconsistent. Both the conversion from
unsigned int to int and size_t to int are non-value-preserving. It
makes no sense that it warns for the latter but not for the former.

"Make weird inconsistent warning messages go away" is not a motivation
for a change. If the command macros could all be made to have type int
(matcing the ioctl argument) without introducing new problems, that
would be a well-motivated change. I suppose "make them have type
unsigned int rather than unsigned long so that they're not
gratuitously over-wide" might be well-motivated too, but I suspect it
leaves in place warnings in some places. "Fix implicit constant
conversion overflow" is not a well-motivated change since there is no
overflow.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.