From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50EE7C433EF for ; Thu, 3 Mar 2022 11:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232696AbiCCLpe convert rfc822-to-8bit (ORCPT ); Thu, 3 Mar 2022 06:45:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbiCCLpd (ORCPT ); Thu, 3 Mar 2022 06:45:33 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 73E1FBF7C for ; Thu, 3 Mar 2022 03:44:47 -0800 (PST) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-4-XQRo4zE6MZqO9sHS00ouew-1; Thu, 03 Mar 2022 11:44:44 +0000 X-MC-Unique: XQRo4zE6MZqO9sHS00ouew-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Thu, 3 Mar 2022 11:44:42 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.028; Thu, 3 Mar 2022 11:44:42 +0000 From: David Laight To: "'Maciej W. Rozycki'" , Paul Cercueil CC: Jiri Slaby , =?iso-8859-1?Q?=27Uwe_Kleine-K=F6nig=27?= , "gregkh@linuxfoundation.org" , Alexandre Belloni , Mateusz Holenko , Neil Armstrong , Benjamin Herrenschmidt , Liviu Dudau , Baruch Siach , "linux-kernel@vger.kernel.org" , Paul Mackerras , "Michael Ellerman" , Michal Simek , "Karol Gugala" , Jerome Brunet , "Peter Korsgaard" , Florian Fainelli , Alexander Shiyan , Krzysztof Kozlowski , Alexandre Torgue , Fabio Estevam , "Russell King" , Ludovic Desroches , Andy Gross , "bcm-kernel-feedback-list@broadcom.com" , NXP Linux Team , "linux-serial@vger.kernel.org" , Vineet Gupta , Orson Zhai , Tobias Klauser , Patrice Chotard , "Albert Ou" , Maxime Coquelin , Manivannan Sadhasivam , Martin Blumenstingl , Sascha Hauer , Takao Orito , Vladimir Zapolskiy , Lorenzo Pieralisi , Paul Walmsley , Bjorn Andersson , Sudeep Holla , Richard Genoud , Chunyan Zhang , "Nicolas Ferre" , "David S. Miller" , Taichi Sugaya , Palmer Dabbelt , Pengutronix Kernel Team , "Kevin Hilman" , Baolin Wang , "Shawn Guo" , =?iso-8859-1?Q?Andreas_F=E4rber?= Subject: RE: [PATCH v3] serial: make uart_console_write->putchar()'s character an unsigned char Thread-Topic: [PATCH v3] serial: make uart_console_write->putchar()'s character an unsigned char Thread-Index: AQHYLl5tVpWrjMz0S0GPyaCV/1nc9aysw9yAgADDqR+AAACPoA== Date: Thu, 3 Mar 2022 11:44:42 +0000 Message-ID: <9fa84690ed244eba89f1efe4e6670f80@AcuMS.aculab.com> References: <20220302072732.1916-1-jslaby@suse.cz> <20220302175242.ejiaf36vszr4xvou@pengutronix.de> <5c7045c1910143e08ced432d938b5825@AcuMS.aculab.com> <84ad3854-28b9-e450-f0a2-f1448f32f137@suse.cz> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org From: Maciej W. Rozycki > Sent: 03 March 2022 11:31 .. > It does, but, oh dear, it's a "solution" to a problem we have created in > the first place. Why do we ever want to have signed characters in the TTY > layer, and then to vary between platforms? It's asking for portability > issues. C 'char' is signed because the pdp/11 byte load sign extended. I guess some ABI use unsigned char to avoid issues with all the functions that take/return an int parameter that is either a 'char' cast to 'unsigned char' or EOF. EOF is usually (-1) - but doesn't have to be. But it needs to be different from any value obtained by casting a 'char' to 'unsigned char'. (But that may only need to be all characters, not all values of 'char'.) Then you get the requirement that: sizeof (int) >= sizeof (short) >= sizeof (char) which means that it is perfectly valid for all 3 to be the same size [1]. In that case 'unsigned char' promotes to 'unsigned int' which probably breaks some code. It also makes defining EOF troublesome! [1] The C compiler for a DSP had this 'feature'. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)