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 316D4C433FE for ; Sat, 22 Oct 2022 18:17:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229667AbiJVSQ7 (ORCPT ); Sat, 22 Oct 2022 14:16:59 -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-Google-Smtp-Source: AMsMyM5PC3WBTqR1sNuvu9Sr/3bPDtoW/6RHkFw9Ui+q21fvjeLccF0k/+ebJ6twzKxHQn1ucZtKXQ== 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 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