Skip to content

Commit 021fd07

Browse files
committed
Revert "scripts: checkpatch: fix missing blank line detection"
This reverts commit c310133. randomly asking for Missing a blank line after declarations. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
1 parent 5b05d64 commit 021fd07

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

scripts/checkpatch.pl

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
#!/usr/bin/env perl
22
# SPDX-License-Identifier: GPL-2.0
3-
# SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors
43
#
54
# (c) 2001, Dave Jones. (the file handling bit)
65
# (c) 2005, Joel Schopp <jschopp@austin.ibm.com> (the ugly bit)
76
# (c) 2007,2008, Andy Whitcroft <apw@uk.ibm.com> (new conditions, test suite)
87
# (c) 2008-2010 Andy Whitcroft <apw@canonical.com>
98
# (c) 2010-2018 Joe Perches <joe@perches.com>
10-
# (c) 2025 Aerlync Labs Inc
119

1210
use strict;
1311
use warnings;
@@ -3523,39 +3521,39 @@ sub process {
35233521
}
35243522

35253523
# check for missing blank lines after declarations
3526-
if (($sline =~ /^\+\s+\S/ || $sline =~ /^\s+\S/) && # Not at char 1
3524+
if ($sline =~ /^\+\s+\S/ && #Not at char 1
35273525
# actual declarations
3528-
($prevline =~ /^(\+|\s)\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
3526+
($prevline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
35293527
# function pointer declarations
3530-
$prevline =~ /^(\+|\s)\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ ||
3528+
$prevline =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ ||
35313529
# foo bar; where foo is some local typedef or #define
3532-
$prevline =~ /^(\+|\s)\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
3530+
$prevline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
35333531
# known declaration macros
3534-
$prevline =~ /^(\+|\s)\s+$declaration_macros/) &&
3532+
$prevline =~ /^\+\s+$declaration_macros/) &&
35353533
# for "else if" which can look like "$Ident $Ident"
3536-
!($prevline =~ /^(\+|\s)\s+$c90_Keywords\b/ ||
3534+
!($prevline =~ /^\+\s+$c90_Keywords\b/ ||
35373535
# other possible extensions of declaration lines
35383536
$prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ ||
35393537
# not starting a section or a macro "\" extended line
35403538
$prevline =~ /(?:\{\s*|\\)$/) &&
35413539
# looks like a declaration
3542-
!($sline =~ /^(\+|\s)\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
3540+
!($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
35433541
# function pointer declarations
3544-
$sline =~ /^(\+|\s)\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ ||
3542+
$sline =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ ||
35453543
# foo bar; where foo is some local typedef or #define
3546-
$sline =~ /^(\+|\s)\s+(?:volatile\s+)?$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
3544+
$sline =~ /^\+\s+(?:volatile\s+)?$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
35473545
# known declaration macros
3548-
$sline =~ /^(\+|\s)\s+$declaration_macros/ ||
3546+
$sline =~ /^\+\s+$declaration_macros/ ||
35493547
# start of struct or union or enum
3550-
$sline =~ /^(\+|\s)\s+(?:volatile\s+)?(?:static\s+)?(?:const\s+)?(?:union|struct|enum|typedef)\b/ ||
3548+
$sline =~ /^\+\s+(?:volatile\s+)?(?:static\s+)?(?:const\s+)?(?:union|struct|enum|typedef)\b/ ||
35513549
# start or end of block or continuation of declaration
3552-
$sline =~ /^(\+|\s)\s+(?:$|[\{\}\.\#\"\?\:\(\[])/ ||
3550+
$sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(\[])/ ||
35533551
# bitfield continuation
3554-
$sline =~ /^(\+|\s)\s+$Ident\s*:\s*\d+\s*[,;]/ ||
3552+
$sline =~ /^\+\s+$Ident\s*:\s*\d+\s*[,;]/ ||
35553553
# other possible extensions of declaration lines
3556-
$sline =~ /^(\+|\s)\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) &&
3554+
$sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) &&
35573555
# indentation of previous and current line are the same
3558-
(($prevline =~ /^(\+|\s)(\s+)\S/) && $sline =~ /^(\+|\s)$2\S/)) {
3556+
(($prevline =~ /\+(\s+)\S/) && $sline =~ /^\+$1\S/)) {
35593557
if (WARN("LINE_SPACING",
35603558
"Missing a blank line after declarations\n" . $hereprev) &&
35613559
$fix) {

0 commit comments

Comments
 (0)