2019-03-01 19:32:04

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] scripts: checkpatch: Check multiple blank lines when deleting code

On Thu, 2019-02-28 at 13:15 -0500, Alexandre Ghiti wrote:
> 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;
>
> - 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(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -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 +







2019-03-02 08:11:10

by Alexandre Ghiti

[permalink] [raw]
Subject: Re: [PATCH] scripts: checkpatch: Check multiple blank lines when deleting code

On 3/1/19 2:31 PM, Joe Perches wrote:
> On Thu, 2019-02-28 at 13:15 -0500, Alexandre Ghiti wrote:
>> 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;
>>
>> - 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(-)
>>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []

I do not understand what you mean here, can you clarify for v2 please ?

Thanks !

>> @@ -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.

>
>