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