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 shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF50FC433EF for ; Fri, 22 Apr 2022 14:17:52 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nhu2q-0004PH-Jd for kernelnewbies@archiver.kernel.org; Fri, 22 Apr 2022 10:14:00 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nhtxz-0003ty-5T for kernelnewbies@kernelnewbies.org; Fri, 22 Apr 2022 10:08:59 -0400 Received: by mail-pl1-x62c.google.com with SMTP id s17so11078165plg.9 for ; Fri, 22 Apr 2022 07:08:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=NYiZUH6YdNWqPKQVC7TRdZtEXt4nZi8ua4p2oLtbnag=; b=HswBvaDahuysWI/ySm5pLF6LJT3cePoP/V/zvicMIgvRDgQuskR5YZOyNOhXQYgKqk 0WIjaRQICz+mZvLsNmQOheVOO7e77JVxVOHihp6d99MMPdXcDwWxwCWyOJ0tX6hBttbp HeGudXwHTvFefySGO/f4/sWcL5oRYh5GNQdL+bJdXtoJUwrTo8c0BF28krm3XUN50sxV FM97poqKWJ5c/gmwF7iw0TxKHrZMb1B3zbaUbptWwVAmZm62MpihhmirKREKIUT+OeB7 4LjMuZVUShAfu6q9Kuv8+LTA409XrmFVpYgEfWjoxjEw50Zrv77qro8hfxX6QsTh5Ny/ SBhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=NYiZUH6YdNWqPKQVC7TRdZtEXt4nZi8ua4p2oLtbnag=; b=KIiqVT0t5kszJu6Knfs1pGo3SDZ4k6ntwzA/810n4wJ+W3L7ZDa+bgIuJtJauHuC1R 9lmSF3Poqrillk+HKqnDmSELk6std/bUdz/d6SBt8XHUCLM/FX3MnYsbtc0f4AaDgxzU V7j8kTWTROIyWWnrUh0tqcYKKs2NWronfpzXn9crOd0oL5sZ4YmikLwbjG54gQGLnnL/ HDU5u12pdT+HJzmSCfU92FTY1o9/TvxEhLhCTtUm89gSfymYDvrpUpYDMQtVN/ZEZ2ML Gqi2eky7JavomRwIe2oVk6i/eexbINsHCTLIZm7z9EkdPJmu4yvVtGcJdTyoyIJYOdD0 JXUA== X-Gm-Message-State: AOAM530M6xKJCTX3M0QLE0VztNx5dtXSF0lNRLBGpN74+LBOZI/9mS9c oLmK+5FQ3cbhihH6zJqXB7JzryHHpN4= X-Google-Smtp-Source: ABdhPJx13Fn67NCG9iKfkGEFmOFUt2BoGoVzrFbh1SAWwE1mXL57PANabsKWB9oRxdZueKOE3ZAOiQ== X-Received: by 2002:a17:902:cf0f:b0:15a:24e0:d9b0 with SMTP id i15-20020a170902cf0f00b0015a24e0d9b0mr4745969plg.42.1650636537667; Fri, 22 Apr 2022 07:08:57 -0700 (PDT) Received: from ArchDesktop ([14.100.36.163]) by smtp.gmail.com with ESMTPSA id d15-20020a630e0f000000b003a408836badsm2372084pgl.45.2022.04.22.07.08.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 07:08:56 -0700 (PDT) Date: Fri, 22 Apr 2022 22:08:54 +0800 From: Solomon Tan To: kernelnewbies@kernelnewbies.org Subject: Coding style operator precedence Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces+kernelnewbies=archiver.kernel.org@kernelnewbies.org Hey all, Could someone share what the coding style preference is where operator precedence is concerned? I notice in the staging drivers that there are many instances where there are parenthesis in statements where operator precedence should be (in my opinion) obvious. Yet, there doesn't seem to be a patch to amend it. For example: In vc04_services/interface/vchiq_arm/vchiq_core.c, line 2136, there is ``` slot_zero->master.slot_last = first_data_slot + (num_slots / 2) - 1; ``` It could just have been ``` slot_zero->master.slot_last = first_data_slot + num_slots / 2 - 1; ``` yet I do not see anyone patching it. Nothing is mentioned in the kernel docs about operator precedence. Checkpatch.pl doesn't highlight it as a coding style either. What is the concensus regarding operator precedence in kernel coding style? The most relevant email thread I found suggests some feel the parenthesis shouldnt be there, while others would leave it there for readability. https://lore.kernel.org/linux-staging/YRypyev4Ku3eI9w8@kroah.com/ Should I remove the parenthesis because it is technically unnecessary, or should I leave it in for readability? Or should I just make the patch request and let the maintainer decide? Thank you. Cheers, Solomon _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies