Skip to content

Commit

Permalink
checkpatch.pl: add union and struct to the exceptions list
Browse files Browse the repository at this point in the history
Here is a small code snippet, which will be complained about by
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 and safe, so checkpatch.pl should accept this.  It
should be also true for struct defined in a macro.

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.

Signed-off-by: Stefani Seibold <[email protected]>
Cc: Andy Whitcroft <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
sstefani authored and torvalds committed Mar 6, 2010
1 parent 5213129 commit 22fd2d3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,8 @@ sub process {
DECLARE_PER_CPU|
DEFINE_PER_CPU|
__typeof__\(|
union|
struct|
\.$Ident\s*=\s*|
^\"|\"$
}x;
Expand Down

0 comments on commit 22fd2d3

Please sign in to comment.