Received: by 2002:a05:6358:98a5:b0:11e:80f4:e92 with SMTP id q37csp24252rwa; Thu, 4 May 2023 13:48:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45/4kwba7yykIJo9SXPFokVb8qCymTVR/mVXdrPKe0obzlXNYVVVxx+pNAjdoHUEJdwKJ0 X-Received: by 2002:a05:6a00:1a0b:b0:63f:1adb:bf61 with SMTP id g11-20020a056a001a0b00b0063f1adbbf61mr4845327pfv.18.1683233332362; Thu, 04 May 2023 13:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683233332; cv=none; d=google.com; s=arc-20160816; b=YEJD47gKamsa8dRwgyGR+hXswo5MvXfiFOruGedFRj0y688nfCZwmDIFzbw4cPt3Y7 qA0K4ygI/A7UyBA/9ey+25lqr6nyOIOa3CXGarnsspyWgimBkCTj5ZZE+O2Gxu7WdwC0 AGJfP3QAcSsN9ypwbHAX6RPluaYo2LmN1vX0g7tP2hEWOVBItqeuVxsBp2G93NIXO2PB iui2g97w38m5YHfOANSTIrHTyPlrZ5vBMAY58duFU5sdH/u8YxZgkS99340f21CKkWQ6 DTKY9iD+fMgX7sE/qDZjBr2um+UI40x6KZPT/pbb8D7h6asD+dU4p+kaJ16UpJWBhJqz 7fKw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=h+GJ0OSxPbPrQQ9EBqRupyRYiXDvcK5QPLtdZ6xYBSA=; b=d31xNerX6QGrHzXiwzyKMNscJLdsNa0AAaYP6xUftZ38unA5g4lKGKh3PZrR7dnK3d LbemiUu/Uay6X3/+OAfKr749kqQK8cTJGnl+65FEjpFeimwRfX3LZeLw2/8XyNzSM5QB zmeESSgUcVpiofGboBvZrqxzfob1z4n9lvBGmiy+n2XyWTVb7TSo5G1KwgPGBzk9nuG2 m7k/O1sNpaEG2wahYKv2bDJqdu7kFYVvSvxf99nIZdlwQ8E02l1uklMV9rsJfvarF8nT ATLHMZGHoyHIGVKL2GGcmbFjrluHFdEp7WtElJ94gxd9TAVdQju3BvFcg/JOpyc2ijoM gGhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b="fFma/8uB"; 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 b12-20020a63930c000000b0052c40a97d97si260310pge.5.2023.05.04.13.48.38; Thu, 04 May 2023 13:48:52 -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="fFma/8uB"; 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 S229565AbjEDUsP (ORCPT + 99 others); Thu, 4 May 2023 16:48:15 -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: 8bit X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no 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 Add missing parentheses around use of macro argument "pos" in those patterns to ensure operator precedence behaves as expected: - typeof(*pos) - pos->member - "x = y" is changed for "x = (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) = (node)" is changed for "pos = (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 *list) * reverse the order by yourself before traversing. */ #define llist_for_each(pos, node) \ - for ((pos) = (node); pos; (pos) = (pos)->next) + for (pos = (node); pos; pos = (pos)->next) /** * 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 *list) * reverse the order by yourself before traversing. */ #define llist_for_each_safe(pos, n, node) \ - for ((pos) = (node); (pos) && ((n) = (pos)->next, true); (pos) = (n)) + for (pos = (node); (pos) && (n = (pos)->next, true); pos = (n)) /** * llist_for_each_entry - iterate over some deleted entries of lock-less list of given type @@ -151,9 +151,9 @@ static inline void init_llist_head(struct llist_head *list) * reverse the order by yourself before traversing. */ #define llist_for_each_entry(pos, node, member) \ - for ((pos) = llist_entry((node), typeof(*(pos)), member); \ + for (pos = llist_entry(node, typeof(*(pos)), member); \ member_address_is_nonnull(pos, member); \ - (pos) = llist_entry((pos)->member.next, typeof(*(pos)), member)) + pos = llist_entry((pos)->member.next, typeof(*(pos)), member)) /** * llist_for_each_entry_safe - iterate over some deleted entries of lock-less 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 = llist_entry((node), typeof(*pos), member); \ + for (pos = llist_entry(node, typeof(*(pos)), member); \ member_address_is_nonnull(pos, member) && \ - (n = llist_entry(pos->member.next, typeof(*n), member), true); \ - pos = n) + (n = llist_entry((pos)->member.next, typeof(*(n)), member), true); \ + pos = (n)) /** * llist_empty - tests whether a lock-less list is empty -- 2.25.1