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.0 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL 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 7B9D1261D7 for ; Fri, 24 May 2024 19:10:08 +0200 (CEST) Received: (qmail 28559 invoked by uid 550); 24 May 2024 17:10:04 -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 28476 invoked from network); 24 May 2024 17:10:04 -0000 Date: Fri, 24 May 2024 13:10:18 -0400 From: Rich Felker To: Rafael =?utf-8?Q?=C3=81vila_de_Esp=C3=ADndola?= Cc: musl@lists.openwall.com Message-ID: <20240524171018.GE10433@brightrain.aerifal.cx> References: <87v833cfb4.fsf@espindo.la> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87v833cfb4.fsf@espindo.la> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] ioctl signature On Fri, May 24, 2024 at 05:03:59PM +0000, Rafael Ávila de Espíndola wrote: > The signature of ioctl in musl is > > int ioctl (int, int, ...); > > In glibc it is > > int ioctl(int fd, unsigned long request, ...); > > The requests are always 32 bits, and the most significant bit is used to > indicated that this ioctl is a read operation. This means that some > constants are negative numbers if using an int. I have noticed this > because rust's interface to libc matches the system libc implementation, > and in alpine I got an error for a literal out of range for > 0xc0104801. I don't know if a C compiler would produce a warning, but > that seems somewhat reasonable. > > Should the declaration be changed to use an unsigned request?: > > int ioctl (int, unsigned int, ...); The declaration matches the POSIX definition of the ioctl interface, which is obsolete but the relevant historical standard. From a C standpoint it doesn't really matter whether the argument is signed or unsigned since either way the value round-trips right. I think we explored trying to make the constants come out as signed to match the interface, but there were reasons that didn't work well either. Rich