Skip to contentSkip to conversation

linux/types.h: Tidy __bitwise, add __CHECKER__ hints

PATCH Applied Bjorn Helgaas 2 participants 5 messages Mar 10, 2022 – Mar 11, 2022

Subsystems (2)

v1 of 2 Applied 2/2 Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover linux/types.h: Tidy __bitwise, add __CHECKER__ hints

From: Bjorn Helgaas <[email protected]>

- Tidy up __bitwise__, which is unused except in the __bitwise definition

- Add hints about what __CHECKER__ means

Bjorn Helgaas (2):
linux/types.h: Remove unnecessary __bitwise__ Documentation/sparse: Add hints about __CHECKER__

 Documentation/dev-tools/sparse.rst | 2 ++
 include/linux/compiler_types.h     | 1 +
 include/uapi/linux/types.h         | 6 +++---
 3 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/2 linux/types.h: Remove unnecessary __bitwise__

From: Bjorn Helgaas <[email protected]>

There are no users of "__bitwise__" except the definition of "__bitwise". Remove __bitwise__ and define __bitwise directly.

This is a follow-up to 05de97003c77 ("linux/types.h: enable endian checks for all sparse builds").

Cc Michael S. Tsirkin <[email protected]>
---
 include/uapi/linux/types.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
include/uapi/linux/types.h +2 -3
index f6d2f83cbe29..71696f424ac8 100644
@@ -20,11 +20,10 @@
  */
 
 #ifdef __CHECKER__
-#define __bitwise__ __attribute__((bitwise))
+#define __bitwise	__attribute__((bitwise))
 #else
-#define __bitwise__
+#define __bitwise
 #endif
-#define __bitwise __bitwise__
 
 typedef __u16 __bitwise __le16;
 typedef __u16 __bitwise __be16;
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/2] linux/types.h: Remove unnecessary __bitwise__

Quoted 8 lines · On Thu, 10 Mar 2022 16:09:26 -0600 Bjorn Helgaas <[email protected]> wrote:

From: Bjorn Helgaas <[email protected]>

There are no users of "__bitwise__" except the definition of "__bitwise". Remove __bitwise__ and define __bitwise directly.

This is a follow-up to 05de97003c77 ("linux/types.h: enable endian checks for all sparse builds").

Can we change the copy-pasted code in tools/include/linux/types.h while we're there?

tools/include/linux/types.h renamed from tools/include/linux/types.h~linux-typesh-remove-unnecessary-__bitwise__-fix +2 -3
@@ -43,11 +43,10 @@ typedef __u8  u8;
 typedef __s8  s8;
 
 #ifdef __CHECKER__
-#define __bitwise__ __attribute__((bitwise))
+#define __bitwise	__attribute__((bitwise))
 #else
-#define __bitwise__
+#define __bitwise
 #endif
-#define __bitwise __bitwise__
 
 #define __force
 #define __user

_

#3 lore raw

Re: [PATCH 1/2] linux/types.h: Remove unnecessary __bitwise__

Quoted 7 lines · Andrew Morton
Quoted 5 lines · On Thu, 10 Mar 2022 16:09:26 -0600 Bjorn Helgaas <[email protected]> wrote:

From: Bjorn Helgaas <[email protected]>

There are no users of "__bitwise__" except the definition of "__bitwise". Remove __bitwise__ and define __bitwise directly.

Quoted 6 lines
Quoted 3 lines

This is a follow-up to 05de97003c77 ("linux/types.h: enable endian checks for all sparse builds").

Can we change the copy-pasted code in tools/include/linux/types.h while we're there?

Oh, you bet! Thanks for pointing that out!

Quoted 18 lines
tools/include/linux/types.h renamed from tools/include/linux/types.h~linux-typesh-remove-unnecessary-__bitwise__-fix +2 -3
@@ -43,11 +43,10 @@ typedef __u8  u8;
 typedef __s8  s8;
 
 #ifdef __CHECKER__
-#define __bitwise__ __attribute__((bitwise))
+#define __bitwise	__attribute__((bitwise))
 #else
-#define __bitwise__
+#define __bitwise
 #endif
-#define __bitwise __bitwise__
 
 #define __force
 #define __user

_

#4 lore raw

PATCH 2/2 Documentation/sparse: Add hints about __CHECKER__

In reply to Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

Several attributes depend on __CHECKER__, but previously there was no clue in the tree about when __CHECKER__ might be defined. Add hints at the most common places (__kernel, __user, __iomem, __bitwise) and in the sparse documentation.

---
 Documentation/dev-tools/sparse.rst | 2 ++
 include/linux/compiler_types.h     | 1 +
 include/uapi/linux/types.h         | 1 +
 3 files changed, 4 insertions(+)
Documentation/dev-tools/sparse.rst +2 -0
index 02102be7ff49..dc791c8d84d1 100644
@@ -100,3 +100,5 @@ have already built it.
 
 The optional make variable CF can be used to pass arguments to sparse.  The
 build system passes -Wbitwise to sparse automatically.
+
+Note that sparse defines the __CHECKER__ preprocessor symbol.
include/linux/compiler_types.h +1 -0
index 3c1795fdb568..4b3915ce38a4 100644
@@ -4,6 +4,7 @@
 
 #ifndef __ASSEMBLY__
 
+/* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */
 #ifdef __CHECKER__
 /* address spaces */
 # define __kernel	__attribute__((address_space(0)))
include/uapi/linux/types.h +1 -0
index 71696f424ac8..c4dc597f3dcf 100644
@@ -19,6 +19,7 @@
  * any application/library that wants linux/types.h.
  */
 
+/* sparse defines __CHECKER__; see Documentation/dev-tools/sparse.rst */
 #ifdef __CHECKER__
 #define __bitwise	__attribute__((bitwise))
 #else
Signature · 1 line
2.25.1