Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp640544rwr; Thu, 4 May 2023 07:51:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ58ZA7GO0XaXvKrWteGbJ+W9tBz7Ue/FCNGrELAwWpdniYmviMfcPYakaqvWN5nZvEAlmFM X-Received: by 2002:a17:90a:fd81:b0:24e:3206:7ca9 with SMTP id cx1-20020a17090afd8100b0024e32067ca9mr2437138pjb.46.1683211886359; Thu, 04 May 2023 07:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683211886; cv=none; d=google.com; s=arc-20160816; b=RguXK9P6pIA79KROTxTcB4gh1anrg43yPVv71oRGRlLA799GuE/K9wvw9mkxuepimL 3nuXkZAS2LTy8Galy0AEkpO4EaUeirBjH3c9Jwei0MOGelJdW8FdO19JqdV/M1Mcvi1C 3VsyXVPxqdNW3rxEksOuIrDW7Jiv2+KAzv+HJ2c6NmMuhzvj5dVlfQEyqJ25EPVDNzeK qvRz++XulA19fOF1a5xbquO6IF+BZIRDR+w5Zlqpgp0WbgDWGAReO2BshhKveFKXpU/L izqaG8T/Lv7ZKxSE2JJJXC92NIrLWZmFjKJSeW4jUu4NqUpR4Y3SoRqggaICOGkKuolG bV6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=j+UY+f1cZR9QTa2kcg4ScVWPIqhxNxm3f/7fD85L/Aw=; b=qBS7ugl8PSDcPnGZS+b8EjiEYRSi34PAX5RYFkY2fJ/tM/5SS4ZhIocKSilBe14WVR zq5Zuuw3tnlm1c4rPYCoESEto3Qhh/A1Toa+xzOt9aqPJkixo5HHcpat3r/4iTUddkGt 8n+7IJOcW+ta0vFHIjLyXmwfrkITrPXUyrkJWP8XgyhOA+UAUt+7BK76lFwhjTCyExLy yz2Hl8AfPydtIENGgkAvhGI/9bT5/96T7nIi/TY+lBLdEDtImS4bHx/xgsqqcChbB7Uv qRs9mdVYBQTAre7lkccvjTaY6aiIvi2TBcQ/yQwOTnt0JjxwvOqZ0wpJVh3p0oQG+SzW RMXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=XZQEkixg; 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=efficios.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a63d507000000b0051fc9e06b8csi35493212pgg.378.2023.05.04.07.51.11; Thu, 04 May 2023 07:51:26 -0700 (PDT) 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=@efficios.com header.s=smtpout1 header.b=XZQEkixg; 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=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229905AbjEDOpS (ORCPT + 99 others); Thu, 4 May 2023 10:45:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230415AbjEDOpQ (ORCPT ); Thu, 4 May 2023 10:45:16 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5D13CD for ; Thu, 4 May 2023 07:45:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683211513; bh=HmUqcQHWR1GPfo7qcRsxY8yYNYLW02LpBYc5FEFsqHY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=XZQEkixgFbZ0LGv4S5U7hOgUkTYW3iG42pfZqxIjosrx5ScFlClKApj787cZuXEmW yxseZwyRh8Tz6DMYUfFQ9DBh/cHavZZoYuK3VKX8kGvIjfPC9ZoQPR1se4A4Hag5KT sy2t/+L4lIgSgtxsxZId7XLTMunfyVWLaY2RLmMeIeuHWLWXr1pbITQZhiXQOB0tbH tC01Tcum53pW+S3QH4TVu7N9bXjWeUxbvkJlHH14iMV+29YTofEiLlMaEIy6JQyuur Bl2TJsY72M3XCvAlGk6uFX9WvJOIlwsE7nZKDBKye76LHXHE3wCGZCDS9w/MBfifwo i6y4KWnLuTJMw== Received: from [172.16.0.73] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QBxS95vvxz11nS; Thu, 4 May 2023 10:45:13 -0400 (EDT) Message-ID: <532c91c5-5655-2a15-8bf1-82ee939c156b@efficios.com> Date: Thu, 4 May 2023 10:45:18 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [RFC PATCH 2/4] list.h: Fix parentheses around macro pointer parameter use Content-Language: en-US To: Andy Shevchenko Cc: Andrew Morton , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , David Howells , Ricardo Martinez References: <20230504012914.1797355-1-mathieu.desnoyers@efficios.com> <20230504012914.1797355-2-mathieu.desnoyers@efficios.com> From: Mathieu Desnoyers In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 2023-05-04 10:41, Andy Shevchenko wrote: > On Wed, May 03, 2023 at 09:29:12PM -0400, Mathieu Desnoyers wrote: >> Add missing parentheses around use of macro argument "pos" in those >> patterns to ensure operator precedence behaves as expected: >> >> - typeof(*pos) >> - pos->member >> >> Remove useless parentheses around use of macro parameter (head) in the >> following pattern: >> >> - list_is_head(pos, (head)) >> >> Because comma is the lowest priority operator already, so the extra pair >> of parentheses is redundant. >> >> This corrects the following usage pattern where operator precedence is >> unexpected: >> >> LIST_HEAD(testlist); >> >> struct test { >> struct list_head node; >> int a; >> }; >> >> // pos->member issue >> void f(void) >> { >> struct test *t1; >> struct test **t2 = &t1; > > I'm not against the patch, but I'm in doubt, looking into this example, it's useful. > Any real use case like above in the Linux kernel, please? There aren't because the code would not compile with the current header implementation. But it's unexpected that this kind of pattern does not work. It's not about being useful, but rather about eliminating unexpected operator precedence within macros, and about being consistent everywhere. Thanks, Mathieu > >> list_for_each_entry((*t2), &testlist, node) { /* works */ >> //... >> } >> list_for_each_entry(*t2, &testlist, node) { /* broken */ >> //... >> } >> } > -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com