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. Link: https://lkml.kernel.org/r/CA+55aFwVZk1OfB9T2v014PTAKFhtVan_Zj2dOjnCy3x6E4UJfA@mail.gmail.com Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Joe Perches <joe@perches.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Acked-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Joey Pabalinas <joeypabalinas@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:

committed by
Jonathan Corbet

parent
b04c11c988
commit
7967656ffb
@@ -6368,19 +6368,6 @@ sub process {
|
||||
}
|
||||
}
|
||||
|
||||
# check for bool bitfields
|
||||
if ($sline =~ /^.\s+bool\s*$Ident\s*:\s*\d+\s*;/) {
|
||||
WARN("BOOL_BITFIELD",
|
||||
"Avoid using bool as bitfield. Prefer bool bitfields as unsigned int or u<8|16|32>\n" . $herecurr);
|
||||
}
|
||||
|
||||
# check for bool use in .h files
|
||||
if ($realfile =~ /\.h$/ &&
|
||||
$sline =~ /^.\s+bool\s*$Ident\s*(?::\s*d+\s*)?;/) {
|
||||
CHK("BOOL_MEMBER",
|
||||
"Avoid using bool structure members because of possible alignment issues - see: https://lkml.org/lkml/2017/11/21/384\n" . $herecurr);
|
||||
}
|
||||
|
||||
# check for semaphores initialized locked
|
||||
if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
|
||||
WARN("CONSIDER_COMPLETION",
|
||||
|
Reference in New Issue
Block a user