From nobody Wed Feb 11 20:55:32 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A650C7EE22 for ; Thu, 4 May 2023 20:48:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbjEDUsR (ORCPT ); Thu, 4 May 2023 16:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbjEDUrz (ORCPT ); Thu, 4 May 2023 16:47:55 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 624E9AD32 for ; Thu, 4 May 2023 13:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230733; bh=lMtgOxwdzX0uFY+dt+rni4n4Qsyjrfo6DEFUPcpl8ZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fFma/8uB9FrnwdLgMUbByiIiA8Hs/uH8qtZGJZRYqQPgadYcdw1PlXB9LDBtfra97 DeZL1N80zOyn6fvgwXRkthYRIG7bIsKysrcsLGoKj7N+mdmFKYvljaJ8W4RWkoK7BT Ih6EfdFIwq0dTqc9z1uevqKs8p59fJdB+xeJp2zZ85vEl6twos79ZLSTDJV/MEUoud RRksmMSyHeAZGK7SVbR2JsTPcIf340qNmlPh8lvc7Ex/MnNuBqa+ku09Oh4fDGVgzb g2d3IjTPh1hHOQdOrxtb6+iUBTPJ7KftPMIBzVQKrMDo0qUR4ySVQEcnkuvxQxyJyz 46bI38/F4rnNw== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Yn5ZnSz11lP; Thu, 4 May 2023 16:05:33 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Huang Ying , Peter Zijlstra Subject: [RFC PATCH 08/13] llist.h: Fix parentheses around macro pointer parameter use Date: Thu, 4 May 2023 16:05:22 -0400 Message-Id: <20230504200527.1935944-9-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230504200527.1935944-1-mathieu.desnoyers@efficios.com> References: <20230504200527.1935944-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add missing parentheses around use of macro argument "pos" in those patterns to ensure operator precedence behaves as expected: - typeof(*pos) - pos->member - "x =3D y" is changed for "x =3D (y)", because "y" can be an expression containing a comma if it is the result of the expansion of a macro such as #define eval(...) __VA_ARGS__, which would cause unexpected operator precedence. This use-case is far-fetched, but we have to choose one way or the other (with or without parentheses) for consistency. The typeof(*pos) lack of parentheses around "pos" is not an issue per se in the specific macros modified here because "pos" is used as an lvalue, which should prevent use of any operator causing issue. Still add the extra parentheses for consistency. Remove useless parentheses around use of macro parameter (node) in the following patterns: - llist_entry((node), typeof(*(pos)), member) is changed for llist_entry(node, typeof(*(pos)), member), - "(pos) =3D (node)" is changed for "pos =3D (node)". Because comma is the lowest priority operator already, so the extra pair of parentheses is redundant. Signed-off-by: Mathieu Desnoyers Cc: Andrew Morton Cc: Huang Ying Cc: Peter Zijlstra --- include/linux/llist.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/linux/llist.h b/include/linux/llist.h index 85bda2d02d65..4181b34b557f 100644 --- a/include/linux/llist.h +++ b/include/linux/llist.h @@ -114,7 +114,7 @@ static inline void init_llist_head(struct llist_head *l= ist) * reverse the order by yourself before traversing. */ #define llist_for_each(pos, node) \ - for ((pos) =3D (node); pos; (pos) =3D (pos)->next) + for (pos =3D (node); pos; pos =3D (pos)->next) =20 /** * llist_for_each_safe - iterate over some deleted entries of a lock-less = list @@ -133,7 +133,7 @@ static inline void init_llist_head(struct llist_head *l= ist) * reverse the order by yourself before traversing. */ #define llist_for_each_safe(pos, n, node) \ - for ((pos) =3D (node); (pos) && ((n) =3D (pos)->next, true); (pos) =3D (n= )) + for (pos =3D (node); (pos) && (n =3D (pos)->next, true); pos =3D (n)) =20 /** * llist_for_each_entry - iterate over some deleted entries of lock-less l= ist of given type @@ -151,9 +151,9 @@ static inline void init_llist_head(struct llist_head *l= ist) * reverse the order by yourself before traversing. */ #define llist_for_each_entry(pos, node, member) \ - for ((pos) =3D llist_entry((node), typeof(*(pos)), member); \ + for (pos =3D llist_entry(node, typeof(*(pos)), member); \ member_address_is_nonnull(pos, member); \ - (pos) =3D llist_entry((pos)->member.next, typeof(*(pos)), member)) + pos =3D llist_entry((pos)->member.next, typeof(*(pos)), member)) =20 /** * llist_for_each_entry_safe - iterate over some deleted entries of lock-l= ess list of given type @@ -173,10 +173,10 @@ static inline void init_llist_head(struct llist_head = *list) * reverse the order by yourself before traversing. */ #define llist_for_each_entry_safe(pos, n, node, member) \ - for (pos =3D llist_entry((node), typeof(*pos), member); \ + for (pos =3D llist_entry(node, typeof(*(pos)), member); \ member_address_is_nonnull(pos, member) && \ - (n =3D llist_entry(pos->member.next, typeof(*n), member), true); \ - pos =3D n) + (n =3D llist_entry((pos)->member.next, typeof(*(n)), member), true); \ + pos =3D (n)) =20 /** * llist_empty - tests whether a lock-less list is empty --=20 2.25.1