Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3159585pxm; Mon, 28 Feb 2022 13:22:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzTPuqWjgcw8Oinu7o0GNwi6hlJNRk60fm5k/fEAemBa0ovSgIxtnpA4kb3gz1yYmooP8qP X-Received: by 2002:a17:906:251b:b0:6d6:e258:fe1a with SMTP id i27-20020a170906251b00b006d6e258fe1amr1131781ejb.57.1646083322646; Mon, 28 Feb 2022 13:22:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646083322; cv=none; d=google.com; s=arc-20160816; b=c5+1VF3sqxn6NehgHrTY3s4msB6cqrbyeodA655zvDiWhgQS9WPygjC8tpPFwWroGa 3y65tGIqS9Dpq8d9sryXEzfo4boB6rR9nz0xbeMocBF+iHeWJDCEB0W5MFHgbyTU0JJY wkm08ude8a/izReuDi/e3L4n+tcevMb4AyT8GoFku533z9U4kjnpm1v8+GmPIh+gPybJ IQVtVqIdNIDpPb9GBeLTNMj0KZMz4PfCZiOBilDpvRG95MoogvahvY/GkTrtIW7EE7zK 77ynwbHK+pjh1Y+xuGlO5scA9DTL37dEbR36MslXKtUCRohs3KWIffcPmi6gWtQF+2pq 9a9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature:dkim-signature; bh=DMdmQLcnQOso2RHEeaXgMapK5SwSrUn8V5ej00D4dXY=; b=WJpyoVziW4lNKvoR6HlV/JhJ/HXQ/D9hEkHuwe7L6LPonJIwL5gA0OEemgskGiJUpL 5WSfCXTZ6Z1jtVLmE/eSZGXD3fKxTIgsbdYE9fbblR0qmyihrBM+2+fkgue2BOlvn85S tGdbLuGP1CY/uDn4bTyJ0mrN2ixMP/dBee1te/pxootZ1m29BvI/tmE9V0xEgepBF4+b tFEZm3PyOzRikzsWm16UIsScVbD6gwCYWd86qc5XgCq9/sTUOaPBiF/iwKyerGrJZMV3 IfwmqrMyd7lepqmIAg8ueSAt4EIHWfHT9tJqxmenITBc76isq1dUHSOZ7YJwHD4ytNIn gQxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=fTQp+HhE; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=fTQp+HhE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d6-20020aa7c1c6000000b00410cebf6e6fsi1321725edp.44.2022.02.28.13.21.41; Mon, 28 Feb 2022 13:22:02 -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=@hansenpartnership.com header.s=20151216 header.b=fTQp+HhE; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=fTQp+HhE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230162AbiB1VOE (ORCPT + 72 others); Mon, 28 Feb 2022 16:14:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230104AbiB1VN5 (ORCPT ); Mon, 28 Feb 2022 16:13:57 -0500 Received: from bedivere.hansenpartnership.com (bedivere.hansenpartnership.com [IPv6:2607:fcd0:100:8a00::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6021ECC41; Mon, 28 Feb 2022 13:13:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1646082795; bh=b0jOc0WDOwLaR9eob939Fu/T9iRVE4QNy1gcUuEgORI=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=fTQp+HhEyDWfdTRw9MD74D4dNoy4lJbDD6ufhn8pOCgDG9LKN5I5E2XfQsXuEnTyE o41BjR/wB9Zx796mcVO5HItpPdbUBqFA5gZFvpxw0W0+8SaIBYecaW0t63X4w0ysYd Uxmzs2O4chqjQ5mD0m0R9/q9wYnJ2eru8WGs04Zw= Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id EE6F612811CE; Mon, 28 Feb 2022 16:13:15 -0500 (EST) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fdilm1jMyJ2v; Mon, 28 Feb 2022 16:13:15 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1646082795; bh=b0jOc0WDOwLaR9eob939Fu/T9iRVE4QNy1gcUuEgORI=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=fTQp+HhEyDWfdTRw9MD74D4dNoy4lJbDD6ufhn8pOCgDG9LKN5I5E2XfQsXuEnTyE o41BjR/wB9Zx796mcVO5HItpPdbUBqFA5gZFvpxw0W0+8SaIBYecaW0t63X4w0ysYd Uxmzs2O4chqjQ5mD0m0R9/q9wYnJ2eru8WGs04Zw= Received: from jarvis.int.hansenpartnership.com (unknown [IPv6:2601:5c4:4300:c551::527]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 980CE1280320; Mon, 28 Feb 2022 16:13:11 -0500 (EST) Message-ID: Subject: Re: [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr From: James Bottomley To: Christian =?ISO-8859-1?Q?K=F6nig?= , Linus Torvalds Cc: 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 , Mike Rapoport Date: Mon, 28 Feb 2022 16:13:09 -0500 In-Reply-To: <0b65541a-3da7-dc35-690a-0ada75b0adae@amd.com> 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> <0b65541a-3da7-dc35-690a-0ada75b0adae@amd.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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, 2022-02-28 at 21:56 +0100, Christian König wrote: > > Am 28.02.22 um 21:42 schrieb James Bottomley: > > On Mon, 2022-02-28 at 21:07 +0100, Christian König wrote: > > > Am 28.02.22 um 20:56 schrieb Linus Torvalds: > > > > On Mon, Feb 28, 2022 at 4:19 AM Christian König > > > > wrote: > > > > [SNIP] > > > > Anybody have any ideas? > > > I think we should look at the use cases why code is touching > > > (pos) > > > after the loop. > > > > > > Just from skimming over the patches to change this and experience > > > with the drivers/subsystems I help to maintain I think the > > > primary pattern looks something like this: > > > > > > list_for_each_entry(entry, head, member) { > > > if (some_condition_checking(entry)) > > > break; > > > } > > > do_something_with(entry); > > > > Actually, we usually have a check to see if the loop found > > anything, but in that case it should something like > > > > if (list_entry_is_head(entry, head, member)) { > > return with error; > > } > > do_somethin_with(entry); > > > > Suffice? The list_entry_is_head() macro is designed to cope with > > the bogus entry on head problem. > > That will work and is also what people already do. > > The key problem is that we let people do the same thing over and > over again with slightly different implementations. > > Out in the wild I've seen at least using a separate variable, using > a bool to indicate that something was found and just assuming that > the list has an entry. > > The last case is bogus and basically what can break badly. Yes, I understand that. I'm saying we should replace that bogus checks of entry->something against some_value loop termination condition with the list_entry_is_head() macro. That should be a one line and fairly mechanical change rather than the explosion of code changes we seem to have in the patch series. James