Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4430728imb; Wed, 6 Mar 2019 13:14:56 -0800 (PST) X-Google-Smtp-Source: APXvYqxIOlntZifN0f1QatrEJ2MqE1bR5zMW0h3FtZbWHhjhUWgxoIQNpq/WjQNU/N/fOCsAWuxR X-Received: by 2002:a17:902:ba84:: with SMTP id k4mr9193012pls.103.1551906896068; Wed, 06 Mar 2019 13:14:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551906896; cv=none; d=google.com; s=arc-20160816; b=zfDp0l66cDBVplE0jkuZ51wFArbOt86FcHfTU+v97G1OVZvm5QIanxpmmzkJQHAfNS eNpruocrlQDtQO5Wrqye4gJ5CLF/S0rpRY/e9uzkVZVUX9WmdTD9QGhu5h0qNngfH4HM dYf7+vN8ZBQD0CPrp9RHKoBoZtg1z/VVyMxafgzlTEdb24oGdpQqo9pS/ouSZOgORSWg CC6hujiV93Aya7gVdCGWmjdpaJdjVie2vr4YWt7c4BYH/qtN4RsIA5VEq/+GZ4Ehi+jE ECspTG+wBjTZkPbF/E50rKAeIOLIEGGk04s8ok2CQUWxY8TE6h6g/SdKC5g/XWyJuZI8 Mcug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=DgNubHTwNC7sspEUk4AvJHigPSkG9BDaskwX+qeADIY=; b=gJRbakpG109Sb/xY7BrLxOpeuXlT3v8QmIrzNok4KDSfLNOEIqwLqHQ9WC1/vmUZvS 82Hjc7BX/7MVW/98sKhi/cbkoUOrIEB5YuujCTRQu1ZN5aqDxG94jC/KPnJ8Cc5jzV7N J/c+lFh2XgIwQnJnvsqdEaSjweC0W3JyZQyJayiIanxbA45E3xx90wQjpdr2mCc6utMB YWThJiucmbqUn4ZZ6vq5paXAAQ9HbdLvyJwRT7iYmN5tcgkzmdW6ppYlbmQM9oE9EP6J MWBVIzWUzddzQYt6Rks43Y5ih3I9tqAQeDbC/ig4WW67I9Zfm3wrZI+5Y4IqRCY8QSNF W5yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h127si2161978pfb.213.2019.03.06.13.14.37; Wed, 06 Mar 2019 13:14:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730926AbfCFTx3 (ORCPT + 99 others); Wed, 6 Mar 2019 14:53:29 -0500 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:36009 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726991AbfCFTx2 (ORCPT ); Wed, 6 Mar 2019 14:53:28 -0500 X-Originating-IP: 79.86.19.127 Received: from alex.numericable.fr (127.19.86.79.rev.sfr.net [79.86.19.127]) (Authenticated sender: alex@ghiti.fr) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 47EB9FF806; Wed, 6 Mar 2019 19:53:26 +0000 (UTC) From: Alexandre Ghiti To: Andy Whitcroft , Joe Perches , linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH v3] scripts: checkpatch: Check multiple blank lines when deleting code Date: Wed, 6 Mar 2019 14:53:24 -0500 Message-Id: <20190306195324.11634-1-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Alexandre Ghiti --- Changes in v3 as suggested by Joe Perches: - Do not try to fix this case - Make this test separate from the insertion one so that warning is more explicit Changes in v2: - Fix the --fix option scripts/checkpatch.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index b737ca9d7204..c0728cff292f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3296,7 +3296,7 @@ sub process { } } -# check for multiple consecutive blank lines +# check for multiple consecutive blank lines caused by blank line insertion if ($prevline =~ /^[\+ ]\s*$/ && $line =~ /^\+\s*$/ && $last_blank_line != ($linenr - 1)) { @@ -3309,6 +3309,16 @@ sub process { $last_blank_line = $linenr; } +# check for multiple consecutive blank lines caused by code deletion + if ($prevline =~ /^[\+ ]\s*$/ && + $line =~ /^ \s*$/ && + $last_blank_line != ($linenr - 1)) { + CHK("LINE_SPACING", + "Avoid deleting lines that create consecutive blank lines\n" . $hereprev); + + $last_blank_line = $linenr; + } + # check for missing blank lines after declarations if ($sline =~ /^\+\s+\S/ && #Not at char 1 # actual declarations -- 2.20.1