From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0FBDC7EE25 for ; Mon, 8 May 2023 14:29:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234465AbjEHO3A (ORCPT ); Mon, 8 May 2023 10:29:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234247AbjEHO24 (ORCPT ); Mon, 8 May 2023 10:28:56 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEA9C2129; Mon, 8 May 2023 07:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1683556134; bh=x/r/GkBuy7Dt3JR/ZxirbXy8mCQ1jBvYhr8UrWAG4jg=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=bkkEqtTvS6agfeG4WKqHNKhvRlBqIo2FussbcNHbOwMU+Xja2iME/yZxuTNLei5Yc fhveRJhpOltVgcYaZWLkfkdc5/DvCH82dlvYiKboQG3Ze1lHTByTYJ7OJc48qOKFEH aLAQG8l02nCcQmyfw3Q9XktyFPTggnSgavLTtI4+aqoOXn4xy2c0DIpcAxaEoTlCJJ vH89bWmJRl5OR8fIr54txHcOQp65IqGqmsEJ3NfDM1HScVJ3EVgrYgJcjIjcCtETlG NgsUHSsllVHT5RfIfZq2COkSosBBP1VXkFcSa6GXX7hmctYIghv8Aocq9QCV83fXtn ZwTlc9qP0MuZQ== Received: from [172.16.0.99] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4QFNvV0mvdz12H6; Mon, 8 May 2023 10:28:54 -0400 (EDT) Message-ID: Date: Mon, 8 May 2023 10:28:58 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [RFC PATCH 12/13] blk-mq.h: Fix parentheses around macro parameter use Content-Language: en-US From: Mathieu Desnoyers To: Linus Torvalds Cc: Andrew Morton , linux-kernel@vger.kernel.org, Jens Axboe , linux-block@vger.kernel.org References: <20230504200527.1935944-1-mathieu.desnoyers@efficios.com> <20230504200527.1935944-13-mathieu.desnoyers@efficios.com> <3b017a9f-220d-4da8-2cf6-7f0d6175b30c@efficios.com> <3cc72a67-d648-0040-6f60-37663797e360@efficios.com> <322d22f5-7ab0-adbd-45a0-879364d79ce8@efficios.com> In-Reply-To: <322d22f5-7ab0-adbd-45a0-879364d79ce8@efficios.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I've attempted to capture the resulting rules based on our discussion to add this to coding-style.rst. Please let me know if anything is wrong: (to be added in section 12) Macros, Enums and RTL) Always use parentheses around macro arguments, except when: - they are used as a full expression: - as an initializer, - as an expression statement, - as the controlling expression of a selection statement (``if`` or ``switch``), - as the controlling expression of a ``while`` or ``do`` statement, - as any of the expressions of a ``for`` statement, - as the expression in a return statement, - they are used as expression within an array subscript operator "[]", - they are used as arguments to functions or other macros, - there is some syntax reason why adding the parentheses would not work. (note: I'm unsure about requiring or not the parentheses around initializers. Based on C11 section "6.8 Statement and blocks", initializers that are not part of a compound literal are full expressions, which makes the extra parentheses useless.) Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com