linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
From: Utkarsh Verma <utkarshverma294@gmail.com>
To: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: linux-kernel-mentees@lists.linuxfoundation.org
Subject: [PATCH v3] Documentation: checkpatch: Add TRAILING_SEMICOLON message
Date: Sat, 21 Aug 2021 01:23:36 +0530	[thread overview]
Message-ID: <20210820195336.18611-1-utkarshverma294@gmail.com> (raw)
In-Reply-To: <CABJPP5CxsHYO8Omdceh0yD6RtRMnt5hW7DWc=aKxpXPXQJVLEQ@mail.gmail.com>

Add a new message type TRAILING_SEMICOLON for the macro definitions
that conclude with a semicolon.

Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
---
 Documentation/dev-tools/checkpatch.rst | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/Documentation/dev-tools/checkpatch.rst b/Documentation/dev-tools/checkpatch.rst
index f0956e9ea2d8..30eda8f4a8bd 100644
--- a/Documentation/dev-tools/checkpatch.rst
+++ b/Documentation/dev-tools/checkpatch.rst
@@ -845,6 +845,27 @@ Macros, Attributes and Symbols
     Use the `fallthrough;` pseudo keyword instead of
     `/* fallthrough */` like comments.
 
+  **TRAILING_SEMICOLON**
+    Macro definition should not end with a semicolon. The macro
+    invocation style should be consistent with function calls.
+    This can prevent any unexpected code paths::
+
+      #define MAC do_something;
+
+    If this macro is used within a if else statement, like::
+
+      if (some_condition)
+              MAC;
+
+      else
+              do_something;
+
+    Then there would be a compilation error, because when the macro is
+    expanded there are two trailing semicolons, so the else branch gets
+    orphaned.
+
+    See: https://lore.kernel.org/lkml/1399671106.2912.21.camel@joe-AO725/
+
   **WEAK_DECLARATION**
     Using weak declarations like __attribute__((weak)) or __weak
     can have unintended link defects.  Avoid using them.
-- 
2.17.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  reply	other threads:[~2021-08-20 19:54 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-17  6:46 Linux Kernel: Checkpatch Documentation Mentorship Tasks Utkarsh Verma
2021-07-17  7:23 ` Lukas Bulwahn
2021-07-24 22:06   ` Utkarsh Verma
2021-07-26 10:40     ` Lukas Bulwahn
2021-08-03 14:17       ` [PATCH] Documentation: checkpatch: Add SPLIT_STRING message Utkarsh Verma
2021-08-03 14:52         ` Dwaipayan Ray
2021-08-03 18:13           ` Utkarsh Verma
2021-08-03 18:20             ` Lukas Bulwahn
2021-08-04 18:09               ` [PATCH v2] " Utkarsh Verma
2021-08-03 14:19       ` [PATCH] Documentation: checkpatch: Add SYMBOLIC_PERMS message Utkarsh Verma
2021-08-03 14:20       ` [PATCH] Documentation: checkpatch: Add TRAILING_SEMICOLON message Utkarsh Verma
2021-08-03 15:20         ` Dwaipayan Ray
2021-08-03 21:19           ` [PATCH v2] " Utkarsh Verma
2021-08-05 13:49             ` Dwaipayan Ray
2021-08-20 19:53               ` Utkarsh Verma [this message]
2021-08-22 17:29                 ` [PATCH v3] " Dwaipayan Ray
2021-08-03 14:20       ` [PATCH] USB: serial: iuu_phoenix: fix checkpatch memset warning Utkarsh Verma
2021-08-03 14:21       ` [PATCH] USB: serial: iuu_phoenix: fix quoted string split across lines Utkarsh Verma
2021-08-05 13:52         ` Dwaipayan Ray
2021-08-05 14:20           ` Lukas Bulwahn
2021-08-06 13:12             ` Utkarsh Verma
2021-08-25  8:22             ` [PATCH v2] " Utkarsh Verma
2021-08-03 14:21       ` [PATCH] USB: serial: iuu_phoenix: Replace symbolic permissions by octal permissions Utkarsh Verma
2021-08-03 18:11         ` Lukas Bulwahn
2021-08-03 18:37           ` [PATCH v2] " Utkarsh Verma
2021-08-20 10:09             ` Lukas Bulwahn
2021-08-20 19:08               ` Utkarsh Verma
2021-08-04 19:12           ` [PATCH] " Utkarsh Verma
2021-08-05  9:26             ` Lukas Bulwahn
2021-08-06 19:12               ` Utkarsh Verma
2021-08-03 16:36       ` Linux Kernel: Checkpatch Documentation Mentorship Tasks Utkarsh Verma
2021-08-03 18:07         ` Lukas Bulwahn
2021-08-03 21:37           ` [PATCH v2] Documentation: checkpatch: Add SYMBOLIC_PERMS message Utkarsh Verma
2021-08-03 21:49             ` Dwaipayan Ray
2021-08-04 15:31               ` [PATCH v3] " Utkarsh Verma
2021-08-05 13:51                 ` Dwaipayan Ray
2021-08-06 13:46                   ` Utkarsh Verma
2021-08-06 19:56                     ` Dwaipayan Ray
2021-08-06 20:03                       ` Lukas Bulwahn
2021-08-06 20:10                       ` [PATCH v4] " Utkarsh Verma
2021-08-22 17:52                         ` Dwaipayan Ray
2021-08-23  7:18                           ` Lukas Bulwahn
2021-08-24 22:13                             ` [PATCH v5] " Utkarsh Verma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210820195336.18611-1-utkarshverma294@gmail.com \
    --to=utkarshverma294@gmail.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).