Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1762917rwi; Wed, 19 Oct 2022 15:14:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6bviStlEu8DfaBq4SGEn4g5/WWK7WK91wMt7j3l3vNX0lexLoFhvlIYzUKljucKryJELB3 X-Received: by 2002:a05:6402:2d8:b0:458:c152:67bd with SMTP id b24-20020a05640202d800b00458c15267bdmr9447998edx.308.1666217653501; Wed, 19 Oct 2022 15:14:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666217653; cv=none; d=google.com; s=arc-20160816; b=geoR2A5D6hV+4plVqPWu8fG0+Gj+2IbIPnN8gpRH2XdwNtOdT8odMZ7EMl72iDfD80 /cQBpfanqIksdj46YudPybRgy+5VAC7q7AR4UVZQQT5uZ8z8VXtJELvV6fBj7cxev43b s2/TijQbDGoFQ6V8OOKBHID4v5WpFrAij3sUV+EIdMGbL/q81pcaJoHqOk4os/5zcohC OYopyQeZ0NYObHXxPKZdbICaObZiB6DQwn49k2IHupj6iQe7lKucuOtcOIwc+ORNdpQR cBCUs8HdmlgabxNQpScyS10VV7zZko6mMoVnsLlzM1J7uZdei8DSUswPaijBuXx4dWd1 uxYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=YfIprOkje3qn9uc+U0PUM6cjFKP6TFuCiPDGQ0kiDNo=; b=qeeNFTAMF3Y2O3cjeWrvOmHqbBwL3f9mugURDktxnH6f4uVz3DODNrk6Y41NI4pKiJ ElqgEB4lyejVPZf7ImDbLYYtwgHN83PCB2ZAbi72Zx57iDNu3zhn/YD+ik+DhozZ/Fgv WePnCxZtFYgW/Pz1yP1wdY4N6zh6ikIPu6L6bSfqp4O+OQwsFmO8PH3E/ScWBIlMtZJ7 x1ilSVOjHbyw65ldU69rKljYgQ8C3dA15EooZbv9ZAL0lkXqgK0PbaGmPrR6QIcYW4E4 +/Xfd2jzK4IwJl2y8Di9ZGxWUHXlYgfJDsMSeDCxiIUpYMuVk0ceR0zN6i9uD+meFbxI dEyA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a170906698400b00783d969f318si13690302ejr.253.2022.10.19.15.12.51; Wed, 19 Oct 2022 15:14:13 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230343AbiJSV3u (ORCPT + 99 others); Wed, 19 Oct 2022 17:29:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbiJSV3q (ORCPT ); Wed, 19 Oct 2022 17:29:46 -0400 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E6B1B44544; Wed, 19 Oct 2022 14:29:43 -0700 (PDT) Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 29JLQXd0021146; Wed, 19 Oct 2022 16:26:33 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 29JLQV9c021145; Wed, 19 Oct 2022 16:26:31 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 19 Oct 2022 16:26:31 -0500 From: Segher Boessenkool To: David Laight Cc: "'Linus Torvalds'" , "Jason A. Donenfeld" , "linux-kernel@vger.kernel.org" , "linux-kbuild@vger.kernel.org" , "linux-arch@vger.kernel.org" , "linux-toolchains@vger.kernel.org" , Masahiro Yamada , Kees Cook , Andrew Morton , Andy Shevchenko , Greg Kroah-Hartman Subject: Re: [PATCH] kbuild: treat char as always signed Message-ID: <20221019212631.GR25951@gate.crashing.org> References: <20221019162648.3557490-1-Jason@zx2c4.com> <20221019165455.GL25951@gate.crashing.org> <20221019174345.GM25951@gate.crashing.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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 On Wed, Oct 19, 2022 at 09:07:01PM +0000, David Laight wrote: > From: Linus Torvalds > > Sent: 19 October 2022 19:11 > > Explicit casts are bad (unless, of course, you are explicitly trying > > to violate the type system, when they are both required, and a great > > way to say "look, I'm doing something dangerous"). > Casts really ought to be rare. Sometimes you need casts for *data*, like where you write (u32)smth because you really want the low 32 bits of that something. That only happens in some kinds of code -- multi-precision integer, some crypto, serialisation primitives. You often want casts for varargs, too. The alternative is to make very certain some other way that the actual arguments will have the correct type, but that is often awkward to do, and not as clear to read. Pointer casts are almost always a mistake. If you think you want one you are almost always wrong. Segher