Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp4106584pxm; Tue, 1 Mar 2022 11:21:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRJuzdKpp5+3OkgPuw6ALAUh53gq9BC0uhk5+A0EFSZawVNza1sjBEn1HbsUvHkIhxfSuD X-Received: by 2002:a05:6a00:885:b0:4f4:17d8:be31 with SMTP id q5-20020a056a00088500b004f417d8be31mr10078015pfj.57.1646162477359; Tue, 01 Mar 2022 11:21:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646162477; cv=none; d=google.com; s=arc-20160816; b=uUvDGaTyMTiGGeZfIpV9IivyZzimSC6YFXSdmq5P7YTXwhphD11BrptNOjf4xiX4jo vKigA3PzSP0OkcuWqfIhECR3KDZZ99KrdHp9CMZ4rBKvEOyIFdDn9cdrxEUw+YHFcQy0 TmpAHTCpWr8/PFgwxIk/PhSQUiWZ+5SEP/Sr0/I4ykXTu7IqM0X0gVNqBCuFT1tllBp3 C+kFpwtAEJ83p1yUaiQq2X7JeQkr84pNp4YbYyTJphBxAqzSiNkBJ5er9X6/aVZ7+kve mDee8EkPMTY65CDwMLxDpd8gt+/GgNjgGPmO3+GP37lMvzGcZVmteW+JCrftLGaUzuNd GNxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=JZw99KMpsKBs3Ab/LBNeIPMebXALTITXobBfJpN/EsI=; b=kMLx4PokVAxNyWYD16CQu+syKacdAHPPFIUqNXcCQpGWFPjFmOqQo4pJpq/rfondNe Vt4ojqlg+3+SSORzu0Ol88nLAXX7v16g4Y4TSgh4RW8C10wTRxzJuqovGCY1MSpIUVLh FGl33XxONXIsRj5ts83EhxXBxiw1zDb00HE2UyCPAKEVbQYuwUMo2iEzzofXcnto+mA9 r9+XFJHyUT8UEtcVzgfBOwS6ToU9bvFggPWBQwCnqZzp7RxISJoN2+EbRzEaqw5qKysC TNo2pLora/nU9MrGMpdojQceEA3LhkankD5c/OaJbUcKV0DuPTSvf35/rfeyqsgecqxf k/PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=ZEWbFFu3; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 j1-20020a63e741000000b003731be9e343si13677220pgk.380.2022.03.01.11.21.01; Tue, 01 Mar 2022 11:21:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-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=ZEWbFFu3; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234402AbiCASsa (ORCPT + 72 others); Tue, 1 Mar 2022 13:48:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234637AbiCASs3 (ORCPT ); Tue, 1 Mar 2022 13:48:29 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 716192458D for ; Tue, 1 Mar 2022 10:47:45 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id x5so23212095edd.11 for ; Tue, 01 Mar 2022 10:47:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=JZw99KMpsKBs3Ab/LBNeIPMebXALTITXobBfJpN/EsI=; b=ZEWbFFu3eWrZxUgaaScwD4ZJ//Z7mV4SGMyACB20WwCKEMFGKIBMMEXVkM4kZXdOyd EokMKBVyAcoYChV/SvtOh5q5h0Yafm3wlsC3jCGOeoM0h4pn550KTbE+/sUn3z3m8p0V ZL0gG9ZTrYCOlyUURTCDAGrluijISoqXbB1wA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=JZw99KMpsKBs3Ab/LBNeIPMebXALTITXobBfJpN/EsI=; b=PAxCk1WcyQhsjLl1RSOy8yqT3mrMxVOb5k6XlBfhEVKTOZIptFRwjLtLEKwCeUpX/c Gwdv7Qx81j5LhF2YKaML7Cf0+18MQzLCEb2oJqN4FsDFnodKjX927+RDhf6Hnr6LcSrO IKOiYshN5FujPYFzEkurug0BANYP/wmjOhLIBRjESlhGMNVignF6Ko3NkjnyuHfo7tON ItCpDlGvODkM6ygyohYjaze0cvH7x0hA4S1FBr2MAqWqHj3RV7neS4Wk7IuYSKePUUyu EO7X2Q2MUv3QYOXrqQQigSHVVzB/uA1wbEMapHuZAG63OHvwaOHyGh64krau7UUS84ZQ WL8Q== X-Gm-Message-State: AOAM530QYQdjyC7RcDzPZtRnSN0pCJ3378xLVBfAATKS268yEeWH6t9u 8Kf3Y9BATMnXFIAih6RvfhxWs1MVe/fJWyq8eV0= X-Received: by 2002:a05:6402:27c7:b0:412:80f9:18af with SMTP id c7-20020a05640227c700b0041280f918afmr25819932ede.127.1646160463737; Tue, 01 Mar 2022 10:47:43 -0800 (PST) Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com. [209.85.218.47]) by smtp.gmail.com with ESMTPSA id my14-20020a1709065a4e00b006be97e14e5csm5550889ejc.95.2022.03.01.10.47.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Mar 2022 10:47:43 -0800 (PST) Received: by mail-ej1-f47.google.com with SMTP id r13so33348974ejd.5 for ; Tue, 01 Mar 2022 10:47:41 -0800 (PST) X-Received: by 2002:a05:6512:2033:b0:443:3d49:dac with SMTP id s19-20020a056512203300b004433d490dacmr16440784lfs.52.1646160451271; Tue, 01 Mar 2022 10:47:31 -0800 (PST) MIME-Version: 1.0 References: <20220228110822.491923-1-jakobkoschel@gmail.com> <20220228110822.491923-3-jakobkoschel@gmail.com> <2e4e95d6-f6c9-a188-e1cd-b1eae465562a@amd.com> <202203011008.AA0B5A2D@keescook> In-Reply-To: <202203011008.AA0B5A2D@keescook> From: Linus Torvalds Date: Tue, 1 Mar 2022 10:47:14 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr To: Kees Cook Cc: Matthew Wilcox , =?UTF-8?Q?Christian_K=C3=B6nig?= , Jakob Koschel , alsa-devel@alsa-project.org, linux-aspeed@lists.ozlabs.org, "Gustavo A. R. Silva" , linux-iio@vger.kernel.org, nouveau@lists.freedesktop.org, Rasmus Villemoes , dri-devel , Cristiano Giuffrida , amd-gfx list , samba-technical@lists.samba.org, linux1394-devel@lists.sourceforge.net, drbd-dev@lists.linbit.com, linux-arch , CIFS , KVM list , linux-scsi , linux-rdma , linux-staging@lists.linux.dev, "Bos, H.J." , Jason Gunthorpe , intel-wired-lan@lists.osuosl.org, kgdb-bugreport@lists.sourceforge.net, bcm-kernel-feedback-list@broadcom.com, Dan Carpenter , Linux Media Mailing List , Arnd Bergman , Linux PM , intel-gfx , Brian Johannesmeyer , Nathan Chancellor , linux-fsdevel , Christophe JAILLET , v9fs-developer@lists.sourceforge.net, linux-tegra , Thomas Gleixner , Andy Shevchenko , Linux ARM , linux-sgx@vger.kernel.org, linux-block , Netdev , linux-usb@vger.kernel.org, linux-wireless , Linux Kernel Mailing List , Linux F2FS Dev Mailing List , tipc-discussion@lists.sourceforge.net, Linux Crypto Mailing List , dma , linux-mediatek@lists.infradead.org, Andrew Morton , linuxppc-dev , Mike Rapoport Content-Type: text/plain; charset="UTF-8" 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,T_SCC_BODY_TEXT_LINE 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-wireless@vger.kernel.org On Tue, Mar 1, 2022 at 10:14 AM Kees Cook wrote: > > The first big glitch with -Wshadow was with shadowed global variables. > GCC 4.8 fixed that, but it still yells about shadowed functions. What > _almost_ works is -Wshadow=local. Heh. Yeah, I just have long memories of "-Wshadow was a disaster". You looked into the details. > Another way to try to catch misused shadow variables is > -Wunused-but-set-varible, but it, too, has tons of false positives. That on the face of it should be an easy warning to get technically right for a compiler. So I assume the "false positives" are simply because we end up having various variables that really don't end up being used - and "intentionally" so). Or rather, they might only be used under some config option - perhaps the use is even syntactically there and parsed, but the compiler notices that it's turned off under some if (IS_ENABLED(..)) option? Because yeah, we have a lot of those. I think that's a common theme with a lot of compiler warnings: on the face of it they sound "obviously sane" and nobody should ever write code like that. A conditional that is always true? Sounds idiotic, and sounds like a reasonable thing for a compiler to warn about, since why would you have a conditional in the first place for that? But then you realize that maybe the conditional is a build config option, and "always true" suddenly makes sense. Or it's a test for something that is always true on _that_architecture_ but not in some general sense (ie testing "sizeof()"). Or it's a purely syntactic conditional, like "do { } while (0)". It's why I'm often so down on a lot of the odd warnings that are hiding under W=1 and friends. They all may make sense in the trivial case ("That is insane") but then in the end they happen for sane code. And yeah, -Wshadow has had tons of history with macro nesting, and just being badly done in the first place (eg "strlen" can be a perfectly fine local variable). That said, maybe people could ask the gcc and clan people for a way to _mark_ the places where we expect to validly see shadowing. For example, that "local variable in a macro expression statement" thing is absolutely horrendous to fix with preprocessor tricks to try to make for unique identifiers. But I think it would be much more syntactically reasonable to add (for example) a "shadow" attribute to such a variable exactly to tell the compiler "yeah, yeah, I know this identifier could shadow an outer one" and turn it off that way. Linus