From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 0CE6621F31 for ; Mon, 10 Jun 2024 18:03:57 +0200 (CEST) Received: (qmail 30314 invoked by uid 550); 10 Jun 2024 16:03:53 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 30273 invoked from network); 10 Jun 2024 16:03:53 -0000 Date: Mon, 10 Jun 2024 12:04:08 -0400 From: Rich Felker To: Ismael Luceno Cc: musl@lists.openwall.com Message-ID: <20240610160408.GN10433@brightrain.aerifal.cx> References: <20240601010328.27409-1-ismael@iodev.co.uk> <20240601023429.GJ10433@brightrain.aerifal.cx> <20240602225026.GK10433@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] [PATCH] ioctl: Fix implicit constant conversion overflow On Mon, Jun 03, 2024 at 03:57:18AM +0200, Ismael Luceno wrote: > On 02/Jun/2024 18:50, Rich Felker wrote: > > 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. > > GCC doesn't make much sense here but the warning appears with several > versions of GCC. > > An explicit cast at _IOC instead would make sense to me, but what could > break in your opinion? I'm not sure. It needs investigation. There might have been some concern with breakage from kernel headers that define ioctl numbers or something. I just remember this hasn't been as simple as it sounds from past times it came up.. Rich