Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4569864rwi; Sat, 22 Oct 2022 12:15:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6fR0pNV4czx5zygbEJ/ZuaLWwbGG1phmYrhizrXXjIuXsLHJpjuOVFvhxh3YFfkzfVrOhN X-Received: by 2002:a05:6402:2402:b0:45c:a1ce:94d8 with SMTP id t2-20020a056402240200b0045ca1ce94d8mr22756197eda.50.1666466139099; Sat, 22 Oct 2022 12:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666466139; cv=none; d=google.com; s=arc-20160816; b=nne7nc7tFlc/eTlbR8Np4y5jiTbdU4WYxjT2cVuKio9aKE0/wTZKIHcgxeZhsy0XTt U4Lwgti7nbUbsC6aUrIcc9ezv/zBgUftR2nCYe1hW+9xBLmpxmoVlQr6pgcVQdxhXfoK zuackmnSIXh6ELuM6g5wUfCv5xYXpek6zXaTLxzY9/f2zy6tzcvW6tGAkSgDzA9bhswO Dq65LptJbCUOx5t/FIE+OgUpyL1ObIUnOJipzS35vaOlgV64TYlY+OLJ92nbaDVeIVfS c8CoVKA3RpgHDkx9Stb4v/Vjb8Vw/2gWtECXHw/1Yv3Go1yK1lrfagEWXNkLRT/Wu/+Q jz/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8d0KCdG35QJgPzxY2PI5qF4wSDq+As804wur+n4mrk0=; b=GrlrTM+3STqWyQF+79FDbcPhKn4oNOAW5URTZOAkk8iBd2zJwU/SxiBhHF5Ubdn7SA N9LzGE+a6MeWdY2V+MJf9JUx0EWm0AJgVKIDrB1hNKecGnmgAEIZn0L6695OFtBxOlJZ d125XnqhmNmQt71pDs9nHSwNKzgVTkydZsc5MWJSckW/SIa5/CGjeR4l1MBdElLESU+E ozi3OJ2EP2IGdcPZDlH01xCdH1ITmOBhztLCfuZ7KXX5dck9jE7K3JJ59vBKYboeTipO ZlTtLJaOn59EZFgskqWFXuby29z/pfIGPKKki2gKQ1acbPKk1ZSyfFW6NgvKipU2vsb0 vY4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Dlapqk7u; 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 nc23-20020a1709071c1700b00783a0e64f86si27053301ejc.7.2022.10.22.12.15.14; Sat, 22 Oct 2022 12:15:39 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Dlapqk7u; 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 S229738AbiJVSQ4 (ORCPT + 99 others); Sat, 22 Oct 2022 14:16:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229711AbiJVSQy (ORCPT ); Sat, 22 Oct 2022 14:16:54 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86C27EA9EC for ; Sat, 22 Oct 2022 11:16:51 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id c23so3532081qtw.8 for ; Sat, 22 Oct 2022 11:16:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8d0KCdG35QJgPzxY2PI5qF4wSDq+As804wur+n4mrk0=; b=Dlapqk7u3r5R+hK/Sg/KWPsYs7tfU6S9C02brY3SkmFAMIHHhptUQoMcR3/b7mTkYi MbJkeUIbDnrtnp02J3XF1lFi4YRuFRnn+UlALHdVhdPTVUv7JgEC44f9h8+dASuHGJac gfstM1uSAC+JNHVJYDEwl7uW6MEu4hiaC10EI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8d0KCdG35QJgPzxY2PI5qF4wSDq+As804wur+n4mrk0=; b=PCTu5TwNNRsR6/SoN0o+i7KvKbwJtcNLZYlxpONcrRiO2mgrlbX1y2p2bL0JEH9uPh 3P6RIg/KBziFCxlDmEVFDEO0SlA/rtz1tA5LKOYcHeySJIiTfLL5yG+B6PdJLBmriMVg oMfuHxT3wj/dA8bRavlWVeR7bnG3W3nGhTNaJg38KQv9H1wsaFtv2Bg9z60gpp1qMUYT k8DGHwp8lAw/Z8wg7ToWAjwjQCxHLYEPyvpmTaX7+9iquu8YimbZ/7w5M7IVChW+MTqa fGbNoAYMvGzR9oEtBFOT+8z2TlXfeZS37pqENBSL2s5P08c6A3uwUT8rbiSirbAhWzsI HQWA== X-Gm-Message-State: ACrzQf3JjTbKjKtTyU/biTrHTofDAN/3uxGme7S2UlHl1CI4fvNQ/1Z6 NCTM6yfTvVF06035cVMYNhwo8aYf3WkZTg== X-Received: by 2002:a05:622a:1a9f:b0:39c:ae32:9f7f with SMTP id s31-20020a05622a1a9f00b0039cae329f7fmr22339305qtc.80.1666462610374; Sat, 22 Oct 2022 11:16:50 -0700 (PDT) Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com. [209.85.128.182]) by smtp.gmail.com with ESMTPSA id he7-20020a05622a600700b003972790deb9sm9938331qtb.84.2022.10.22.11.16.49 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 22 Oct 2022 11:16:49 -0700 (PDT) Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-369426664f9so51761737b3.12 for ; Sat, 22 Oct 2022 11:16:49 -0700 (PDT) X-Received: by 2002:a81:11d0:0:b0:35b:dd9f:5358 with SMTP id 199-20020a8111d0000000b0035bdd9f5358mr22201031ywr.401.1666462609310; Sat, 22 Oct 2022 11:16:49 -0700 (PDT) MIME-Version: 1.0 References: <20221019162648.3557490-1-Jason@zx2c4.com> <20221019165455.GL25951@gate.crashing.org> <20221019174345.GM25951@gate.crashing.org> In-Reply-To: From: Linus Torvalds Date: Sat, 22 Oct 2022 11:16:33 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] kbuild: treat char as always signed To: Gabriel Paubert Cc: Segher Boessenkool , "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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no 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 Fri, Oct 21, 2022 at 11:06 PM Gabriel Paubert wrote: > > Ok, I=C2=B4ve just tried it, except that I had something slightly differe= nt in > mind, but perhaps should have been clearer in my first post. > > I have change your code to the following: I actually tested that, but using a slightly different version, and my non-union test case ended up like size_t strlen(const char *p) { return __builtin_strlen(p); } and then gcc actually complains about warning: infinite recursion detected and I (incorrectly) thought this was unworkable. But your version seems to work fine. So yeah, for the kernel I think we could do something like this. It's ugly, but it gets rid of the crazy warning. Practically speaking this might be a bit painful, because we've got several different variations of this all due to all the things like our debugging versions (see for example), so some of our code is this crazy jungle of "with this config, use this wrapper". But if somebody wants to deal with the '-Wpointer-sign' warnings, there does seem to be a way out. Maybe with another set of helper macros, creating those odd __transparent_union__ wrappers might even end up reasonable. It's not like we don't have crazy macros for function wrappers elsewhere (the SYSCALL macros come to mind - shudder). The macros themselves may be a nasty horror, but when done right the _use_ point of said macros can be nice and clean. Linus