Skip to contentSkip to conversation

checkpatch.pl: add union and struct to the exceptions list

PATCH In review Stefani Seibold 2 participants 3 messages Jan 6, 2010 – Jan 12, 2010 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch.pl: add union and struct to the exceptions list

This patch add the struct and union keywords to the exceptions list of the checkpatch.pl script, to prevent error message "Macros with multiple statements should be enclosed in a do - while loop". Otherwise it is not possible to build a struct or union with a macro.

---
 checkpatch.pl |    2 ++
 1 file changed, 2 insertions(+)
scripts/checkpatch.pl +2 -0
@@ -2348,6 +2348,8 @@ sub process {
 				DECLARE_PER_CPU|
 				DEFINE_PER_CPU|
 				__typeof__\(|
+				union|
+				struct|
 				\.$Ident\s*=\s*|
 				^\"|\"$
 			}x;
#1 lore raw
Quoted 13 lines · On Wed, 06 Jan 2010 17:46:00 +0100 Stefani Seibold <[email protected]> wrote:

This patch add the struct and union keywords to the exceptions list of the checkpatch.pl script, to prevent error message "Macros with multiple statements should be enclosed in a do - while loop". Otherwise it is not possible to build a struct or union with a macro.

---
 checkpatch.pl |    2 ++
 1 file changed, 2 insertions(+)

scripts/checkpatch.pl sub process { · line 2355

Quoted 8 lines
scripts/checkpatch.pl +2 -0
@@ -2348,6 +2348,8 @@ sub process {
 				DECLARE_PER_CPU|
 				DEFINE_PER_CPU|
 				__typeof__\(|
+				union|
+				struct|
 				\.$Ident\s*=\s*|
 				^\"|\"$
 			}x;

hm. Perhaps it would help if you could provide a snippet of code which triggers the incorrect warning?

#2 lore raw

Am Montag, den 11.01.2010, 14:42 -0800 schrieb Andrew Morton:

Quoted 13 lines
Quoted 10 lines · On Wed, 06 Jan 2010 17:46:00 +0100 Stefani Seibold <[email protected]> wrote:

This patch add the struct and union keywords to the exceptions list of the checkpatch.pl script, to prevent error message "Macros with multiple statements should be enclosed in a do - while loop". Otherwise it is not possible to build a struct or union with a macro.

---
 checkpatch.pl |    2 ++
 1 file changed, 2 insertions(+)
Quoted 15 lines

scripts/checkpatch.pl sub process { · line 2355

Quoted 11 lines
scripts/checkpatch.pl +2 -0
@@ -2348,6 +2348,8 @@ sub process {
 				DECLARE_PER_CPU|
 				DEFINE_PER_CPU|
 				__typeof__\(|
+				union|
+				struct|
 				\.$Ident\s*=\s*|
 				^\"|\"$
 			}x;

hm. Perhaps it would help if you could provide a snippet of code which triggers the incorrect warning?

Here is a small code snippet, which will be complained by the checkpatch.pl:

#define __STRUCT_KFIFO_COMMON(recsize, ptrtype) \
	union { \
		struct { \
			unsigned int	in; \
			unsigned int	out; \
		}; \
		char		rectype[recsize]; \
		ptrtype		*ptr; \
		const ptrtype	*ptr_const; \
	};

This construct is legal an save, so checkpatch.pl should accept this. It should be also true for struct defined in a macro.

Stefani