[PATCH] checkpatch: Allow spaces before the ':' of a bitfield

From: Josh Triplett
Date: Mon Oct 14 2013 - 13:32:20 EST


checkpatch warns about spaces both before and after the ':' separating a
bitfield name from its width. However, many drivers do put space before
the : to line up the widths, which makes the definition significantly
more readable; checkpatch should not warn about that. Remove the
warning for space before the ':' of a bitfield.

Reported-by: Nandini Hanumanthagowda <nandu.hgowda@xxxxxxxxx>
Reported-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Josh Triplett <josh@xxxxxxxxxxxxxxxx>
---

Nandini and Greg observed this issue as part of checkpatch warnings on a
staging driver (octeon-usb), and both agreed that checkpatch should not
issue this warning; patching accordingly.

scripts/checkpatch.pl | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ed16a68..9e36345 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2934,8 +2934,7 @@ sub process {

# No spaces for:
# ->
- # : when part of a bitfield
- } elsif ($op eq '->' || $opv eq ':B') {
+ } elsif ($op eq '->') {
if ($ctx =~ /Wx.|.xW/) {
if (ERROR("SPACING",
"spaces prohibited around that '$op' $at\n" . $hereptr)) {
@@ -2947,6 +2946,19 @@ sub process {
}
}

+ # : when part of a bitfield
+ } elsif ($opv eq ':B') {
+ if ($ctx =~ /.xW/) {
+ if (ERROR("SPACING",
+ "spaces prohibited after that '$op' $at\n" . $hereptr)) {
+ $good = $fix_elements[$n] . rtrim($fix_elements[$n + 1]);
+ if (defined $fix_elements[$n + 2]) {
+ $fix_elements[$n + 2] =~ s/^\s+//;
+ }
+ $line_fixed = 1;
+ }
+ }
+
# , must have a space on the right.
} elsif ($op eq ',') {
if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) {
--
1.8.4.rc3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/