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 A19DCC433FE for ; Wed, 19 Oct 2022 20:23:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231325AbiJSUXY (ORCPT ); Wed, 19 Oct 2022 16:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbiJSUXT (ORCPT ); Wed, 19 Oct 2022 16:23:19 -0400 Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 67D0D1C25FF; Wed, 19 Oct 2022 13:23:16 -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 29JKFhWg016370; Wed, 19 Oct 2022 15:15:43 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 29JKFgLV016366; Wed, 19 Oct 2022 15:15:42 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 19 Oct 2022 15:15:42 -0500 From: Segher Boessenkool To: Linus Torvalds Cc: Nick Desaulniers , "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: <20221019201542.GN25951@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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Wed, Oct 19, 2022 at 11:56:00AM -0700, Linus Torvalds wrote: > After fixing fortify-string.h to not complain (which was indeed about > strlen() signedness), it turns out a lot were still about 'char', but > not necessarily the functions. > > We use 'unsigned char *' for our dentry data, for example, and then you get > > warning: pointer targets in initialization of ‘const unsigned > char *’ from ‘char *’ differ in signedness > > when you do something like > > QSTR_INIT(NULL_FILE_NAME, > > which is simply doing a regular initializer assignment, and wants to > assign a constant string (in this case the constant string "null") to > that "const unsigned char *name". It cannot see that all users of this are okay with ignoring the difference. > That's certainly another example of "why the heck did the compiler > warn about that thing". Because this is a simple warning. It did exactly what it is supposed to -- you are mixing "char" and "unsigned char" here, and in some cases that matters hugely. > You can literally try to compile this one-liner with gcc: > > const unsigned char *c = "p"; > > and it will complain. What a hugely pointless warning. Yes, there are corner cases like this. Please open a PR if you want this fixed. It is UB to (try to) modify string literals (since they can be shared for example), but still they have type "array of (plain) char". This is historical :-/ Segher