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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5989C433EF for ; Sun, 6 Mar 2022 14:34:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBC676B0071; Sun, 6 Mar 2022 09:34:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D6AE66B0072; Sun, 6 Mar 2022 09:34:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C326E6B0073; Sun, 6 Mar 2022 09:34:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id B04DB6B0071 for ; Sun, 6 Mar 2022 09:34:01 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7AB2D216B9 for ; Sun, 6 Mar 2022 14:34:01 +0000 (UTC) X-FDA: 79214205882.11.D41EBCA Received: from bedivere.hansenpartnership.com (bedivere.hansenpartnership.com [96.44.175.130]) by imf02.hostedemail.com (Postfix) with ESMTP id A15E28000E for ; Sun, 6 Mar 2022 14:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1646577238; bh=gj0xg4o/jelATStNvl7Ejbgin7X2OTavQUPcfcC0oOg=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=rWOQ0+Od8Jzq6RvBnjveKNMh+2TMiuJNWeZIXQ/i60V95Hcn3LcbppE+z2qn/kYT4 bbCkNG9niKu4vUi2QSZwZuKf+HePVYZ9XBidq8241PGwJBnHigQon3oR8waHNO2ikD flc4g5yehg4vACix+Fl6uZb7S+AJmRkR+E1DvlaY= Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id CE7D7128111C; Sun, 6 Mar 2022 09:33:58 -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 Ic5liuxIESJe; Sun, 6 Mar 2022 09:33:58 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1646577238; bh=gj0xg4o/jelATStNvl7Ejbgin7X2OTavQUPcfcC0oOg=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=rWOQ0+Od8Jzq6RvBnjveKNMh+2TMiuJNWeZIXQ/i60V95Hcn3LcbppE+z2qn/kYT4 bbCkNG9niKu4vUi2QSZwZuKf+HePVYZ9XBidq8241PGwJBnHigQon3oR8waHNO2ikD flc4g5yehg4vACix+Fl6uZb7S+AJmRkR+E1DvlaY= 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) server-digest SHA256) (No client certificate requested) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id B04BD12810DA; Sun, 6 Mar 2022 09:33:57 -0500 (EST) Message-ID: Subject: Re: [PATCH 2/6] list: add new MACROs to make iterator invisiable outside the loop From: James Bottomley To: Xiaomeng Tong Cc: arnd@arndb.de, gregkh@linuxfoundation.org, jakobkoschel@gmail.com, jannh@google.com, keescook@chromium.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, torvalds@linux-foundation.org Date: Sun, 06 Mar 2022 09:33:56 -0500 In-Reply-To: <20220303033122.10028-1-xiam0nd.tong@gmail.com> References: <20220303033122.10028-1-xiam0nd.tong@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.4 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam10 X-Rspam-User: X-Stat-Signature: ahrz4xwjrck3urztyfhgq5kobp4j4qjj Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=hansenpartnership.com header.s=20151216 header.b=rWOQ0+Od; dkim=pass header.d=hansenpartnership.com header.s=20151216 header.b=rWOQ0+Od; spf=pass (imf02.hostedemail.com: domain of James.Bottomley@HansenPartnership.com designates 96.44.175.130 as permitted sender) smtp.mailfrom=James.Bottomley@HansenPartnership.com; dmarc=pass (policy=none) header.from=hansenpartnership.com X-Rspamd-Queue-Id: A15E28000E X-HE-Tag: 1646577240-119150 X-Bogosity: Ham, tests=bogofilter, spamicity=0.014280, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, 2022-03-03 at 11:31 +0800, Xiaomeng Tong wrote: > On Wed, 02 Mar 2022 08:02:23 -0500, James Bottomley > wrote: > > pos shouldn't be an input to the macro since it's being declared > > inside > > it. All that will do will set up confusion about the shadowing of > > pos. > > The macro should still work as > > > > #define list_for_each_entry_inside(type, head, member) \ > > ... > > > > For safety, you could > > > > #define POS __UNIQUE_ID(pos) > > > > and use POS as the loop variable .. you'll have to go through an > > intermediate macro to get it to be stable. There are examples in > > linux/rcupdate.h > > The outer "pos" variable is no longer needed and thus the declare > statement before the loop is removed, see the demostration in PATCH > 3~6. Now, there is only one inner "pos" variable left. Thus, there > should be no such *shadow* problem. So why is pos in the signature of your #define then? Because that means it expands to whatever goes in the first field of list_for_each_entry_inside(). If someone needs to specify a unique name to avoid shadowing an existing variable, then hide pos and use UNIQUE_ID instead was the whole thrust of this comment. James