scripts: checkpatch: Check multiple blank lines when deleting code
A message that is not in the archive (sent off-list or not yet received): [email protected]
scripts/checkpatch.pl
Quoted 23 lines · Alexandre Ghiti
By matching only current line starting with '+', we miss the case when deleting code makes consecutive blank lines appear: this patch then makes it possible to detect this case by also matching current line starting with ' ', which is an already existing blank line.
On the following example, checkpatch --subjective now complains about multiple blank lines:
static long hugepage_subpool_get_pages(struct
hugepage_subpool*spool, {(quoted diff) +0
-2long ret = delta; - if (!spool) - return ret; spin_lock(&spool->lock);Signed-off-by Alexandre Ghiti <[email protected]>--- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/checkpatch.pl +0
-0
[]
scripts/checkpatch.pl sub process { · line 3304
Quoted 9 lines
scripts/checkpatch.pl +1
-1@@ -3298,7 +3298,7 @@ sub process { # check for multiple consecutive blank lines if ($prevline =~ /^[\+ ]\s*$/ && - $line =~ /^\+\s*$/ && + $line =~ /^[\+ ]\s*$/ && $last_blank_line != ($linenr - 1)) { if (CHK("LINE_SPACING", "Please don't use multiple blank lines\n" . $hereprev) &&
I believe this screws up the --fix option just below this if the line does not start with +
Quoted 18 lines · Joe Perches
Quoted 17 lines · Alexandre Ghiti
By matching only current line starting with '+', we miss the case when deleting code makes consecutive blank lines appear: this patch then makes it possible to detect this case by also matching current line starting with ' ', which is an already existing blank line.
On the following example, checkpatch --subjective now complains about multiple blank lines:
static long hugepage_subpool_get_pages(struct hugepage_subpool *spool, { long ret = delta;(quoted diff) +0
-2- if (!spool) - return ret; spin_lock(&spool->lock);
Quoted 7 lines
scripts/checkpatch.pl
Quoted 6 lines
Signed-off-by Alexandre Ghiti <[email protected]>--- scripts/checkpatch.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/checkpatch.pl +0
-0[]
I do not understand what you mean here, can you clarify for v2 please ?
Thanks !
Quoted 13 lines
scripts/checkpatch.pl sub process { · line 3304
Quoted 9 lines
scripts/checkpatch.pl +1
-1@@ -3298,7 +3298,7 @@ sub process { # check for multiple consecutive blank lines if ($prevline =~ /^[\+ ]\s*$/ && - $line =~ /^\+\s*$/ && + $line =~ /^[\+ ]\s*$/ && $last_blank_line != ($linenr - 1)) { if (CHK("LINE_SPACING", "Please don't use multiple blank lines\n" . $hereprev) &&I believe this screws up the --fix option just below this if the line does not start with +
Totally, you're right, thanks.