From: Joe Perches Date: Tue, 10 Apr 2018 23:34:04 +0000 (-0700) Subject: checkpatch: add test for assignment at start of line X-Git-Tag: v6.6-pxa1908~14424^2~38 X-Git-Url: https://git.dujemihanovic.xyz/?a=commitdiff_plain;h=6a487211ec720658f3e3c39eecd0b6829eafa6d4;p=linux.git checkpatch: add test for assignment at start of line Kernel style seems to prefer line wrapping an assignment with the assignment operator on the previous line like: identifier = expression; over identifier = expression; somewhere around a 50:1 ratio $ git grep -P "[^=]=\s*$" -- "*.[ch]" | wc -l 52008 $ git grep -P "^\s+[\*\/\+\|\%\-]?=[^=>]" | wc -l 1161 So add a --strict test for that condition. Link: http://lkml.kernel.org/r/1522275726.2210.12.camel@perches.com Signed-off-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d2464002bb40..5deee8bd0bae 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3062,6 +3062,12 @@ sub process { } } +# check for assignments on the start of a line + if ($sline =~ /^\+\s+($Assignment)[^=]/) { + CHK("ASSIGNMENT_CONTINUATIONS", + "Assignment operator '$1' should be on the previous line\n" . $hereprev); + } + # check for && or || at the start of a line if ($rawline =~ /^\+\s*(&&|\|\|)/) { CHK("LOGICAL_CONTINUATIONS",