Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp4126815pxm; Tue, 1 Mar 2022 11:49:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMKECcDVOVSYfri3fZr97b1I6YCffZB5U8lg+W8G95bQUzQNVg8UAWLbKlFlNAhhLC8uR8 X-Received: by 2002:a17:906:e218:b0:6cf:7483:36c8 with SMTP id gf24-20020a170906e21800b006cf748336c8mr19847237ejb.747.1646164159044; Tue, 01 Mar 2022 11:49:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646164159; cv=none; d=google.com; s=arc-20160816; b=pK7tnEX+XhnXQFQgWMCRJ2XUHz8IWIk5IBzkF32U1RrmCtF8n7UQqaXq9b7X0gHjiG 2/EYGhI48FGiKzagH+Jad4r1Mv7wwl2eE64ImI9nA3MUcfzv2Q0+1QK5JWYwB7pc/8jB XPNPNgvOGqM1o9r0pvxYi+x6Q+i06uXCzuxaNGgZC2JmbPp4n5do6XBN1ZXc8OdIB0Lb wKmJndtoQqFikiZWT3MSbc3caRHxPFfeYEpaKGQSErR92PekC9/MOIeYypCqAtl/Z4tz zjFJrNEzWruwWf9GuVYQHoAlp7a3iK4a6daFOTx5F7P9owCFk6Gk2Di/Vvx7JPlHockD KoQg== 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=+FYbGAw6yxU17iUDUp61Ry7f+ZSO9wN0ehJ+hGfk2DQ=; b=IrvjwhRor47P/sG7i8rX9JRRrIcHS07LPJcPesdutxwmserFXeUicezvzPHURph/e+ Op/taqz+yhrfRolWegVwAObdngMze4CYTR9BT/yaigRCAz7/6I3jJ8z1CW4ZljoE7MK+ xulRp9XwQUHZ6/ITaHbtmUps8MF+gMOK43pZ+k+xPbOdATqLiREYTMF3V6d110pozwmR ymGZjhFKLaZcZb5TLtP+2zNhcqK08Wti8WiXfLSAZwdsou4e0y5bGa4q55NHDMwXd8eZ IspDJMBdH1LmBcaNCxlqfzw1BfozF3eCxgllJvDG6IhIVer1vpwaaR6meyJYSAX+7DLN ImEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=NEmpYuhx; 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 vz5-20020a17090704c500b006cf0dd8c608si7581310ejb.53.2022.03.01.11.49.00; Tue, 01 Mar 2022 11:49:19 -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=NEmpYuhx; 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 S229873AbiCATH7 (ORCPT + 72 others); Tue, 1 Mar 2022 14:07:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbiCATH6 (ORCPT ); Tue, 1 Mar 2022 14:07:58 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CA1C66C99 for ; Tue, 1 Mar 2022 11:07:17 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id t13so16513085lfd.9 for ; Tue, 01 Mar 2022 11:07:16 -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=+FYbGAw6yxU17iUDUp61Ry7f+ZSO9wN0ehJ+hGfk2DQ=; b=NEmpYuhxkY3jphhiKwB9rL7CFHETV0OarciDwH/Y25b8gogpFDGLbcsm2Hp5JlhbRM fgLdNaX0z1k1bpDTdAa2T+xhPoQGBlkWInAyVtxomjmoWydKKz6S1Vw5P8QyPxUNcXPG O8s4ZVUjpR1ZVkG2oqZOMI9ApgRXI/RsyC5iE= 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=+FYbGAw6yxU17iUDUp61Ry7f+ZSO9wN0ehJ+hGfk2DQ=; b=DaX2g/HT9zO7PsW2mGC6UI2b+U+8jGP8Ii1a15NdLSjqLezoXxns2V+ueL2XMB0WGu rrfeZ7+vQMcU9lHEReJw+QpzVnMtiC9JK+D4kIjUJlOu3nxdE+LkZAVq1ZRDMeliMm1s aEqrVl6VrwnWT6a8IQoC1xiVFyz7LmihQFMMiEV2o6UMfVWhRHyIQczSsjeguBg8AgSH Nb1Uw6vk5jHKw07kGm9WovnBHRnyLxQHY3okh/EuRsKE4gJepR7j11S00UNEjbLIniFt +2dzHJn2ZVZ2DOVIIYQVZVz75AKClaHVEga37jRhsph6EmpmEfRgIucxXMnSszsGbTcz akaw== X-Gm-Message-State: AOAM533jqNSfK2RO1PC70xtvS1y3ePnCLZiWJyzF0D2qGNi1q3wEe7Se KoWGZH4b5ZnuZk982onOspPLcrTDiMQ6K+zMbDM= X-Received: by 2002:ac2:4f03:0:b0:443:5d9d:819d with SMTP id k3-20020ac24f03000000b004435d9d819dmr16014803lfr.165.1646161634617; Tue, 01 Mar 2022 11:07:14 -0800 (PST) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com. [209.85.167.48]) by smtp.gmail.com with ESMTPSA id u9-20020ac251c9000000b00443dc755dfdsm1625727lfm.215.2022.03.01.11.07.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Mar 2022 11:07:14 -0800 (PST) Received: by mail-lf1-f48.google.com with SMTP id t13so16512955lfd.9 for ; Tue, 01 Mar 2022 11:07:13 -0800 (PST) X-Received: by 2002:a2e:3013:0:b0:246:2ca9:365e with SMTP id w19-20020a2e3013000000b002462ca9365emr17902580ljw.291.1646161622598; Tue, 01 Mar 2022 11:07:02 -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> <282f0f8d-f491-26fc-6ae0-604b367a5a1a@amd.com> <7D0C2A5D-500E-4F38-AD0C-A76E132A390E@kernel.org> <73fa82a20910c06784be2352a655acc59e9942ea.camel@HansenPartnership.com> In-Reply-To: <73fa82a20910c06784be2352a655acc59e9942ea.camel@HansenPartnership.com> From: Linus Torvalds Date: Tue, 1 Mar 2022 11:06:45 -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: James Bottomley Cc: Mike Rapoport , =?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 , Kees Cook , 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 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 Mon, Feb 28, 2022 at 2:29 PM James Bottomley wrote: > > However, if the desire is really to poison the loop variable then we > can do > > #define list_for_each_entry(pos, head, member) \ > for (pos = list_first_entry(head, typeof(*pos), member); \ > !list_entry_is_head(pos, head, member) && ((pos = NULL) == NULL; \ > pos = list_next_entry(pos, member)) > > Which would at least set pos to NULL when the loop completes. That would actually have been excellent if we had done that originally. It would not only avoid the stale and incorrectly typed head entry left-over turd, it would also have made it very easy to test for "did I find an entry in the loop". But I don't much like it in the situation we are now. Why? Mainly because it basically changes the semantics of the loop _without_ any warnings about it. And we don't actually get the advantage of the nicer semantics, because we can't actually make code do list_for_each_entry(entry, ....) { .. } if (!entry) return -ESRCH; .. use the entry we found .. because that would be a disaster for back-porting, plus it would be a flag-day issue (ie we'd have to change the semantics of the loop at the same time we change every single user). So instead of that simple "if (!entry)", we'd effectively have to continue to use something that still works with the old world order (ie that "if (list_entry_is_head())" model). So we couldn't really take _advantage_ of the nicer semantics, and we'd not even get a warning if somebody does it wrong - the code would just silently do the wrong thing. IOW: I don't think you are wrong about that patch: it would solve the problem that Jakob wants to solve, and it would have absolutely been much better if we had done this from the beginning. But I think that in our current situation, it's actually a really fragile solution to the "don't do that then" problem we have. Linus