From patchwork Thu May 4 20:05:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90243 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp609665vqo; Thu, 4 May 2023 14:10:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61kInVedYb/STOKjRIGnJl2KCrwxJg5ChFqbPke21Bz4676i1Xh7IpTgbJJXNamWvb7UsJ X-Received: by 2002:a05:6a20:ae15:b0:f0:2222:8b58 with SMTP id dp21-20020a056a20ae1500b000f022228b58mr3444496pzb.12.1683234607647; Thu, 04 May 2023 14:10:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683234607; cv=none; d=google.com; s=arc-20160816; b=Yhbb7FzzlSEoPmGDji6bDS8DBhSqcFilCS+rz1gxnL1caNkc/kGh4xsQoaQXxsfhkk dV6xlcVoHH8q2TnJfdCy/FktApP/VbKKuv1o2RfL+w/MiTPLLLOTRcxuzM4vA+TZKDnT Q5F9noAe2Wk3OOzxIFvvq/BaLC9F6vTRpnxyFazyrZPXVFiv+DQtawYawL4LA+kPXsiM sTHdB/gTSSEJyvuz3NgCEsoVp0gyc4Cv08fwCqWXLyAN8GT1Gy/+M9xE2TbtyNHFqsbc 1YHdasK5LS6fwSWtMBESu4rfdxThtbpbQ4f/f5kcL9GD7WAzWPqsdkKyAUXxitcLLJIB vmFw== 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=bC4Ls+M8E3ic/KS7drQkRwIJpylQ0tIcQeEq+cYDyRs=; b=HhzE/eWdrE74aHQZeV27k0ja8LuzsCgt1chMjgO+AI7KH3L6hbsMFR7Mq9JzBj8hWu WjpqctV1EvyeejeERGUTDTNT7qNuaihwfoyPnm9FX4VK7vasBurussYeZAtSXUtIjfbe MQFE1gQotJItgkIfKBA6ggSHlckJXdE+62igd5LMT25aesUeWU3WfpK5Ulz8uhLQKXIh 52E4JQCMPQTvicUtXrSmbIbkWGgE6wKHpiecLK+QCSiJxaIZVUQTnQl7kq7SSV4lSD3T fsijfm7948CBnYdV6Q3sYvkoivowAf3Ss6JQIQDvFsAW7/zMalcdbyJP9cDZz1uBkXR7 JN0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b="v/dCD84H"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h185-20020a6383c2000000b0052857fbb31dsi331493pge.200.2023.05.04.14.09.54; Thu, 04 May 2023 14:10:07 -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="v/dCD84H"; 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 S230417AbjEDVCV (ORCPT + 99 others); Thu, 4 May 2023 17:02:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230497AbjEDVBn (ORCPT ); Thu, 4 May 2023 17:01:43 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D9B01493C for ; Thu, 4 May 2023 14:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230732; bh=QRmMLfXg5unF7/3RNcMH7AOL6J3UpJBYx5LfEyiS2RI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v/dCD84HuYJgTT5w4IJtqAmtHBQh8auLZmyc/r854jojAY8mbnR7qunxRrDb9sm/H PuqMc5qLmGpf0CBbmricpzPkYNSERIKKeFL40PZmw64U1phoW3/ggTIZ+E2g4/aELv S30ofIhjNFqOU9X3sLYYavOSH8ljbEGVN6KfSnv1D84bVErgj3V6K5loX4+xKwYOCi zK1XyIig4dExnSpgyxNEGupyY9pxRo0k01WaggUNcSMG5FLPxOdAc4My9Us0IPxImJ BLRNcl9nQknH66s5Eq5XrY9xjP5nxHlm6MJlITftb3DdwY9G1s3ivy8Uy6rP3SyPYm GGfK4Q/1eDeRQ== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Yl5vByzxRG; Thu, 4 May 2023 16:05:31 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , "Paul E. McKenney" , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Lai Jiangshan , Zqiang Subject: [RFC PATCH 01/13] rcu: rcupdate.h: Fix parentheses around macro parameter use Date: Thu, 4 May 2023 16:05:15 -0400 Message-Id: <20230504200527.1935944-2-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764999412353255012?= X-GMAIL-MSGID: =?utf-8?q?1764999412353255012?= linux/rcupdate.h macros use the *p parameter without parentheses, e.g.: typeof(*p) rather than typeof(*(p)) The following test-case shows how it can generate confusion due to C operator precedence being reversed compared to the expectations: #define m(p) \ do { \ __typeof__(*p) v = 0; \ } while (0) void fct(unsigned long long *p1) { m(p1 + 1); /* works */ m(1 + p1); /* broken */ } Add missing parentheses around macro parameter use in the following pattern to ensure operator precedence behaves as expected: - m(&p) is changed for m(&(p)). Remove useless parentheses in the following macro argument usage patterns: - m((x), y) is changed for m(x, y), because comma has the lowest operator precedence, and thus the extra parentheses are useless. - "(_r_a_p__v) where _r_a_p__v is a variable and not a macro parameter, is changed for "_r_a_p__v", An extra whitespace is also removed in kvfree_rcu_arg_2() for consistency. Signed-off-by: Mathieu Desnoyers Cc: "Paul E. McKenney" Cc: Joel Fernandes Cc: Josh Triplett Cc: Boqun Feng Cc: Steven Rostedt Cc: Lai Jiangshan Cc: Zqiang --- include/linux/rcupdate.h | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index dcd2cf1e8326..4f26c3080953 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h @@ -215,7 +215,7 @@ void rcu_tasks_trace_qs_blkd(struct task_struct *t); \ if (likely(!READ_ONCE((t)->trc_reader_special.b.need_qs)) && \ likely(!___rttq_nesting)) { \ - rcu_trc_cmpxchg_need_qs((t), 0, TRC_NEED_QS_CHECKED); \ + rcu_trc_cmpxchg_need_qs(t, 0, TRC_NEED_QS_CHECKED); \ } else if (___rttq_nesting && ___rttq_nesting != INT_MIN && \ !READ_ONCE((t)->trc_reader_special.b.blocked)) { \ rcu_tasks_trace_qs_blkd(t); \ @@ -227,7 +227,7 @@ void rcu_tasks_trace_qs_blkd(struct task_struct *t); #define rcu_tasks_qs(t, preempt) \ do { \ - rcu_tasks_classic_qs((t), (preempt)); \ + rcu_tasks_classic_qs(t, preempt); \ rcu_tasks_trace_qs(t); \ } while (0) @@ -430,16 +430,16 @@ static inline void rcu_preempt_sleep_check(void) { } #ifdef __CHECKER__ #define rcu_check_sparse(p, space) \ - ((void)(((typeof(*p) space *)p) == p)) + ((void)(((typeof(*(p)) space *)(p)) == (p))) #else /* #ifdef __CHECKER__ */ #define rcu_check_sparse(p, space) #endif /* #else #ifdef __CHECKER__ */ #define __unrcu_pointer(p, local) \ ({ \ - typeof(*p) *local = (typeof(*p) *__force)(p); \ + typeof(*(p)) *local = (typeof(*(p)) *__force)(p); \ rcu_check_sparse(p, __rcu); \ - ((typeof(*p) __force __kernel *)(local)); \ + ((typeof(*(p)) __force __kernel *)(local)); \ }) /** * unrcu_pointer - mark a pointer as not being RCU protected @@ -452,29 +452,29 @@ static inline void rcu_preempt_sleep_check(void) { } #define __rcu_access_pointer(p, local, space) \ ({ \ - typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ + typeof(*(p)) *local = (typeof(*(p)) *__force)READ_ONCE(p); \ rcu_check_sparse(p, space); \ - ((typeof(*p) __force __kernel *)(local)); \ + ((typeof(*(p)) __force __kernel *)(local)); \ }) #define __rcu_dereference_check(p, local, c, space) \ ({ \ /* Dependency order vs. p above. */ \ - typeof(*p) *local = (typeof(*p) *__force)READ_ONCE(p); \ + typeof(*(p)) *local = (typeof(*(p)) *__force)READ_ONCE(p); \ RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_check() usage"); \ rcu_check_sparse(p, space); \ - ((typeof(*p) __force __kernel *)(local)); \ + ((typeof(*(p)) __force __kernel *)(local)); \ }) #define __rcu_dereference_protected(p, local, c, space) \ ({ \ RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_protected() usage"); \ rcu_check_sparse(p, space); \ - ((typeof(*p) __force __kernel *)(p)); \ + ((typeof(*(p)) __force __kernel *)(p)); \ }) #define __rcu_dereference_raw(p, local) \ ({ \ /* Dependency order vs. p above. */ \ typeof(p) local = READ_ONCE(p); \ - ((typeof(*p) __force __kernel *)(local)); \ + ((typeof(*(p)) __force __kernel *)(local)); \ }) #define rcu_dereference_raw(p) __rcu_dereference_raw(p, __UNIQUE_ID(rcu)) @@ -520,10 +520,10 @@ do { \ uintptr_t _r_a_p__v = (uintptr_t)(v); \ rcu_check_sparse(p, __rcu); \ \ - if (__builtin_constant_p(v) && (_r_a_p__v) == (uintptr_t)NULL) \ - WRITE_ONCE((p), (typeof(p))(_r_a_p__v)); \ + if (__builtin_constant_p(v) && _r_a_p__v == (uintptr_t)NULL) \ + WRITE_ONCE(p, (typeof(p))_r_a_p__v); \ else \ - smp_store_release(&p, RCU_INITIALIZER((typeof(p))_r_a_p__v)); \ + smp_store_release(&(p), RCU_INITIALIZER((typeof(p))_r_a_p__v));\ } while (0) /** @@ -539,8 +539,8 @@ do { \ */ #define rcu_replace_pointer(rcu_ptr, ptr, c) \ ({ \ - typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ - rcu_assign_pointer((rcu_ptr), (ptr)); \ + typeof(ptr) __tmp = rcu_dereference_protected(rcu_ptr, c); \ + rcu_assign_pointer(rcu_ptr, ptr); \ __tmp; \ }) @@ -571,7 +571,7 @@ do { \ * down multi-linked structures after a grace period has elapsed. However, * rcu_dereference_protected() is normally preferred for this use case. */ -#define rcu_access_pointer(p) __rcu_access_pointer((p), __UNIQUE_ID(rcu), __rcu) +#define rcu_access_pointer(p) __rcu_access_pointer(p, __UNIQUE_ID(rcu), __rcu) /** * rcu_dereference_check() - rcu_dereference with debug checking @@ -607,7 +607,7 @@ do { \ * annotated as __rcu. */ #define rcu_dereference_check(p, c) \ - __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ + __rcu_dereference_check(p, __UNIQUE_ID(rcu), \ (c) || rcu_read_lock_held(), __rcu) /** @@ -623,7 +623,7 @@ do { \ * rcu_read_lock() but also rcu_read_lock_bh() into account. */ #define rcu_dereference_bh_check(p, c) \ - __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ + __rcu_dereference_check(p, __UNIQUE_ID(rcu), \ (c) || rcu_read_lock_bh_held(), __rcu) /** @@ -639,7 +639,7 @@ do { \ * only rcu_read_lock() but also rcu_read_lock_sched() into account. */ #define rcu_dereference_sched_check(p, c) \ - __rcu_dereference_check((p), __UNIQUE_ID(rcu), \ + __rcu_dereference_check(p, __UNIQUE_ID(rcu), \ (c) || rcu_read_lock_sched_held(), \ __rcu) @@ -651,7 +651,7 @@ do { \ * rcu_read_lock_held(). */ #define rcu_dereference_raw_check(p) \ - __rcu_dereference_check((p), __UNIQUE_ID(rcu), 1, __rcu) + __rcu_dereference_check(p, __UNIQUE_ID(rcu), 1, __rcu) /** * rcu_dereference_protected() - fetch RCU pointer when updates prevented @@ -670,7 +670,7 @@ do { \ * but very ugly failures. */ #define rcu_dereference_protected(p, c) \ - __rcu_dereference_protected((p), __UNIQUE_ID(rcu), (c), __rcu) + __rcu_dereference_protected(p, __UNIQUE_ID(rcu), c, __rcu) /** @@ -1021,7 +1021,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) #define KVFREE_GET_MACRO(_1, _2, NAME, ...) NAME #define kvfree_rcu_arg_2(ptr, rhf) \ do { \ - typeof (ptr) ___p = (ptr); \ + typeof(ptr) ___p = (ptr); \ \ if (___p) { \ BUILD_BUG_ON(!__is_kvfree_rcu_offset(offsetof(typeof(*(ptr)), rhf))); \ From patchwork Thu May 4 20:05:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90226 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp597236vqo; Thu, 4 May 2023 13:46:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ448S2QLsIQSgTAw5xRcjpYoGOC0ZkD+ogDLWF5vE53ZogOE1mvfcQHWOgIwlJVs/YVdMzG X-Received: by 2002:a05:6a00:1a11:b0:63b:89ba:fc9c with SMTP id g17-20020a056a001a1100b0063b89bafc9cmr4303756pfv.27.1683233192041; Thu, 04 May 2023 13:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683233192; cv=none; d=google.com; s=arc-20160816; b=AOioLOfXyXMIFYq9LPUpHoe1P2bsA6KtXEUcdKhA8srW6mGnnAjUNAXjDdovWUI8Dw 8Y3wHsrYdgbFT9HK0/ZQ8H6cuwuZUGWKtfONe05CPXAebHgaMb4c0zlfar1Y0E012JY/ 7hZkMQqWfEqt9p3H3CxT8OEaTCrP4EKI0AUc+N7TOyH20GgdJFroL5vfPmoL3eTn3WzS XqbTE7VuU5vHgKiL4IfpehrJKSMN+fQZtg2iScqJbSk8bVgcdPEPA+5fT5Z2ZDZBtLLS TBLAi3770MRo07AGYkbkLTQXML8mL3u/6FHMfWRrkArYiVzn5IGb5OblmyMf/PrTWurO 7iaA== 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=Zti40A3E9W1uH526WPtZKO9ZOi9tS1JUTyb1/r8Eh9U=; b=YqXTFM06CwkANwx/gLVw9zvfbkoNn87HHuL4kdDEuDExogZIZhiSxWQen9dBkNBKH4 zU5/Wxe2cGkG6IcU2Ln8azVrDGplVXK6kk80JXUR/c3DmiOp/APZlURHu5FEX3pGTBat /jARw5TEh7YX8lx66Vpe5y5MX9eKa5dGg99P6esgmOxxxsrTq2sl0ngZigE7gSurg97j gCLPBQbG7o5VXlECToPS8Ou3mtzMknD2nFuPlII/wxJOXEOoybbyDlCqL174CKVg05cC /UUm1VzicIajzAyN0FSaeJS3EPTCYnDVFvFMiLlg2NEVOUXc5qTMgNJM1bSbIEhhR906 5ULA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b="pP/WOQu2"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a2-20020aa79702000000b0063d408c714bsi248642pfg.175.2023.05.04.13.46.19; Thu, 04 May 2023 13:46:32 -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="pP/WOQu2"; 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 S231272AbjEDUck (ORCPT + 99 others); Thu, 4 May 2023 16:32:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231137AbjEDUcU (ORCPT ); Thu, 4 May 2023 16:32:20 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B5EB19435; Thu, 4 May 2023 13:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230732; bh=W9zAZi8VwGgVLnwB1Kz05im9spQ0PM5+IFpjRSSrhRE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pP/WOQu25fetQ3sRoYaQurZejTtqepJNV9c4Kuqjs22wa8BGt5gMJ25ZiFCE0l0BI GNuj7gkGiKFbAbQ341x8qDNPFhW2niVnAQxIkb16dhbJPSn1pDjCi0Uu+A3ECdpZlb 2do0i0ahDdGKtSRaoXczdV/8LKiritrQ1vxfWre/+AtgKIv+8KtkI8oPKxXd7LAJl/ 8bqzLbzBQzeaaAjSJUXVWwB8pa0bNThwR3NUSqXqNaiJapkWuYtpYLrWgxlXsvFGEV i6DkCbILWnO5e3PBAepEhC3ZeeC2QTi+RJDi/azdj5WAmFqeh4M/ZUm63LzJkdS4me CSMnHx8BkUX1g== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Ym0sqPzxRH; Thu, 4 May 2023 16:05:32 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Lai Jiangshan , Zqiang , rcu@vger.kernel.org Subject: [RFC PATCH 02/13] rculist.h: Fix parentheses around macro pointer parameter use Date: Thu, 4 May 2023 16:05:16 -0400 Message-Id: <20230504200527.1935944-3-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 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_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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764997927844799338?= X-GMAIL-MSGID: =?utf-8?q?1764997927844799338?= Add missing parentheses around use of macro argument "pos" in those patterns to ensure operator precedence behaves as expected: - typeof(*pos) - pos->member 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; list_for_each_entry_rcu((*t2), &testlist, node) { /* works */ //... } list_for_each_entry_rcu(*t2, &testlist, node) { /* broken */ //... } } 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. Signed-off-by: Mathieu Desnoyers Cc: "Paul E. McKenney" Cc: Andrew Morton Cc: Frederic Weisbecker Cc: Neeraj Upadhyay Cc: Joel Fernandes Cc: Josh Triplett Cc: Boqun Feng Cc: Steven Rostedt Cc: Lai Jiangshan Cc: Zqiang Cc: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- include/linux/rculist.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/include/linux/rculist.h b/include/linux/rculist.h index d29740be4833..d27aeff5447d 100644 --- a/include/linux/rculist.h +++ b/include/linux/rculist.h @@ -388,9 +388,9 @@ static inline void list_splice_tail_init_rcu(struct list_head *list, */ #define list_for_each_entry_rcu(pos, head, member, cond...) \ for (__list_check_rcu(dummy, ## cond, 0), \ - pos = list_entry_rcu((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) + pos = list_entry_rcu((head)->next, typeof(*(pos)), member);\ + &(pos)->member != (head); \ + pos = list_entry_rcu((pos)->member.next, typeof(*(pos)), member)) /** * list_for_each_entry_srcu - iterate over rcu list of given type @@ -407,9 +407,9 @@ static inline void list_splice_tail_init_rcu(struct list_head *list, */ #define list_for_each_entry_srcu(pos, head, member, cond) \ for (__list_check_srcu(cond), \ - pos = list_entry_rcu((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) + pos = list_entry_rcu((head)->next, typeof(*(pos)), member);\ + &(pos)->member != (head); \ + pos = list_entry_rcu((pos)->member.next, typeof(*(pos)), member)) /** * list_entry_lockless - get the struct for this entry @@ -441,9 +441,9 @@ static inline void list_splice_tail_init_rcu(struct list_head *list, * but never deleted. */ #define list_for_each_entry_lockless(pos, head, member) \ - for (pos = list_entry_lockless((head)->next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry_lockless(pos->member.next, typeof(*pos), member)) + for (pos = list_entry_lockless((head)->next, typeof(*(pos)), member); \ + &(pos)->member != (head); \ + pos = list_entry_lockless((pos)->member.next, typeof(*(pos)), member)) /** * list_for_each_entry_continue_rcu - continue iteration over list of given type @@ -464,9 +464,9 @@ static inline void list_splice_tail_init_rcu(struct list_head *list, * position. */ #define list_for_each_entry_continue_rcu(pos, head, member) \ - for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \ - &pos->member != (head); \ - pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) + for (pos = list_entry_rcu((pos)->member.next, typeof(*(pos)), member); \ + &(pos)->member != (head); \ + pos = list_entry_rcu((pos)->member.next, typeof(*(pos)), member)) /** * list_for_each_entry_from_rcu - iterate over a list from current point @@ -486,8 +486,8 @@ static inline void list_splice_tail_init_rcu(struct list_head *list, * after the given position. */ #define list_for_each_entry_from_rcu(pos, head, member) \ - for (; &(pos)->member != (head); \ - pos = list_entry_rcu(pos->member.next, typeof(*(pos)), member)) + for (; &(pos)->member != (head); \ + pos = list_entry_rcu((pos)->member.next, typeof(*(pos)), member)) /** * hlist_del_rcu - deletes entry from hash list without re-initialization From patchwork Thu May 4 20:05:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp608183vqo; Thu, 4 May 2023 14:07:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ZkX13cR4wGYXuDo4uI98aoC+xAwqYf4t9WGoKpi+FpFwNPy6IeGIOv/WGbnQ8YolaiA74 X-Received: by 2002:a17:902:e5c9:b0:1aa:fe23:a7f8 with SMTP id u9-20020a170902e5c900b001aafe23a7f8mr5399995plf.59.1683234452242; Thu, 04 May 2023 14:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683234452; cv=none; d=google.com; s=arc-20160816; b=SvL3qVGHWyJ5inkyA20/qjUbIyHz155K8p+DlGOV0wXhDVYNg1AahV20iu6T6SvLEu BUiUC9V7B462ZOt4uinEaxXQR/Tq4nN1umoroLhUiSM43f+daA6hQXW4k88NbPJnH2rQ SUoe+j+pozfA+f8dyftk6kLArloRNXKqZ7VuvcL75rVCrXRmSKJxh2hklQiCKoS9EVqn bs2Fg9PpMqX5SBMx01zs6pAtS4k0XbvDVT8CA5jVWqQDAEly0NhTR9A1tOzY9YdtbghG WRj7tjHrsQSsBFgqRRTet3bDeoGv0Ir57ais/RBGOeM2iAK0DldsCJZjjGhBCTFglQOR fxZg== 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=3fyNm0wVVcT/TLXXDeU2ch8hRopaezBDb3vsoRrtbiQ=; b=CkfiGz312NUPuBMjsZoYn8E9ypbjtO9C6G+ZIcx8qDuaOH0OlF0FIX3Xl1Z3FVUTPe H6vuC/ENXxbadfplvZ1DL8HPom7SP9GqUhpuoCUaetvM0aenkK6CBCy1hUNRVXcdQoT1 BB5idRumeHCDwWLmqJrC8Owa7GIC/S44HxPEEcw79Z6k9Rbiqu1xx/vcZPl6ql9vckFj 2EmsqHWbEwllAoO5Zia3i6r3yjdH7Yjzirtyzw3k3sxmpspfdCnRcfQC7gRwzBFNqYlf 5SMFOD/QleIdYWEYeZw9V6Yc6NSlzYjq9/xP7BgnwMaoRogmmXWznMTwpbmz2FOggoci DXMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=N0jaaMPN; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t10-20020a170902e84a00b0019a826d3054si37968957plg.640.2023.05.04.14.07.17; Thu, 04 May 2023 14:07:32 -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=N0jaaMPN; 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 S229906AbjEDVBi (ORCPT + 99 others); Thu, 4 May 2023 17:01:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230369AbjEDVBS (ORCPT ); Thu, 4 May 2023 17:01:18 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0E8313C10; Thu, 4 May 2023 14:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230732; bh=D/NfiDdblr1nISgkSaCGt1uzTz4bykGLb/1bVKOEMww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N0jaaMPNt4wgec6S+UXVf+cRhRvvT7e7d14PG5ZkCYpwfQLOYyu0n1nDOZ8A6bhye ut3K1V5mWn/K8ziXFRU222jQPbdpUQti5+xKhlOuewRc8MWNrqDlJsRURvhWRSVT0t JMUnH3+xGstJ6bHBVPMTU8yrcg37TV3CFoIK0/1pOgHNMP8MxJbMQvtiqUiUAX5vjB Frip0V51Cjqsk/ZCtfgWKK0tjDkrEEN7Uj22K+8O2hqobuOOuAEzgaeKRgXU1cIAou ze0+ixYVLRr909UzlBGQf6Z4zQu4zA8gsElrCqoImMeu58ksiVa6D5N6HXYmnUdgvj sxdzMviQL1VRw== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Ym3GV2z122c; Thu, 4 May 2023 16:05:32 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Alexei Starovoitov , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Lai Jiangshan , Zqiang , rcu@vger.kernel.org Subject: [RFC PATCH 03/13] rculist_nulls.h: Add parentheses around macro pointer parameter use Date: Thu, 4 May 2023 16:05:17 -0400 Message-Id: <20230504200527.1935944-4-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764999249169056121?= X-GMAIL-MSGID: =?utf-8?q?1764999249169056121?= Add parentheses around use of macro argument "tpos" in those patterns to ensure operator precedence behaves as expected: - typeof(*tpos) The typeof(*tpos) lack of parentheses around "tpos" is not an issue per se in the specific macros modified here because "tpos" is used as an lvalue, which should prevent use of any operator causing issue. Still add the extra parentheses for consistency with other list iteration code across the kernel tree. Signed-off-by: Mathieu Desnoyers Cc: Andrew Morton Cc: Alexei Starovoitov Cc: "Paul E. McKenney" Cc: Andrew Morton Cc: Frederic Weisbecker Cc: Neeraj Upadhyay Cc: Joel Fernandes Cc: Josh Triplett Cc: Boqun Feng Cc: Steven Rostedt Cc: Lai Jiangshan Cc: Zqiang Cc: rcu@vger.kernel.org --- include/linux/rculist_nulls.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/rculist_nulls.h b/include/linux/rculist_nulls.h index ba4c00dd8005..6e56dd2daecf 100644 --- a/include/linux/rculist_nulls.h +++ b/include/linux/rculist_nulls.h @@ -168,7 +168,7 @@ static inline void hlist_nulls_add_fake(struct hlist_nulls_node *n) for (({barrier();}), \ pos = rcu_dereference_raw(hlist_nulls_first_rcu(head)); \ (!is_a_nulls(pos)) && \ - ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); 1; }); \ + ({ tpos = hlist_nulls_entry(pos, typeof(*(tpos)), member); 1; }); \ pos = rcu_dereference_raw(hlist_nulls_next_rcu(pos))) /** @@ -183,7 +183,7 @@ static inline void hlist_nulls_add_fake(struct hlist_nulls_node *n) for (({barrier();}), \ pos = rcu_dereference_raw(hlist_nulls_first_rcu(head)); \ (!is_a_nulls(pos)) && \ - ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); \ + ({ tpos = hlist_nulls_entry(pos, typeof(*(tpos)), member); \ pos = rcu_dereference_raw(hlist_nulls_next_rcu(pos)); 1; });) #endif #endif From patchwork Thu May 4 20:05:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp597240vqo; Thu, 4 May 2023 13:46:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6nBZWN41M8eMvDUeNofzmypFVbHCV5D1GUpFzNLJMdK7+udd/EmLSdjyrtlFiXVGkNdqbS X-Received: by 2002:a17:902:768c:b0:1aa:e0c4:54e8 with SMTP id m12-20020a170902768c00b001aae0c454e8mr4552395pll.28.1683233192416; Thu, 04 May 2023 13:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683233192; cv=none; d=google.com; s=arc-20160816; b=dAixZO3ojSng2drf/v07HSzP4FloN8/8IAbpi3X9lcSIezS9N68aiexKEDaUsvrkwh 0w6igLVHmsr23lBsP3TTc6LHGY+auiYmiWvcF7yer9ZGH/ShAO6hZDOmjXj3t7fdbxnJ FMnHkmhT9GgQwVhYVn0V0/F7rVApqmL45Ly6qvvTHjb2++ptmHAiTNvmkvU6XmLmVlPH 7BUz3o9mB1hw7sIkduV0BgNQdDItTvqVYrF2XRV+iogh4SaLRw59xFG7upvTMmjLePGn pMjHDL+2ZNr6Wy2YBvlIgkeYrB3z3gbxbzRbc4kmmqPFDuKjXZg5VhSYFIJuuaSKfEhf RQSw== 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=TAz6OqpaDHPyJTHK6/RmvvqS7GhmEj0Kkzr4nF+F4d8=; b=fl0zVWrKI8n8BfuEnxGvPM9RYFBe8QH3Ymo2RAbCABPAIOijJhP4JWDp9ES7TTvXkD HgyLTg8EjESbqX6ujHbiYzsRntLw2OYyD/M2qsliNZSQxul9nEZ9T1vJmyXxALyUwhwr 2c9KZER6EB9n+hb71+QYnrhXQlkKCOYecvlMnTvLbOyGMbtjbZd5PiY/GCbCldT54zT1 H0EA79JLCXI9xz+7GdDpGECW1rhPJ2c2RlwbZMV/1ulWEBEaOXJuEhLw9OCPwCrOe8Pb awWiVmj3Tpok41HQqN6gCnZ5wqR9TEwNyAuhkS1IjSQW1yrHqi0lvWgC4KXIzyKZwbI9 NBiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=IfKCIjYQ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 14-20020a17090a004e00b0024e52b03440si3913556pjb.101.2023.05.04.13.46.19; Thu, 04 May 2023 13:46:32 -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=IfKCIjYQ; 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 S230123AbjEDUch (ORCPT + 99 others); Thu, 4 May 2023 16:32:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231196AbjEDUcU (ORCPT ); Thu, 4 May 2023 16:32:20 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9267E19434; Thu, 4 May 2023 13:22:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230733; bh=ZEKk2l+avXLFbsd5WjSG9znQ65K2KXiDXgyV8vZ7EJA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IfKCIjYQSXozgD4Wb+wSwBd+stdAcMsdT2i7VdXVhDqafbIW98tLuRfWIBLQZ+upQ 5cHlYfTa3Xacv7BcJRQjH/KgIlprqL2os0yCC4v5U1jBnVjjzAOo8SbzbhlzvKzMbr xsgD+dGSe18n+gif1kzPhm7D/VrQEw+jlmdRLLTOHI+fz8FHAT+PohpHF2J7q1HDPH x2iH82MRkVPYP9LF5JDu/DNky5u5fcl2ZbUWmIH8cL3c6qvJNMbGCOILIGskgK9xjy OpOb1k8U26ecYsStldMJQXyZQUN/oCdD/EusL/yddPWCrmAcHo8IK1GDvFgkHgoSZ6 9raHAvS4UD5rg== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Ym5dLWzxRJ; Thu, 4 May 2023 16:05:32 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Steven Rostedt , Lai Jiangshan , Zqiang , rcu@vger.kernel.org Subject: [RFC PATCH 04/13] rculist_bl.h: Fix parentheses around macro pointer parameter use Date: Thu, 4 May 2023 16:05:18 -0400 Message-Id: <20230504200527.1935944-5-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 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_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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764997927556058725?= X-GMAIL-MSGID: =?utf-8?q?1764997927556058725?= Add missing parentheses around use of macro argument "tpos" in those patterns to ensure operator precedence behaves as expected: - typeof(*tpos) - pos->next - x && y is changed for (x) && (y). The typeof(*tpos) lack of parentheses around "tpos" is not an issue per se in the specific macros modified here because "tpos" is used as an lvalue, which should prevent use of any operator causing issue. Still add the extra parentheses for consistency. Signed-off-by: Mathieu Desnoyers Cc: Andrew Morton Cc: "Paul E. McKenney" Cc: Andrew Morton Cc: Frederic Weisbecker Cc: Neeraj Upadhyay Cc: Joel Fernandes Cc: Josh Triplett Cc: Boqun Feng Cc: Steven Rostedt Cc: Lai Jiangshan Cc: Zqiang Cc: rcu@vger.kernel.org --- include/linux/rculist_bl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/rculist_bl.h b/include/linux/rculist_bl.h index 0b952d06eb0b..798c0a03bf5c 100644 --- a/include/linux/rculist_bl.h +++ b/include/linux/rculist_bl.h @@ -94,8 +94,8 @@ static inline void hlist_bl_add_head_rcu(struct hlist_bl_node *n, */ #define hlist_bl_for_each_entry_rcu(tpos, pos, head, member) \ for (pos = hlist_bl_first_rcu(head); \ - pos && \ - ({ tpos = hlist_bl_entry(pos, typeof(*tpos), member); 1; }); \ - pos = rcu_dereference_raw(pos->next)) + (pos) && \ + ({ tpos = hlist_bl_entry(pos, typeof(*(tpos)), member); 1; }); \ + pos = rcu_dereference_raw((pos)->next)) #endif From patchwork Thu May 4 20:05:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90239 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp608019vqo; Thu, 4 May 2023 14:07:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4vTR+qOYGE3OEnbSo9dWZbEzZtLk69y/cHYp6SDsWGJd0qEsaky0A+3BaP82eDikMKut/I X-Received: by 2002:a05:6a20:2d29:b0:f6:3548:e4af with SMTP id g41-20020a056a202d2900b000f63548e4afmr3587263pzl.25.1683234437712; Thu, 04 May 2023 14:07:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683234437; cv=none; d=google.com; s=arc-20160816; b=NQnCRam5+wnGSvAw5IGr38sIJFkiBRhhDAS3GVUJJKrb3LSUIZfoF5pkuAFh5RgMdm P2URtF6odjubxUfcXk7QkkDDy7UMpucUuTl32JRFPLPGKiQ2uj7R3GUoMKvKywBYzlEn /6TiBmBoFIZLBae3awKo2/SS69i26LCaPmAOJ8NbCQyZcGXwtKqUuwMRYlch5zOu9WoK CfAH9ABKb9MypRbFnWdbZZpxP24ZfOz17W3dOlLPntzqf4we6sSHV71fB8EmUoh7eXOP ZwqSTOwzs9irfYh6ZccoWpA9JX2wOG+gW9tjlAAuYZYy1oXhi3AdVptHhUJVqY1wh4cI 02Ng== 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=1VQS2KoVkI/aTYAAFLIuxRkcR9/+XB6RqMZhRjRUocg=; b=PWhYI3rWBFWNihTi3QnWdbkXjw/Tijrp0XXajyYiPmwPHC8dX7HgwhX9tNYAV7Z66r mf0JN7GGqoTiIxe096oEXEAaV/EwdnAHpfVbuYxDBoN39Ko0RoobIeKqun3I9K7FYLyv mK+nLfWW+iYELLJAfgZXZajQMSoTSFWeKf5oKWCTkKrgsdp8b83p4uDWmS1FvtXoG1eM mS6jYyVUHMgBL8AHRigl0/b9+ORpgH/JsV6YmC9+ple5OgY4YMIkEIyoIAoViMyLL1BP YJgXLmw6T2PVSeueD5uGR+0YU0tulecbicby/ABeVWHL6FkUE5QvzVXtQerdoDVFpJfA DEew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=RtnX8wDZ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h185-20020a6383c2000000b0052857fbb31dsi331493pge.200.2023.05.04.14.07.03; Thu, 04 May 2023 14:07:17 -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=RtnX8wDZ; 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 S229962AbjEDVBe (ORCPT + 99 others); Thu, 4 May 2023 17:01:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbjEDVBP (ORCPT ); Thu, 4 May 2023 17:01:15 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C737D13290 for ; Thu, 4 May 2023 14:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230733; bh=ejcZRhDyFKbQO0Pq2uphS/at1qd6mS5DdbQdmXOnDzQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RtnX8wDZcF6Jl+yg7Dd9MSRqmNfuJYg1Un9qlf5XhMvxdr7G3SPJ/NC7b1o0U9QqO xNNKCrM3RFPuHBRWMX+pbAOtU94c/g8K1MJU0el1F3YlFSF7/SjANB97oUp1US8g0J UxTEkVNVZwlmjmGS1aBGe9SsZ3VpWXSKRUvWu3Lqq9qoURob4coNjaJISbSgUX1s3j Anak7Axro4o4SYd8WD2cOd+aVuCq5K+uK3qdUX0vVv9SSVXEkiSt7D5CUPNO1DMv+2 oGikVrgtWGdvksFhIcg3vSW6JI7vKEVlBfKdpSWREnRpNFOL6qvBmK1E8wORIWPnLu TE7ZR+jxlRkEg== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Yn0vBhz122d; Thu, 4 May 2023 16:05:33 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Greg Kroah-Hartman , Andy Shevchenko , David Howells , Ricardo Martinez Subject: [RFC PATCH 05/13] list.h: Fix parentheses around macro pointer parameter use Date: Thu, 4 May 2023 16:05:19 -0400 Message-Id: <20230504200527.1935944-6-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764999233881761728?= X-GMAIL-MSGID: =?utf-8?q?1764999233881761728?= 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, - x && y is changed for (x) && (y). 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; list_for_each_entry((*t2), &testlist, node) { /* works */ //... } list_for_each_entry(*t2, &testlist, node) { /* broken */ //... } } // typeof(*pos) issue void f2(void) { struct test *t1 = NULL, *t2; t2 = list_prepare_entry((0 + t1), &testlist, node); /* works */ t2 = list_prepare_entry(0 + t1, &testlist, node); /* broken */ } Note that the macros in which "pos" is also used as an lvalue probably don't suffer from the lack of parentheses around "pos" in typeof(*pos), but add those nevertheless to keep everything consistent. Signed-off-by: Mathieu Desnoyers Cc: Andrew Morton Cc: Greg Kroah-Hartman Cc: Andy Shevchenko Cc: David Howells Cc: Ricardo Martinez --- include/linux/list.h | 54 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/include/linux/list.h b/include/linux/list.h index f10344dbad4d..d197b1a6f411 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -603,7 +603,7 @@ static inline void list_splice_tail_init(struct list_head *list, * @head: the head for your list. */ #define list_for_each(pos, head) \ - for (pos = (head)->next; !list_is_head(pos, (head)); pos = pos->next) + for (pos = (head)->next; !list_is_head(pos, head); pos = (pos)->next) /** * list_for_each_rcu - Iterate over a list in an RCU-safe fashion @@ -612,8 +612,8 @@ static inline void list_splice_tail_init(struct list_head *list, */ #define list_for_each_rcu(pos, head) \ for (pos = rcu_dereference((head)->next); \ - !list_is_head(pos, (head)); \ - pos = rcu_dereference(pos->next)) + !list_is_head(pos, head); \ + pos = rcu_dereference((pos)->next)) /** * list_for_each_continue - continue iteration over a list @@ -623,7 +623,7 @@ static inline void list_splice_tail_init(struct list_head *list, * Continue to iterate over a list, continuing after the current position. */ #define list_for_each_continue(pos, head) \ - for (pos = pos->next; !list_is_head(pos, (head)); pos = pos->next) + for (pos = (pos)->next; !list_is_head(pos, head); pos = (pos)->next) /** * list_for_each_prev - iterate over a list backwards @@ -631,7 +631,7 @@ static inline void list_splice_tail_init(struct list_head *list, * @head: the head for your list. */ #define list_for_each_prev(pos, head) \ - for (pos = (head)->prev; !list_is_head(pos, (head)); pos = pos->prev) + for (pos = (head)->prev; !list_is_head(pos, head); pos = (pos)->prev) /** * list_for_each_safe - iterate over a list safe against removal of list entry @@ -640,9 +640,9 @@ static inline void list_splice_tail_init(struct list_head *list, * @head: the head for your list. */ #define list_for_each_safe(pos, n, head) \ - for (pos = (head)->next, n = pos->next; \ - !list_is_head(pos, (head)); \ - pos = n, n = pos->next) + for (pos = (head)->next, n = (pos)->next; \ + !list_is_head(pos, head); \ + pos = (n), n = (pos)->next) /** * list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry @@ -651,9 +651,9 @@ static inline void list_splice_tail_init(struct list_head *list, * @head: the head for your list. */ #define list_for_each_prev_safe(pos, n, head) \ - for (pos = (head)->prev, n = pos->prev; \ - !list_is_head(pos, (head)); \ - pos = n, n = pos->prev) + for (pos = (head)->prev, n = (pos)->prev; \ + !list_is_head(pos, head); \ + pos = (n), n = (pos)->prev) /** * list_count_nodes - count nodes in the list @@ -677,7 +677,7 @@ static inline size_t list_count_nodes(struct list_head *head) * @member: the name of the list_head within the struct. */ #define list_entry_is_head(pos, head, member) \ - (&pos->member == (head)) + (&(pos)->member == (head)) /** * list_for_each_entry - iterate over list of given type @@ -686,7 +686,7 @@ static inline size_t list_count_nodes(struct list_head *head) * @member: the name of the list_head within the struct. */ #define list_for_each_entry(pos, head, member) \ - for (pos = list_first_entry(head, typeof(*pos), member); \ + for (pos = list_first_entry(head, typeof(*(pos)), member); \ !list_entry_is_head(pos, head, member); \ pos = list_next_entry(pos, member)) @@ -697,7 +697,7 @@ static inline size_t list_count_nodes(struct list_head *head) * @member: the name of the list_head within the struct. */ #define list_for_each_entry_reverse(pos, head, member) \ - for (pos = list_last_entry(head, typeof(*pos), member); \ + for (pos = list_last_entry(head, typeof(*(pos)), member); \ !list_entry_is_head(pos, head, member); \ pos = list_prev_entry(pos, member)) @@ -710,7 +710,7 @@ static inline size_t list_count_nodes(struct list_head *head) * Prepares a pos entry for use as a start point in list_for_each_entry_continue(). */ #define list_prepare_entry(pos, head, member) \ - ((pos) ? : list_entry(head, typeof(*pos), member)) + ((pos) ? : list_entry(head, typeof(*(pos)), member)) /** * list_for_each_entry_continue - continue iteration over list of given type @@ -773,10 +773,10 @@ static inline size_t list_count_nodes(struct list_head *head) * @member: the name of the list_head within the struct. */ #define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_first_entry(head, typeof(*pos), member), \ + for (pos = list_first_entry(head, typeof(*(pos)), member), \ n = list_next_entry(pos, member); \ !list_entry_is_head(pos, head, member); \ - pos = n, n = list_next_entry(n, member)) + pos = (n), n = list_next_entry(n, member)) /** * list_for_each_entry_safe_continue - continue list iteration safe against removal @@ -792,7 +792,7 @@ static inline size_t list_count_nodes(struct list_head *head) for (pos = list_next_entry(pos, member), \ n = list_next_entry(pos, member); \ !list_entry_is_head(pos, head, member); \ - pos = n, n = list_next_entry(n, member)) + pos = (n), n = list_next_entry(n, member)) /** * list_for_each_entry_safe_from - iterate over list from current point safe against removal @@ -807,7 +807,7 @@ static inline size_t list_count_nodes(struct list_head *head) #define list_for_each_entry_safe_from(pos, n, head, member) \ for (n = list_next_entry(pos, member); \ !list_entry_is_head(pos, head, member); \ - pos = n, n = list_next_entry(n, member)) + pos = (n), n = list_next_entry(n, member)) /** * list_for_each_entry_safe_reverse - iterate backwards over list safe against removal @@ -820,10 +820,10 @@ static inline size_t list_count_nodes(struct list_head *head) * of list entry. */ #define list_for_each_entry_safe_reverse(pos, n, head, member) \ - for (pos = list_last_entry(head, typeof(*pos), member), \ + for (pos = list_last_entry(head, typeof(*(pos)), member), \ n = list_prev_entry(pos, member); \ !list_entry_is_head(pos, head, member); \ - pos = n, n = list_prev_entry(n, member)) + pos = (n), n = list_prev_entry(n, member)) /** * list_safe_reset_next - reset a stale list_for_each_entry_safe loop @@ -1033,11 +1033,11 @@ static inline void hlist_move_list(struct hlist_head *old, #define hlist_entry(ptr, type, member) container_of(ptr,type,member) #define hlist_for_each(pos, head) \ - for (pos = (head)->first; pos ; pos = pos->next) + for (pos = (head)->first; pos ; pos = (pos)->next) #define hlist_for_each_safe(pos, n, head) \ - for (pos = (head)->first; pos && ({ n = pos->next; 1; }); \ - pos = n) + for (pos = (head)->first; (pos) && ({ n = (pos)->next; 1; }); \ + pos = (n)) #define hlist_entry_safe(ptr, type, member) \ ({ typeof(ptr) ____ptr = (ptr); \ @@ -1082,8 +1082,8 @@ static inline void hlist_move_list(struct hlist_head *old, * @member: the name of the hlist_node within the struct. */ #define hlist_for_each_entry_safe(pos, n, head, member) \ - for (pos = hlist_entry_safe((head)->first, typeof(*pos), member);\ - pos && ({ n = pos->member.next; 1; }); \ - pos = hlist_entry_safe(n, typeof(*pos), member)) + for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\ + (pos) && ({ n = (pos)->member.next; 1; }); \ + pos = hlist_entry_safe(n, typeof(*(pos)), member)) #endif From patchwork Thu May 4 20:05:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90236 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp603716vqo; Thu, 4 May 2023 14:01:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7VzuCkTy2lMnAhMZTqrMrfpd4q3FQBujd3qT7gacYL+FxPwKv4+q/tpHBZ42FZYZYy0uqe X-Received: by 2002:a17:90a:fb41:b0:24e:3254:5d94 with SMTP id iq1-20020a17090afb4100b0024e32545d94mr3189055pjb.40.1683234084487; Thu, 04 May 2023 14:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683234084; cv=none; d=google.com; s=arc-20160816; b=vZl0CkvGeD7v1TYqrRX/Hp+1mBNr7PsNnh756hE9c7Go0Qjr97hUFSnEq1ZNjiab9o 9cKdvi09S4o75gZVDDQ5j1Y+/TshjszluC4korCrdQAQdpyzEHI8Aoofho0pw6gd8ixI jTrozGZkAB4tfyiI67u7gmd8xfKIyI9+PdRgntEXJinh/piSoDIn0yVNDxZVoDkoYXRw daQ520wXACfsvmP+kovFguNeoLox+fboAZqA1dd/54vV4jdkPIImFc6YRpjJFPnZ8y8m bij23BAWJZNH9EWEBV3p6o1ZpGKhBPxy2/5Chqgbe+sflI6O3o2b9230ZwbkBIwQ+4L7 l/GA== 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=9ZzIAKfT9InAlFyzxC81nuZuDOW7gOvBeNUt/7jIN3Y=; b=Da0GZxd7SMAEc2ASgJiEb5mUQLQRTxknXOJ7wqi5vW56yOqCzVRu8Hi2D0Yyc6110t XpxQo3km+qrYcSrWPVuy2pEvS+hug4B8xcPpDKyYorHhr6GXKqvSleNfmSH0RsCQ/rsQ 273RPxjCLA6L79/IYh3/qmwk9Zpr1H+qq4PrsgnPUtTWk0+VP7SMs3mhMTPPZhagsjks V+Q4Jb1HpR0cYANAxxA2vaVC1UdanxeH3qgZgBS8jpt8/Tc1WqbNxgBiL0gtZ4u2grQp jo0vEsr2y72wK1YWP31LRgYFQA4bpCGf0kjIxGUNcBBMcMr1jU8DkKsP91GW72t2sVUK jU1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=QKHvDn6H; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rm12-20020a17090b3ecc00b0024681cc291csi5136822pjb.88.2023.05.04.14.00.57; Thu, 04 May 2023 14:01:24 -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=QKHvDn6H; 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 S229955AbjEDUsN (ORCPT + 99 others); Thu, 4 May 2023 16:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbjEDUry (ORCPT ); Thu, 4 May 2023 16:47:54 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0725AD22 for ; Thu, 4 May 2023 13:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230733; bh=dMinXl77eDsU1Swj1Mb43GwAjcr/wXhk2zDxp1xftSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QKHvDn6Hf3v0PHsQWe1RYRYUrA6cXCyH8x79TPvgUZp1EldRddS1HoRHyXcsej3KL MzttQmErR1tipru+dWJxiPqeOpKCqohr0r0M5qbIOZDWXzAmLatxqJ0tLt1uCERr7M Q1RjExLIPDuvuxS/aMp9Onj9KvtqU/4ZrjjOaZtq1NKCsBDDqRUcsYWyo4xfZ95yBG PUyU6YuACzZPsntH2K4lvKUXxuthxoyYcHxMO9vgdK2AOqRmCg5mK8kNG7hTuoX9W/ gz86VeH9i+KvGq8E07uXrGku3OO+Ub5r/oj/KUnkXfyjd3nMSC3dn7IEDYsroPjZDd V9kHHG34ChNxA== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Yn2d43z11qs; Thu, 4 May 2023 16:05:33 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Eric Dumazet Subject: [RFC PATCH 06/13] list_nulls.h: Fix parentheses around macro pointer parameter use Date: Thu, 4 May 2023 16:05:20 -0400 Message-Id: <20230504200527.1935944-7-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 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_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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764998863714793322?= X-GMAIL-MSGID: =?utf-8?q?1764998863714793322?= Add missing parentheses around use of macro argument "pos" in those patterns to ensure operator precedence behaves as expected: - typeof(*tpos) - pos->next The typeof(*tpos) lack of parentheses around "tpos" is not an issue per se in the specific macros modified here because "tpos" is used as an lvalue, which should prevent use of any operator causing issue. Still add the extra parentheses for consistency. Signed-off-by: Mathieu Desnoyers Cc: Andrew Morton Cc: Eric Dumazet --- include/linux/list_nulls.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/list_nulls.h b/include/linux/list_nulls.h index fa6e8471bd22..74ffde881e44 100644 --- a/include/linux/list_nulls.h +++ b/include/linux/list_nulls.h @@ -127,8 +127,8 @@ static inline void hlist_nulls_del(struct hlist_nulls_node *n) #define hlist_nulls_for_each_entry(tpos, pos, head, member) \ for (pos = (head)->first; \ (!is_a_nulls(pos)) && \ - ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); 1;}); \ - pos = pos->next) + ({ tpos = hlist_nulls_entry(pos, typeof(*(tpos)), member); 1;}); \ + pos = (pos)->next) /** * hlist_nulls_for_each_entry_from - iterate over a hlist continuing from current point @@ -139,7 +139,7 @@ static inline void hlist_nulls_del(struct hlist_nulls_node *n) */ #define hlist_nulls_for_each_entry_from(tpos, pos, member) \ for (; (!is_a_nulls(pos)) && \ - ({ tpos = hlist_nulls_entry(pos, typeof(*tpos), member); 1;}); \ - pos = pos->next) + ({ tpos = hlist_nulls_entry(pos, typeof(*(tpos)), member); 1;}); \ + pos = (pos)->next) #endif From patchwork Thu May 4 20:05:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90245 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp616186vqo; Thu, 4 May 2023 14:23:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6JknG2c3Lpd4cCVRS0inebmGZwo+fgiTqZLP+gP/92uaaDGKbUp7NG+5ILjFfr60BYBgM2 X-Received: by 2002:a05:6a20:1616:b0:ee:f5a4:c064 with SMTP id l22-20020a056a20161600b000eef5a4c064mr3670053pzj.62.1683235409002; Thu, 04 May 2023 14:23:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683235408; cv=none; d=google.com; s=arc-20160816; b=Ck/8Slaqx1pjAPYCSFkKHHJ/R3pB9h5KEgglCLHgark4NC6qzcw4KD0YXvdpbVujx6 ctW+xQ0yBdNIyfj21/g0Y2iFE3V0erqb7C0PtfljdPlxeypNAfmqcm0nSMGPPbZpNnpo jWioNU5HauWGIxFK2e0/Bhas4UWqVstw8HGu6/m8Qra/jB3JsODGMAgXZL8vcXa1A1St cKaksbEBbPyIBiD0u4ZZgvxENOjs2f7GZb8ayYSxA8hEI2K8fKgZUbtR50K+BCxAE6R0 wKzR9jzkcecbq8+jPXvMJsmfXsZWZvS4siTq9w5lkVO/508Wey6NKsvfiC2UOL3+8Z69 TUnw== 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=LM+3H8dLN0nAcKQLW+3LBfFpWVETNu8c+RfxD3XsFAQ=; b=MTQC+Npp9AA2S7Uvo72Ta/KjKuJsYuHgSwz9EstOJlI89pp1jE3nwRUxmcH5OembxQ Fl9S9yDT2RPxt6xU8PBvQ0RJG+QNRrCCjNsRjYT9PB8Yk+7MVvgoXhjwfRII49vOM1Xi 1+vFZiC5uLrh/C8AbaRXL19EmbRDiGPv6XT5bLIipXQHxA7pGOPYKsxtlsRweNhw3Bya KZzdQYlZEiMz0qO5HiQx8TGPujcmr9i1GaCTsqtivYxDnIV1nuc1GxX88sxQcKrHKhf6 TX0IBiW9q5NczT36vVv/dDy+0n1n67qDUb9w+XodI8/ufgfEF/cEbRXnEgCpm6adCdMc twVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=toqxukN7; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 73-20020a63004c000000b0051bb433f5bbsi359727pga.386.2023.05.04.14.23.14; Thu, 04 May 2023 14:23:28 -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=toqxukN7; 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 S229872AbjEDUwO (ORCPT + 99 others); Thu, 4 May 2023 16:52:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbjEDUwM (ORCPT ); Thu, 4 May 2023 16:52:12 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9ECD93FE for ; Thu, 4 May 2023 13:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230733; bh=d1KfLyc6kB5wDCv4ypHLZjfVgQsbxIXbUETDS35Ubh0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=toqxukN7T7Av2eyJcYL2ReSsGzK35iliPKL5M9vE69O5uZjYjlUmjCXQrvge67SxK hP9j6ab2jjsexqBW5FeevpasCXjAp+BCOdVUEy5fj7Wsu76oJrbE+jcBb6E3K1J0S6 a/DB/3f2G1yaU2zI24mI8/oZ9SziaFFLNf99ryEp8mnnwAZC8UeoqW6vxn9VWnE9NF SzcMpF+SbmjpAB2+18ZxFWorz57tY7oOcbmcXwkafxxBX84WvWHBoQ3OfRUj0qy8kG TgotT3nEWmSh86Z1yYRb6zKbuqlRMW4G8iKlykQDNbMuWFKcbYze6Oacc3KXPhIu3+ 60KbS6+/3qpzA== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Yn3w9Nz11qt; Thu, 4 May 2023 16:05:33 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Nick Piggin Subject: [RFC PATCH 07/13] list_bl.h: Fix parentheses around macro pointer parameter use Date: Thu, 4 May 2023 16:05:21 -0400 Message-Id: <20230504200527.1935944-8-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765000252189100112?= X-GMAIL-MSGID: =?utf-8?q?1765000252189100112?= Add missing parentheses around use of macro argument "tpos" in those patterns to ensure operator precedence behaves as expected: - typeof(*tpos) - pos->next - "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. - x && y is changed for (x) && (y). The typeof(*tpos) lack of parentheses around "tpos" is not an issue per se in the specific macros modified here because "tpos" is used as an lvalue, which should prevent use of any operator causing issue. Still add the extra parentheses for consistency. Signed-off-by: Mathieu Desnoyers Cc: Andrew Morton Cc: Nick Piggin --- include/linux/list_bl.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h index ae1b541446c9..450cca15496b 100644 --- a/include/linux/list_bl.h +++ b/include/linux/list_bl.h @@ -168,9 +168,9 @@ static inline bool hlist_bl_is_locked(struct hlist_bl_head *b) */ #define hlist_bl_for_each_entry(tpos, pos, head, member) \ for (pos = hlist_bl_first(head); \ - pos && \ - ({ tpos = hlist_bl_entry(pos, typeof(*tpos), member); 1;}); \ - pos = pos->next) + (pos) && \ + ({ tpos = hlist_bl_entry(pos, typeof(*(tpos)), member); 1;}); \ + pos = (pos)->next) /** * hlist_bl_for_each_entry_safe - iterate over list of given type safe against removal of list entry @@ -182,8 +182,8 @@ static inline bool hlist_bl_is_locked(struct hlist_bl_head *b) */ #define hlist_bl_for_each_entry_safe(tpos, pos, n, head, member) \ for (pos = hlist_bl_first(head); \ - pos && ({ n = pos->next; 1; }) && \ - ({ tpos = hlist_bl_entry(pos, typeof(*tpos), member); 1;}); \ - pos = n) + (pos) && ({ n = (pos)->next; 1; }) && \ + ({ tpos = hlist_bl_entry(pos, typeof(*(tpos)), member); 1;}); \ + pos = (n)) #endif From patchwork Thu May 4 20:05:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp600727vqo; Thu, 4 May 2023 13:55:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6QTHVzVhSvgJLyoEAqvNJut2CGzu1B/bG5U93Bghe4gBhv4CktrI/tSC2BnkSeVmoRajBq X-Received: by 2002:a05:6a21:3983:b0:f3:1c8b:ce62 with SMTP id ad3-20020a056a21398300b000f31c8bce62mr3303065pzc.47.1683233723981; Thu, 04 May 2023 13:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683233723; cv=none; d=google.com; s=arc-20160816; b=B0gFszwgu7vDUtvcjB9gJmR3rnalaZ6IwU0iKV0NB3RNPmqp0VimXA83GUrIdcrg4a NnhA3Uh0jXanyYbnnKFcKXJbHUEhIcIRqAlhs9eZ/YD3TAaAKJMoE8y+oWTdxiK3+l1H ohVXSw1Wuia7rgeekCwoiBU8UreXY3ZQ8pk2p0BB7Nm2c6mJQZrQTuL2hBGdai4UF9vl frEG1dZsslPlQmp8+NnnICvy12MNgPyB8Aj4e0FsToNwtfiJL0TrIkqxqsrJ5Vlz62mZ vxuu6GJXa2PNahCgKOfwyOg672NQWVTni2S+8KbfFWyBLWLfChEdp0EV7Z7syZvKRtGv Jxzw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t28-20020a63b25c000000b0050c0a7a2742si294806pgo.350.2023.05.04.13.55.11; Thu, 04 May 2023 13:55:23 -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 S229977AbjEDUsQ (ORCPT + 99 others); Thu, 4 May 2023 16:48:16 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764998485788848214?= X-GMAIL-MSGID: =?utf-8?q?1764998485788848214?= 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 From patchwork Thu May 4 20:05:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90244 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp611647vqo; Thu, 4 May 2023 14:13:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Qwa9YLZuiDfErefCLMir/4KfxnXbfuR78zCxZPYC+cK93+PeHaNiAsZefOuobFsTNEP9U X-Received: by 2002:a17:902:9b8a:b0:1a9:7e44:17 with SMTP id y10-20020a1709029b8a00b001a97e440017mr4523048plp.17.1683234820311; Thu, 04 May 2023 14:13:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683234820; cv=none; d=google.com; s=arc-20160816; b=ZbpdNx9JNdRPOlLUnbhmqnMAq64cdL1hTAtLS8k68vYAMpaIbgPau0ff2lLFmsVrOE C4SS/x/0Bx0UI23Obxe73NeXTPFfaOqCGD8f7zlAfGWhhhWvAfUmznRC8HhAKy1bpz/h DO344rTGcnYCXA9x0VNcE1IMZ6VcQkDEiDJBB3hxESzCHnb8Dp/SSB0rOTUh7UVcyLc+ zGOI10LO6EHI3F65nvvEKd7l0IQfHrOj1W0hd65jZDG9MhQxWyDbaGOHWFsN22l9tHFB EL6+YzgqmbKVr7iOlXg/22obkeEaB6r+F7w3R5DMnYgmjYR/ag1sgrPXIllbn3F/M+Rz MAMQ== 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=Bubf55MzW5emAv6+LlabL3jgrNnqs2qrHUIhSugWFXg=; b=CGECY/h04LEi39c9w7O9acRZmKxzhMDepyie/tTMfniQCtC7iXMNq2h2ZPw5TKpldq tUzIwOedaX4gi/i+lG2bLHpvz1inaN1Njj3UUrC3D8fbYEvo4BxISIfauu9TnyjA+GbH Bk2wI/zsAwtSBQCI9iG5CxZsHVyt9DrcgS9Qidr/UVX+XvM+0pccliZ+ooXER2Gko0Q9 nLZN+pP4HP2hPFaHrjFZpEFnSFQldrgrVAFEGaaJzX8/c/D4OtZ1LsMWlhJfXBPPV0Jf jDq8CiH5J0a9hFEVJRQLQvRo7RM+XlESVaGhRyk9N2CT4iEInCBByXwl5JsFSWq9RBUT D7Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=jxPC214C; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jb22-20020a170903259600b001a9b2c782ddsi17802543plb.176.2023.05.04.14.13.26; Thu, 04 May 2023 14:13:40 -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=jxPC214C; 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 S229959AbjEDUwR (ORCPT + 99 others); Thu, 4 May 2023 16:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229607AbjEDUwM (ORCPT ); Thu, 4 May 2023 16:52:12 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A80E41982 for ; Thu, 4 May 2023 13:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230734; bh=dJQRAkXY/sZd+jGAwjtNNNkqluNx5CFdlblILWEd/ho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jxPC214CyqN3DWs2Lz4/8H6/dXwg9FXVbDVTrZWqDb53iOczpo8qSltyhMXsKwuUh mSGGhtlybyKW4PFy+3RZ0T4kXVvvAKZfEfsw595k3mDQC88GSyd96HZKORmxy7TUVi 4x2hGCby5njBz7+1n1eHcSfOKRHXatuQfYo+JlzLfz5vtcR0IAKJSPVydnIwfIbixw YieXJzykgzJAAgUD7XiTv1NnDBZwtM7iPetRzlC1GsbFhNJAtPtWCsvcpc+RvXvzil tAVfs5s2eRdOsvr6/BJll1vB+hBp0drnQl1WEsbZpdrfIJp6nMwYZxHksGKdNsok70 L+TBIKiWk4Ulg== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Yn75Q6z11jG; Thu, 4 May 2023 16:05:33 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Tejun Heo , Peter Zijlstra Subject: [RFC PATCH 09/13] klist.h: Fix parentheses around macro parameter use Date: Thu, 4 May 2023 16:05:23 -0400 Message-Id: <20230504200527.1935944-10-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764999635073359425?= X-GMAIL-MSGID: =?utf-8?q?1764999635073359425?= Add missing parentheses around "_name" parameter use in KLIST_INIT(). It keeps list macros consistent, and prevents unexpected operator precedence situations, for example: struct klist a[1] = { KLIST_INIT(*a, NULL, NULL) }; Where the "." operator within KLIST_INIT() is evaluated before the "*" operator. Add missing parentheses around macro parameter use in the following patterns to ensure operator precedence behaves as expected: - "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. Signed-off-by: Mathieu Desnoyers Cc: Andrew Morton Cc: Tejun Heo Cc: Peter Zijlstra --- include/linux/klist.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/klist.h b/include/linux/klist.h index b0f238f20dbb..d7e0612ca4ff 100644 --- a/include/linux/klist.h +++ b/include/linux/klist.h @@ -23,10 +23,10 @@ struct klist { } __attribute__ ((aligned (sizeof(void *)))); #define KLIST_INIT(_name, _get, _put) \ - { .k_lock = __SPIN_LOCK_UNLOCKED(_name.k_lock), \ - .k_list = LIST_HEAD_INIT(_name.k_list), \ - .get = _get, \ - .put = _put, } + { .k_lock = __SPIN_LOCK_UNLOCKED((_name).k_lock), \ + .k_list = LIST_HEAD_INIT((_name).k_list), \ + .get = (_get), \ + .put = (_put), } #define DEFINE_KLIST(_name, _get, _put) \ struct klist _name = KLIST_INIT(_name, _get, _put) From patchwork Thu May 4 20:05:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp609149vqo; Thu, 4 May 2023 14:09:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5t1U4Z4nDttmSiD5HSm770gG7myWIX4Jrxv8OAtZWu7+0bqI6IJcaxyl9PbWr4FKhM3LI1 X-Received: by 2002:a17:902:7d85:b0:1a8:bc5:4912 with SMTP id a5-20020a1709027d8500b001a80bc54912mr4593098plm.52.1683234550314; Thu, 04 May 2023 14:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683234550; cv=none; d=google.com; s=arc-20160816; b=YHag5JENFXWtcjfsHzQGzh7eql1k+yBkCk1IDCTuoeuC8mpXG7JjtjVcrnESMV9PZf 1whq3eGAgLzx9PKDNtPX6qaIFF654HpWs80TAvkApuB2NPXsM56+/hUOsf8T1BenbhjX xq6RUgyIq2f11peERmSc+p9TIb54AmpITfcd1grQbJzIPSiWOxw2SLBEaw0+sYe5aCNJ hBE31CQdMvmvClpz7JGPtdxvmFmVH07AsEiMW+ED+BMMWduTsPG7QUXw/T6MVrjEgfHG Nejosl9Z61Axdjs1BRP0wEvte7SQyHqF12MYxEGUewus4/K7EJ6ZtfDnRqQnuzC0Fh4U zhZg== 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=8E9tCuc8caFbaCRIHqxlR5dNn5NMNoGkMgzVPGqCktk=; b=1D1Mx+0QImL2JnLJsl7OrUIGQtsFAe+AqdPXK2a9OHM5e3QP6JlUdwz5bNCwegkeMO Ac0V3TjalhezizSz5XwacvB0csKmyX8DxfMqq0s2P2u+sUTplFxlK5MBqymbCVQHSkm0 d3TnxNsGJNuWw0xVdjw4dWOWxDpsreg7Wa1LZml+Y+T0eo0uW3J1cz3vjFCCfCjpnFnz QgLX/ic4ydBW+QKtvHgDbfR1C+7SrFIO1zvDz4QiC6W4AEwOSAaLo+WeJxttbVPVjab0 P36NsvM/Tb1rbqVzfChKnuL2nojMwau+hbW8o5z0kNSrNqJhTyxDqpQGm9C38MLl90p5 LI8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b="O8/ofAq1"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rm12-20020a17090b3ecc00b0024681cc291csi5136822pjb.88.2023.05.04.14.08.55; Thu, 04 May 2023 14:09:10 -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="O8/ofAq1"; 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 S230376AbjEDVCL (ORCPT + 99 others); Thu, 4 May 2023 17:02:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbjEDVBj (ORCPT ); Thu, 4 May 2023 17:01:39 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AA6A14E61 for ; Thu, 4 May 2023 14:01:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230734; bh=4SJMp1te2JkZx1CFuIwS27tlAnRiNSVpgrNwcTggKBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O8/ofAq1zgKtNVBwizAqBo6VPHz1KvIuRHyyIfW/cPGoa7HBxwdD9IsDlm6MCfCtU 1Xq0ctKQjJZsSymzJWterSninx0fyNR8uNTt9RPL7HoqCGPi5ltJh72eT959mbzWgI enh/p1OD/wGmFU6zjf73ft0NWHva2NXDvyOaeyvmKW2J6w4fgUDmRMByTkDG/Yu87m HaISwZxSXkZzBXIqxuRTqQqcNofwWRm66ELNBvhTuDtu7UBZm2kD53A49JLxV+JThy cMYcG2P2Kx2EaxdL5zwM9Cz/N67dTecAMHrvHfzTAdLhGGJ7PidlDOgDOh5QOSn43U +E94H2JQg/gBw== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Yp1R7Yz11jH; Thu, 4 May 2023 16:05:34 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Jiang Liu Subject: [RFC PATCH 10/13] resource_ext.h: Remove useless parentheses around macro parameters Date: Thu, 4 May 2023 16:05:24 -0400 Message-Id: <20230504200527.1935944-11-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764999352027187105?= X-GMAIL-MSGID: =?utf-8?q?1764999352027187105?= Parentheses around macro parameters which are surrounded by commas is a scenario where those added parentheses are useless, because the comma is the operator with the lowest precedence. Remove those useless parentheses to make list iteration code consistent across kernel headers. Signed-off-by: Mathieu Desnoyers Cc: Andrew Morton Cc: Jiang Liu --- include/linux/resource_ext.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/resource_ext.h b/include/linux/resource_ext.h index ff0339df56af..f4a3c0040886 100644 --- a/include/linux/resource_ext.h +++ b/include/linux/resource_ext.h @@ -60,11 +60,11 @@ resource_list_destroy_entry(struct resource_entry *entry) resource_list_free_entry(entry); } -#define resource_list_for_each_entry(entry, list) \ - list_for_each_entry((entry), (list), node) +#define resource_list_for_each_entry(entry, list) \ + list_for_each_entry(entry, list, node) #define resource_list_for_each_entry_safe(entry, tmp, list) \ - list_for_each_entry_safe((entry), (tmp), (list), node) + list_for_each_entry_safe(entry, tmp, list, node) static inline struct resource_entry * resource_list_first_type(struct list_head *list, unsigned long type) From patchwork Thu May 4 20:05:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90242 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp609483vqo; Thu, 4 May 2023 14:09:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5OxONoUXPBSjtr0/Axnx1PzTkzWrn4qEM0+/cLqPHbYQsfDLPbbsv8nir5Xdk6PTH19DDy X-Received: by 2002:a17:90b:3592:b0:247:35c7:bd67 with SMTP id mm18-20020a17090b359200b0024735c7bd67mr3312689pjb.46.1683234589523; Thu, 04 May 2023 14:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683234589; cv=none; d=google.com; s=arc-20160816; b=H4lRyet4G5ScKx6w13QDxdbZUNlA/DR7mq6ng3BqZadIVTJ163tKHaggFXaLNcxSWj Rko8xhGVz8MxIpfQxKvDppEkPQNa1Az8p0petTM23rb/VYtCslT2Z51DbZLrstHAUFan oE98PM+A5EqHJcsBYCy2TEHcLYCXuuhqFzpqkyAilJi1GwRkieLjLXZZgqVOqRdMy5On wdSy+eeCbiH/u0y0EFahsgfrdrHeqa53MN52SgkLdXoExoin1CU556U6fcXFEghCXn0q AA8IFNVU8kIOe1aYgWbVQI9T/JxK04SJYuMLuvg3amI2Hzb1VAzIlOYNXPDSfxOgHZbm r5WA== 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=KqlCASvx3Lriit5qvu9KDdo/u6rvrJrwdo5bXhas5d8=; b=QIihuLUjNchF/M2hQTlnLupXXWuJLcCh9SZFDdBEadRVU+LPkca+pN8XfRTgEPsleU nkvzEie8/YFqyz2Ssc9VBInPEcKDi9BpqUpAWQk5s9hG/ldgRPGQfAP78glSHkUQ+E1r TRkAg3tjct13hoSht4+22GClnQsF6uxXe4jI3+aZ6R7/xNxy1pLUU+kruTM0AFXVS6OW Ak2VPchCHQkYtFZjzkZO+ww+YKqXoBTBxuwK9QMAtlpOck4dgtDaiI09cbjH6qBFivXK DN1K1afP3doyzonXpI/N/JMY9uuN10ZSgme5qEBLAKKx6oM3q1o6gpV8XLaS7nsZ8oF9 mLnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=j4elbQnq; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rm12-20020a17090b3ecc00b0024681cc291csi5136822pjb.88.2023.05.04.14.09.35; Thu, 04 May 2023 14:09:49 -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=j4elbQnq; 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 S230327AbjEDVCW (ORCPT + 99 others); Thu, 4 May 2023 17:02:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230502AbjEDVBo (ORCPT ); Thu, 4 May 2023 17:01:44 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A04CCAD25; Thu, 4 May 2023 14:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230734; bh=4eWXzqJGW3r8CsJlCJi50P2D2+UPMfjU80F5mDNGm64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j4elbQnqRi3jTLzFpSiA0lk6IUePnELvzLSch+U+lB44pmffUULxho7cstr32fRmp yyx1I+uF0AnCbCfOeFuhbpm9M+MKLg3C4I0HuLxBmbbEeVApWLWZDZ8PL8JKHyf52K 13KvbCwD6QqP5tZR/5f610cJ4pLH1mRtE2vw0WUp2+pvQuWZgzCXbomISIxP/sd/u7 cA0w22qS71+/mFkQ6qgxcoQVSCrPm+fOwAuiNHV/Ve2xDcRtJT8qpXrdm/z12eKFGR T3pJWBfjoN+FX3vOSg9dJ8gqXIA00bDqrxNK+2LL6Y+7FuE0di03m3j7FiuY4jVvTT CFcEQmkiCs0/A== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Yp2nzCz11jJ; Thu, 4 May 2023 16:05:34 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Subject: [RFC PATCH 11/13] netdevice.h: Fix parentheses around macro parameter use Date: Thu, 4 May 2023 16:05:25 -0400 Message-Id: <20230504200527.1935944-12-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764999393099283428?= X-GMAIL-MSGID: =?utf-8?q?1764999393099283428?= Add missing parentheses around macro parameter use in the following pattern: - "x - 1" changed for "(x) - 1", - "x->member" changed for "(x)->member". to ensure operator precedence behaves as expected. Remove useless parentheses around macro parameter use in the following pattern: - m((x), y) changed for m(x, y), because comma has the lowest operator precedence, which makes the extra comma useless. Signed-off-by: Mathieu Desnoyers Cc: Andrew Morton Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org --- include/linux/netdevice.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 08fbd4622ccf..5a357262a45b 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -283,7 +283,7 @@ struct hh_cache { /* cached hardware header; allow for machine alignment needs. */ #define HH_DATA_MOD 16 #define HH_DATA_OFF(__len) \ - (HH_DATA_MOD - (((__len - 1) & (HH_DATA_MOD - 1)) + 1)) + (HH_DATA_MOD - ((((__len) - 1) & (HH_DATA_MOD - 1)) + 1)) #define HH_DATA_ALIGN(__len) \ (((__len)+(HH_DATA_MOD-1))&~(HH_DATA_MOD - 1)) unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)]; @@ -4459,7 +4459,7 @@ static inline void netif_tx_unlock_bh(struct net_device *dev) } #define HARD_TX_LOCK(dev, txq, cpu) { \ - if ((dev->features & NETIF_F_LLTX) == 0) { \ + if (((dev)->features & NETIF_F_LLTX) == 0) { \ __netif_tx_lock(txq, cpu); \ } else { \ __netif_tx_acquire(txq); \ @@ -4467,12 +4467,12 @@ static inline void netif_tx_unlock_bh(struct net_device *dev) } #define HARD_TX_TRYLOCK(dev, txq) \ - (((dev->features & NETIF_F_LLTX) == 0) ? \ + ((((dev)->features & NETIF_F_LLTX) == 0) ? \ __netif_tx_trylock(txq) : \ __netif_tx_acquire(txq)) #define HARD_TX_UNLOCK(dev, txq) { \ - if ((dev->features & NETIF_F_LLTX) == 0) { \ + if (((dev)->features & NETIF_F_LLTX) == 0) { \ __netif_tx_unlock(txq); \ } else { \ __netif_tx_release(txq); \ @@ -4534,7 +4534,7 @@ static inline void netif_addr_unlock_bh(struct net_device *dev) * rcu_read_lock held. */ #define for_each_dev_addr(dev, ha) \ - list_for_each_entry_rcu(ha, &dev->dev_addrs.list, list) + list_for_each_entry_rcu(ha, &(dev)->dev_addrs.list, list) /* These functions live elsewhere (drivers/net/net_init.c, but related) */ @@ -5237,6 +5237,6 @@ extern struct net_device *blackhole_netdev; /* Note: Avoid these macros in fast path, prefer per-cpu or per-queue counters. */ #define DEV_STATS_INC(DEV, FIELD) atomic_long_inc(&(DEV)->stats.__##FIELD) #define DEV_STATS_ADD(DEV, FIELD, VAL) \ - atomic_long_add((VAL), &(DEV)->stats.__##FIELD) + atomic_long_add(VAL, &(DEV)->stats.__##FIELD) #endif /* _LINUX_NETDEVICE_H */ From patchwork Thu May 4 20:05:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90248 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp618253vqo; Thu, 4 May 2023 14:28:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4uPAnBJn0fGx0LYAP4OdpjMGn46B1b7onD36uzcapwPQf4YAkDsVyXpKZmPHMEo1gPpfll X-Received: by 2002:a05:6a00:2e10:b0:643:59ed:5dc9 with SMTP id fc16-20020a056a002e1000b0064359ed5dc9mr3770213pfb.12.1683235715750; Thu, 04 May 2023 14:28:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683235715; cv=none; d=google.com; s=arc-20160816; b=DXqEopNZ0/bdy3AXjjQA+ytf5NUmy33RzNt0vKgDLAkefs9qK4h2/pwEBpbkjti4Sn 8V7H2YaP5gcHVMEZmN41k2DhXymZk8Dr7aozY2Q4NavpZzSOrkRF3FIEOWmfd6q9Uu5I OK/A6ULNsV8zNMMr7ySPVUduKUSdpuQ0T2Zr3xunZPumYPp4eeonTksbJPQWChuvd6+b W5QsDI3RlComT9Wv8hJA86NAnqsspJ2Dbo2wXX1hob21dbu8+MHRDvyqJO7eQoQFY1oL 97MRj62lOs+IlaYeC3k1HUoQqp9ZEKKPvkR0y0CK00o1I+iNYfRxVXMtt/kwZ4jsLoQ8 fWWA== 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=yyXpP8PvqVtvlym95zFbHOX4gLgLeLMJqvpcQmhZ82Y=; b=ABWXuv+oYtG0oWcxYBLCfCqAHJU7GRzFp7SU6SEWg1O5NhlakV7iuH/LGlqRV8wuX/ BtmT3Fzzp/3RSJvYNyzzA2Q2EeBhWGlaa90cjio315zWnS8OG9gGuzPyKDqr/QUudQdK DH3+OnuTHf8PjC48lopuNaLLNegnm46IC99xrSd9J12V+OmWP5qNGXkxy9IYtPQYfGC4 GvSmgK5qWQw359LfNq3gTFw6YdQqGgmSjEhRfSFY7wqN+G3+zYs/9ogke2M/m7VEywbS edK+HMydv2lDJy8ngyax2UQ2hlxDXD7fs1NpVI9utKWl9LZlhIhcnzXioqfdF9DWeAi4 gnNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=tc4yMe+d; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z190-20020a6265c7000000b006434d66f94dsi388841pfb.31.2023.05.04.14.28.04; Thu, 04 May 2023 14:28:35 -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=tc4yMe+d; 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 S230010AbjEDVCs (ORCPT + 99 others); Thu, 4 May 2023 17:02:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230090AbjEDVCO (ORCPT ); Thu, 4 May 2023 17:02:14 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A2EE1734; Thu, 4 May 2023 14:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230734; bh=1jfyZJuK4k9g5CEpe8gCUedeSdOIfbCNOZJDVvTtWOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tc4yMe+dNevzwFlfwp6HT3GKbEIZ6zDHUt7WxxxM2l5wvdmhFhE9c2ghavf7lfuXS yUOE9TorFjIilwout/zxZzthJA7GU5yXGedxPlWJ74oWHfbnpweJw+vaj+pn/56sDb KH+wazgLGkoJ6Bg/zeJ3vxNWomkPYz6NRNSMYWI5B1Kdo8/SUQmylzqb9EmiiuxKak Sq8X+1DXrgbHEkZ7qYTavuig7dN1ZoNTYXWb14q1N8jptcqJRQL0IFUP4+a5u/TXdw uPh0Bi7AIGDnVvnBt+jv2S25RvMgLq99tCBREknHhixsLetxD70RhzKQhrelXcsDQE Z535jfxloZg1w== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Yp4cDXz11wl; Thu, 4 May 2023 16:05:34 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Jens Axboe , linux-block@vger.kernel.org Subject: [RFC PATCH 12/13] blk-mq.h: Fix parentheses around macro parameter use Date: Thu, 4 May 2023 16:05:26 -0400 Message-Id: <20230504200527.1935944-13-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 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_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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765000573911919693?= X-GMAIL-MSGID: =?utf-8?q?1765000573911919693?= Fix the following macro parameter usage patterns in blk-mq.h for consistency, ensuring that operator precedence is respected: Added parentheses: - x->member is changed for (x)->member, - x.member is changed for (x).member, - flags >> BLK_MQ_F_ALLOC_POLICY_START_BIT is changed for (flags) >> BLK_MQ_F_ALLOC_POLICY_START_BIT. - "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. Removed parentheses: - m((x)) is changed for m(x) (the extra parentheses are useless), - m(x, (y), (z)) is changed for m(x, y, z), because comma is the lowest priority operator, and thus the extra parentheses are useless, - v[(x)] is changed for v[x], because the extra parentheses are useless given that [] already surrounds an expression, - "(i) = 0" is changed for "i = 0", because "i" is an lvalue, which makes the extra parentheses useless. Signed-off-by: Mathieu Desnoyers Cc: Andrew Morton Cc: Jens Axboe Cc: linux-block@vger.kernel.org --- include/linux/blk-mq.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 06caacd77ed6..4de6ad92530c 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -223,13 +223,13 @@ static inline unsigned short req_get_ioprio(struct request *req) #define rq_list_add(listptr, rq) do { \ (rq)->rq_next = *(listptr); \ - *(listptr) = rq; \ + *(listptr) = (rq); \ } while (0) #define rq_list_add_tail(lastpptr, rq) do { \ (rq)->rq_next = NULL; \ - **(lastpptr) = rq; \ - *(lastpptr) = &rq->rq_next; \ + **(lastpptr) = (rq); \ + *(lastpptr) = &(rq)->rq_next; \ } while (0) #define rq_list_pop(listptr) \ @@ -251,11 +251,11 @@ static inline unsigned short req_get_ioprio(struct request *req) }) #define rq_list_for_each(listptr, pos) \ - for (pos = rq_list_peek((listptr)); pos; pos = rq_list_next(pos)) + for (pos = rq_list_peek(listptr); pos; pos = rq_list_next(pos)) #define rq_list_for_each_safe(listptr, pos, nxt) \ - for (pos = rq_list_peek((listptr)), nxt = rq_list_next(pos); \ - pos; pos = nxt, nxt = pos ? rq_list_next(pos) : NULL) + for (pos = rq_list_peek(listptr), nxt = rq_list_next(pos); \ + pos; pos = (nxt), nxt = (pos) ? rq_list_next(pos) : NULL) #define rq_list_next(rq) (rq)->rq_next #define rq_list_empty(list) ((list) == (struct request *) NULL) @@ -692,10 +692,10 @@ enum { BLK_MQ_CPU_WORK_BATCH = 8, }; #define BLK_MQ_FLAG_TO_ALLOC_POLICY(flags) \ - ((flags >> BLK_MQ_F_ALLOC_POLICY_START_BIT) & \ + (((flags) >> BLK_MQ_F_ALLOC_POLICY_START_BIT) & \ ((1 << BLK_MQ_F_ALLOC_POLICY_BITS) - 1)) #define BLK_ALLOC_POLICY_TO_MQ_FLAG(policy) \ - ((policy & ((1 << BLK_MQ_F_ALLOC_POLICY_BITS) - 1)) \ + (((policy) & ((1 << BLK_MQ_F_ALLOC_POLICY_BITS) - 1)) \ << BLK_MQ_F_ALLOC_POLICY_START_BIT) #define BLK_MQ_NO_HCTX_IDX (-1U) @@ -948,11 +948,11 @@ static inline void *blk_mq_rq_to_pdu(struct request *rq) } #define queue_for_each_hw_ctx(q, hctx, i) \ - xa_for_each(&(q)->hctx_table, (i), (hctx)) + xa_for_each(&(q)->hctx_table, i, hctx) #define hctx_for_each_ctx(hctx, ctx, i) \ - for ((i) = 0; (i) < (hctx)->nr_ctx && \ - ({ ctx = (hctx)->ctxs[(i)]; 1; }); (i)++) + for (i = 0; (i) < (hctx)->nr_ctx && \ + ({ ctx = (hctx)->ctxs[i]; 1; }); (i)++) static inline void blk_mq_cleanup_rq(struct request *rq) { @@ -1013,20 +1013,20 @@ struct req_iterator { }; #define __rq_for_each_bio(_bio, rq) \ - if ((rq->bio)) \ - for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next) + if ((rq)->bio) \ + for (_bio = (rq)->bio; _bio; _bio = (_bio)->bi_next) #define rq_for_each_segment(bvl, _rq, _iter) \ - __rq_for_each_bio(_iter.bio, _rq) \ - bio_for_each_segment(bvl, _iter.bio, _iter.iter) + __rq_for_each_bio((_iter).bio, _rq) \ + bio_for_each_segment(bvl, (_iter).bio, (_iter).iter) #define rq_for_each_bvec(bvl, _rq, _iter) \ - __rq_for_each_bio(_iter.bio, _rq) \ - bio_for_each_bvec(bvl, _iter.bio, _iter.iter) + __rq_for_each_bio((_iter).bio, _rq) \ + bio_for_each_bvec(bvl, (_iter).bio, (_iter).iter) #define rq_iter_last(bvec, _iter) \ - (_iter.bio->bi_next == NULL && \ - bio_iter_last(bvec, _iter.iter)) + ((_iter).bio->bi_next == NULL && \ + bio_iter_last(bvec, (_iter).iter)) /* * blk_rq_pos() : the current sector From patchwork Thu May 4 20:05:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 90225 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp597214vqo; Thu, 4 May 2023 13:46:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4XtyO+BdhTKqCP+oBJWHI6hmcs1jR+anxyAgGYuWRsHgljBRfSzELjMtrnARyIpyVvQ37B X-Received: by 2002:a05:6a00:1702:b0:643:5455:2577 with SMTP id h2-20020a056a00170200b0064354552577mr3637425pfc.3.1683233189883; Thu, 04 May 2023 13:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683233189; cv=none; d=google.com; s=arc-20160816; b=eA0cmqiDCnwjxSf1kUSKo1K8juz4e0eX43Vv6Bas/eJYOkdYtVgMD3h61gUaqqCPTV hXeu1JLYVpWGAy5ALn4ArJfQSVoApAeuaOI6Gl+eoaV9HmBVDNbzB+5YPmNuVQr4BVf3 R+M37xCT17si/30F2uhz8qUu5j6zR8CSwQ6up+TpTe6Evntqg00lajC1HdJQxdmHC00M 51zKMdtzKWpuzo9l+aEqeIRysu/Z4G3thWh6PUqpBGdJJ1iwpfxAUu/6ht/JzNFkZRDN a5oPzwdJdmRqV2LpfOh+ZefOhOaGWjKH8jnQMTq4sE+/WB+VBnTNyq1+m47Q+V1UWCsV acwQ== 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=5NRvoXQB1EjmXTZekOeNRloYLMLpoRqkn8WA3SqygpQ=; b=JJUlfVlyIazelTO4oH3kx39oUbs/1gWaHvQOeEFO/n8Sv/vc7Fa8iKrvLrl9s5vBke PdJahX6tK4IwSTJQoEfeOQ0E8vldrvCre1Rx4o8qMa4XJwgjdHXAtVnI/GuhH7W+bavJ cZN6hpU+qdJJcKB1ZoYrXZHHgNffM7jXXTxuHczrMPwoM0t09LZjHcm+QqK3GY3GgIgq r0VFzr1KwK29A42xH+SCS0ZWTIAxrNLW98XsTLVNXv9L4WzMKjMlx3ybJN+EOLPHBoDO M0d6LnpjA/X7vg5V/KDRdNeOPjwvYDBEyS+f21VQ98AcbEtiaBxg3bWt8G47L2phKmsx K8Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=al4b3prN; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w66-20020a626245000000b0063d3545d864si242350pfb.220.2023.05.04.13.46.16; Thu, 04 May 2023 13:46:29 -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=al4b3prN; 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 S231153AbjEDUcf (ORCPT + 99 others); Thu, 4 May 2023 16:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229893AbjEDUcT (ORCPT ); Thu, 4 May 2023 16:32:19 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 094031156B; Thu, 4 May 2023 13:21:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683230734; bh=QcIbf0/W/0tjmDJfN3K1x8lHrFbEPUWzJFa8s3c9fPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=al4b3prNPOgFLIry5QRsiV7BMrgdJB5bp4bmx7Pos2w5P+YZsuggLjjbLG62RauMe RKuV7lps9ytKmdR7YJFSU0zi1AzzhbJ1BhCVHXCp3PLa+JCVK9SCFV+fHAcfb77EsW BMX3wqtdhQ2BybtmbZAHGLkMJv3aTFNUoeVukyGNmRl726XcDfprt7Hp5G+vXNzt2s xKJudcCUTE3Zcdr70kARY9RRTvDPV+H2pZtTIo48xW3VgUUEb3BoYJzqPcYJwPupZ+ AfsvwbTpjT0+oIZ4cEIvbxW3htx/Vux+3hxP18amRC5bEI/vi9t/3x9Y0ZAGlyZ/3b /RhxNuB7YQnkA== Received: from localhost.localdomain (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QC4Yp64TWz11jK; Thu, 4 May 2023 16:05:34 -0400 (EDT) From: Mathieu Desnoyers To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Jens Axboe , Omar Sandoval , linux-block@vger.kernel.org Subject: [RFC PATCH 13/13] bio.h: Fix parentheses around macro parameter use Date: Thu, 4 May 2023 16:05:27 -0400 Message-Id: <20230504200527.1935944-14-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764997925202489935?= X-GMAIL-MSGID: =?utf-8?q?1764997925202489935?= Add missing parentheses around macro parameter use in the following patterns to ensure operator precedence behaves as expected: - "x++" is changed for "(x)++", - x->member is changed for (x)->member, - &x is changed for &(x). - "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. Remove useless parentheses in the following macro argument usage patterns: - m((x)) is changed for m(x), - m((x), y) is changed for m(x, y) because comma has lowest operator precedence, making the extra parentheses useless, Signed-off-by: Mathieu Desnoyers Cc: Jens Axboe Cc: Andrew Morton Cc: Omar Sandoval Cc: linux-block@vger.kernel.org --- include/linux/bio.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index b3e7529ff55e..f09aea290511 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -20,7 +20,7 @@ static inline unsigned int bio_max_segs(unsigned int nr_segs) } #define bio_prio(bio) (bio)->bi_ioprio -#define bio_set_prio(bio, prio) ((bio)->bi_ioprio = prio) +#define bio_set_prio(bio, prio) ((bio)->bi_ioprio = (prio)) #define bio_iter_iovec(bio, iter) \ bvec_iter_bvec((bio)->bi_io_vec, (iter)) @@ -37,7 +37,7 @@ static inline unsigned int bio_max_segs(unsigned int nr_segs) #define bio_iovec(bio) bio_iter_iovec((bio), (bio)->bi_iter) #define bvec_iter_sectors(iter) ((iter).bi_size >> 9) -#define bvec_iter_end_sector(iter) ((iter).bi_sector + bvec_iter_sectors((iter))) +#define bvec_iter_end_sector(iter) ((iter).bi_sector + bvec_iter_sectors(iter)) #define bio_sectors(bio) bvec_iter_sectors((bio)->bi_iter) #define bio_end_sector(bio) bvec_iter_end_sector((bio)->bi_iter) @@ -93,7 +93,7 @@ static inline bool bio_next_segment(const struct bio *bio, * before it got to the driver and the driver won't own all of it */ #define bio_for_each_segment_all(bvl, bio, iter) \ - for (bvl = bvec_init_iter_all(&iter); bio_next_segment((bio), &iter); ) + for (bvl = bvec_init_iter_all(&(iter)); bio_next_segment(bio, &(iter)); ) static inline void bio_advance_iter(const struct bio *bio, struct bvec_iter *iter, unsigned int bytes) @@ -145,17 +145,17 @@ static inline void bio_advance(struct bio *bio, unsigned int nbytes) #define __bio_for_each_segment(bvl, bio, iter, start) \ for (iter = (start); \ (iter).bi_size && \ - ((bvl = bio_iter_iovec((bio), (iter))), 1); \ - bio_advance_iter_single((bio), &(iter), (bvl).bv_len)) + ((bvl = bio_iter_iovec(bio, iter)), 1); \ + bio_advance_iter_single(bio, &(iter), (bvl).bv_len)) #define bio_for_each_segment(bvl, bio, iter) \ __bio_for_each_segment(bvl, bio, iter, (bio)->bi_iter) -#define __bio_for_each_bvec(bvl, bio, iter, start) \ +#define __bio_for_each_bvec(bvl, bio, iter, start) \ for (iter = (start); \ (iter).bi_size && \ - ((bvl = mp_bvec_iter_bvec((bio)->bi_io_vec, (iter))), 1); \ - bio_advance_iter_single((bio), &(iter), (bvl).bv_len)) + ((bvl = mp_bvec_iter_bvec((bio)->bi_io_vec, iter)), 1); \ + bio_advance_iter_single(bio, &(iter), (bvl).bv_len)) /* iterate over multi-page bvec */ #define bio_for_each_bvec(bvl, bio, iter) \ @@ -167,7 +167,7 @@ static inline void bio_advance(struct bio *bio, unsigned int nbytes) */ #define bio_for_each_bvec_all(bvl, bio, i) \ for (i = 0, bvl = bio_first_bvec_all(bio); \ - i < (bio)->bi_vcnt; i++, bvl++) + i < (bio)->bi_vcnt; (i)++, (bvl)++) #define bio_iter_last(bvec, iter) ((iter).bi_size == (bvec).bv_len) @@ -548,7 +548,7 @@ static inline void bio_list_init(struct bio_list *bl) #define BIO_EMPTY_LIST { NULL, NULL } #define bio_list_for_each(bio, bl) \ - for (bio = (bl)->head; bio; bio = bio->bi_next) + for (bio = (bl)->head; bio; bio = (bio)->bi_next) static inline unsigned bio_list_size(const struct bio_list *bl) { @@ -702,7 +702,7 @@ static inline bool bioset_initialized(struct bio_set *bs) #define bio_for_each_integrity_vec(_bvl, _bio, _iter) \ for_each_bio(_bio) \ - bip_for_each_vec(_bvl, _bio->bi_integrity, _iter) + bip_for_each_vec(_bvl, (_bio)->bi_integrity, _iter) extern struct bio_integrity_payload *bio_integrity_alloc(struct bio *, gfp_t, unsigned int); extern int bio_integrity_add_page(struct bio *, struct page *, unsigned int, unsigned int);