Skip to contentSkip to conversation

Documentation: checkpatch: Document some more message types

PATCH In review Utkarsh Verma 2 participants 2 messages Sep 17, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Documentation: checkpatch: Document some more message types

Added and documented 4 new message types:
- INCLUDE_LINUX
- INDENTED_LABEL
- IF_0
- IF_1

---
 Documentation/dev-tools/checkpatch.rst | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
Documentation/dev-tools/checkpatch.rst +22 -0
index f0956e9ea2d8..ea343a7a5b46 100644
@@ -435,6 +435,11 @@ API usage
   **EXPORT_SYMBOL**
     EXPORT_SYMBOL should immediately follow the symbol to be exported.
 
+  **INCLUDE_LINUX**
+    Whenever asm/file.h is included and linux/file.h exists, a
+    conversion can be made when linux/file.h includes asm/file.h.
+    However this is not always the case (See signal.h).
+
   **IN_ATOMIC**
     in_atomic() is not for driver use so any such use is reported as an ERROR.
     Also in_atomic() is often used to determine if sleeping is permitted,
@@ -661,6 +666,10 @@ Indentation and Line Breaks
 
     See: https://lore.kernel.org/lkml/1328311239.21255.24.camel@joe2Laptop/
 
+  **INDENTED_LABEL**
+    goto labels either should not have any indentation or only a single
+    space indentation.
+
   **SWITCH_CASE_INDENT_LEVEL**
     switch should be at the same indent as case.
     Example::
@@ -790,6 +799,19 @@ Macros, Attributes and Symbols
   **DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON**
     do {} while(0) macros should not have a trailing semicolon.
 
+  **IF_0**
+    The code enclosed within #if 0 and #endif is not executed and is used
+    for temporarily removing the segments of code with the intention of
+    using it in the future, much like comments. But comments cannot be
+    nested, so #if 0 is preferred. But if the code inside #if 0 and #endif
+    doesn't seem to be anymore required then remove it.
+
+  **IF_1**
+    The code enclosed within #if 1 and #endif is always executed, so the
+    #if 1 and #endif statements are redundant, thus remove it.
+    It is only useful for debugging purposes, it can quickly disable the
+    code enclosed within itself by changing #if 1 to #if 0
+
   **INIT_ATTRIBUTE**
     Const init definitions should use __initconst instead of
     __initdata.
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 17 lines · Utkarsh Verma

Added and documented 4 new message types:
- INCLUDE_LINUX
- INDENTED_LABEL
- IF_0
- IF_1

---
 Documentation/dev-tools/checkpatch.rst | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
Documentation/dev-tools/checkpatch.rst +0 -0
index f0956e9ea2d8..ea343a7a5b46 100644

Documentation/dev-tools/checkpatch.rst API usage · line 442

Quoted 8 lines
Documentation/dev-tools/checkpatch.rst +5 -0
@@ -435,6 +435,11 @@ API usage
   **EXPORT_SYMBOL**
     EXPORT_SYMBOL should immediately follow the symbol to be exported.
 
+  **INCLUDE_LINUX**
+    Whenever asm/file.h is included and linux/file.h exists, a
+    conversion can be made when linux/file.h includes asm/file.h.
+    However this is not always the case (See signal.h).
+

Can you suggest why? And is this true for every use?

Documentation/dev-tools/checkpatch.rst Indentation and Line Breaks · line 672

Quoted 11 lines
Documentation/dev-tools/checkpatch.rst +4 -0
   **IN_ATOMIC**
     in_atomic() is not for driver use so any such use is reported as an ERROR.
     Also in_atomic() is often used to determine if sleeping is permitted,
@@ -661,6 +666,10 @@ Indentation and Line Breaks
 
     See: https://lore.kernel.org/lkml/1328311239.21255.24.camel@joe2Laptop/
 
+  **INDENTED_LABEL**
+    goto labels either should not have any indentation or only a single
+    space indentation.
+

Some reference here maybe?

Quoted 10 lines
Documentation/dev-tools/checkpatch.rst +3 -0
   **SWITCH_CASE_INDENT_LEVEL**
     switch should be at the same indent as case.
     Example::
@@ -790,6 +799,19 @@ Macros, Attributes and Symbols
   **DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON**
     do {} while(0) macros should not have a trailing semicolon.
 
+  **IF_0**
+    The code enclosed within #if 0 and #endif is not executed and is used
+    for temporarily removing the segments of code with the intention of

Documentation/dev-tools/checkpatch.rst Macros, Attributes and Symbols · line 814

Quoted 10 lines
Documentation/dev-tools/checkpatch.rst +10 -0
+    using it in the future, much like comments. But comments cannot be
+    nested, so #if 0 is preferred. But if the code inside #if 0 and #endif
+    doesn't seem to be anymore required then remove it.
+
+  **IF_1**
+    The code enclosed within #if 1 and #endif is always executed, so the
+    #if 1 and #endif statements are redundant, thus remove it.
+    It is only useful for debugging purposes, it can quickly disable the
+    code enclosed within itself by changing #if 1 to #if 0
+

These two are good.

Quoted 6 lines
Documentation/dev-tools/checkpatch.rst +0 -1
   **INIT_ATTRIBUTE**
     Const init definitions should use __initconst instead of
     __initdata.
--

2.25.1

Thanks,
Dwaipayan.