Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1258641pxp; Sun, 6 Mar 2022 09:51:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzaNqigXAYf9h+/PkVDDtIwiWvRWarhAZgH/QcmBePu162tc8UHkC4AQABNjap8A+NZLEL2 X-Received: by 2002:a17:906:a38e:b0:6da:a1f9:f9ee with SMTP id k14-20020a170906a38e00b006daa1f9f9eemr6161292ejz.27.1646589108707; Sun, 06 Mar 2022 09:51:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646589108; cv=none; d=google.com; s=arc-20160816; b=Tuzx58h/5ew+bs3hYsvsaw361FlTi+HSSpRDaE4G0Pqu8HxkW0RwPgP8YaiiS1n9c6 X5O42hKDJO39tR23G4aKpbmkIQOxLTKiKJq+EeWP6MSM5Ve2QjBWFObpp0gSKkIOmFf9 gbe8zh3uU3wIVyXUB9ZEW3T8pxFpUN8RkYj5GCaLwN66gwcMTTrJF5X3FDlbDvM8Quji mn06KnfSdXvi52/D79LoEOLqNtuJOQI6xu8L1Tg7WMKE+L5Yj0GgIgJeB8hUAwcsV5fh lA+muHShu7hW5eeflkb7ifkE0kspve8bCDMyWoGEUtnohSO0RUnI9rkpx/Z2f4o4y+Jm WpuA== 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=01A78e3BNJF/O5rz6xPxSilqTIuVd6KjQccxsjKtw9M=; b=EwtxZONJwHUC1XZNMIc5WzNOoRAIrTxor19dTF3DxNPWWY36OzTHj3we6Nml67iLlT a1OR93QsLC9M3/4cWS01LhgjMrr5mD+ytkT/fHFfSsB6yepynqjLTkMHRl35HdOn1hvR IW91bLEmngBD/87qMFSu7N0DIGKdQcPtUaoF0GsM6yIxIXvBpq5ETJEsBSHCPfaCxG4q 11NgEx6W7OPcAx39Q7CUKfeber9XZfXsPWUM1pmwP07RU6dkChe3VEa7wzvKsOJAZyEP dD+UJQ15WoQgB5KA5w8MkjKY3Gf7Gy+nDVIN0jmDBe3DMI/q753eRn/+lragTlKMRXTF lfLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=rWOQ0+Od; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=rWOQ0+Od; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 ka21-20020a170907991500b006d2a8ed00f1si6524775ejc.909.2022.03.06.09.51.26; Sun, 06 Mar 2022 09:51:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=rWOQ0+Od; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=rWOQ0+Od; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S233634AbiCFOey (ORCPT + 99 others); Sun, 6 Mar 2022 09:34:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232853AbiCFOex (ORCPT ); Sun, 6 Mar 2022 09:34:53 -0500 Received: from bedivere.hansenpartnership.com (bedivere.hansenpartnership.com [IPv6:2607:fcd0:100:8a00::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85487546AC; Sun, 6 Mar 2022 06:34:00 -0800 (PST) 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-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-kernel@vger.kernel.org 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