History

coding-style: Clarify the expectations around bool

There has been some confusion since checkpatch started warning about bool use in structures, and people have been avoiding using it. Many people feel there is still a legitimate place for bool in structures, so provide some guidance on bool usage derived from the entire thread that spawned the checkpatch warning.

Jason Gunthorpe committed 7 years ago

Commit 79676561 parent b04c11c2 files · +34 −17Browse files

Showing the changes to scripts/checkpatch.pl (1 of 2 files). Show all

Unified · Split

scripts/checkpatch.pl+0−13
@@ -6368,19 +6368,6 @@ sub process { · 6367 unmodified lines
6368 }6368 }
6369 }6369 }
6370 6370
6371# check for bool bitfields
6372 if ($sline =~ /^.\s+bool\s*$Ident\s*:\s*\d+\s*;/) {
6373 WARN("BOOL_BITFIELD",
6374 "Avoid using bool as bitfield. Prefer bool bitfields as unsigned int or u<8|16|32>\n" . $herecurr);
6375 }
6376
6377# check for bool use in .h files
6378 if ($realfile =~ /\.h$/ &&
6379 $sline =~ /^.\s+bool\s*$Ident\s*(?::\s*d+\s*)?;/) {
6380 CHK("BOOL_MEMBER",
6381 "Avoid using bool structure members because of possible alignment issues - see: https://lkml.org/lkml/2017/11/21/384\n" . $herecurr);
6382 }
6383
6384# check for semaphores initialized locked6371# check for semaphores initialized locked
6385 if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {6372 if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
6386 WARN("CONSIDER_COMPLETION",6373 WARN("CONSIDER_COMPLETION",