Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp797346pxm; Thu, 3 Mar 2022 05:00:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJym+1GAsXF4hGH5Es73Qo40uLZ1hBGZZb6fC5UcSjOD9yyXlQ83eKS6pSF32/7yvHVROh37 X-Received: by 2002:a05:6a00:1694:b0:4e1:9050:1e19 with SMTP id k20-20020a056a00169400b004e190501e19mr38209152pfc.72.1646312455546; Thu, 03 Mar 2022 05:00:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646312455; cv=none; d=google.com; s=arc-20160816; b=jQykTnWuBFYcBypkKQM1NrASd24/oJBYl2NKPLXn5wqpGw1w5ouV3eWHG4vAc/d7E5 hBzA2lqQ9zgAxiJS9fyhRIPfpwkFCKW2i29T+SUXd3zsLYDpDz/udQfgUAIjOQPhO32H T9mgdb5IDSdNIS+j4j7kiT18AlX/nLg8bDOKZV0sF+/3KgJqhpDQ3hDFDylajY59G86w 9k9rvnJTqsf0arX64ETPUdJwOc1bJhUefowbapiuLAesQPvwzYgA6eP8teGUM1cb7Upq QeT7T0DBD1GzJGq+YdhKTQIjUFqrDsTrRSjKHvpZ88b+zx/m239rVq+mvL/lLJJxPUKo EN1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:subject:from:date; bh=ClJTn6MUVkJblEzxFv9tlOTDcp2WGpE2zsiqa0feJjY=; b=Ha5+FJ7s8TcaOHM9lns0HXs9kEEvjRjTYcguY1M4FCLBqrf/Vp6qhvPGBXode30lIj beG2SF277j5f8f5gEXsTiksNHCFSTVkZ+GelHE7tjxiR5LIdvPNKH3+bmV9EFOsFFhHJ gvlSWQ9L7n5GBDNylaKXjkl89WIkvzJ56rPLBXSmsNu5cEAjurKDrtsvvTCcIxIlJgDQ mkNxpvweYdgYYCW07Ixtbmv9UY2DsumuV45E6CNm9cRT7bB+PQ/DxHMOQAGl5AsSNdDR Cw1kC3pqyWJS6/bN6tWGINLZR47wOoOWlz4BDcnPcpIP51ozRbPAA/9IKdjObh5KvCoB 2LLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020a170902f70e00b001515e2375b5si1960033plo.440.2022.03.03.05.00.38; Thu, 03 Mar 2022 05:00:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233304AbiCCM2t convert rfc822-to-8bit (ORCPT + 99 others); Thu, 3 Mar 2022 07:28:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232047AbiCCM2r (ORCPT ); Thu, 3 Mar 2022 07:28:47 -0500 Received: from aposti.net (aposti.net [89.234.176.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B96B1344F7; Thu, 3 Mar 2022 04:28:01 -0800 (PST) Date: Thu, 03 Mar 2022 12:27:37 +0000 From: Paul Cercueil Subject: RE: [PATCH v3] serial: make uart_console_write->putchar()'s character an unsigned char To: David Laight Cc: "'Maciej W. Rozycki'" , Jiri Slaby , 'Uwe =?iso-8859-1?q?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 , Andreas =?iso-8859-1?q?F=E4rber?= Message-Id: <1A568R.RVXRB53P9YYQ1@crapouillou.net> In-Reply-To: <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> <9fa84690ed244eba89f1efe4e6670f80@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David, Le jeu., mars 3 2022 at 11:44:42 +0000, David Laight a ?crit : > 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. That's incorrect. The C standard does say that "the implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char". C 'char' is signed on x86 (and MIPS and Sparc etc.). It is unsigned on ARM, PowerPC and Risc-V among others. > 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'.) Is the putchar() callback ever going to be called with EOF? I don't think so. > 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. We're talking about Linux here. Ints are 32-bit. Cheers, -Paul