From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEFCCC04AB1 for ; Thu, 9 May 2019 17:19:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9C364217D7 for ; Thu, 9 May 2019 17:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbfEIRTP (ORCPT ); Thu, 9 May 2019 13:19:15 -0400 Received: from smtprelay0228.hostedemail.com ([216.40.44.228]:45651 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726620AbfEIRTP (ORCPT ); Thu, 9 May 2019 13:19:15 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 943FC100E86C7; Thu, 9 May 2019 17:19:13 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: fly20_3353c4314b71f X-Filterd-Recvd-Size: 2401 Received: from XPS-9350.home (cpe-23-242-196-136.socal.res.rr.com [23.242.196.136]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Thu, 9 May 2019 17:19:12 +0000 (UTC) Message-ID: Subject: Re: [Proposal] end of file checks by checkpatch.pl From: Joe Perches To: Masahiro Yamada Cc: Linux Kernel Mailing List , Andy Whitcroft Date: Thu, 09 May 2019 10:19:11 -0700 In-Reply-To: References: Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.1-1build1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2019-05-10 at 00:27 +0900, Masahiro Yamada wrote: > Hi Joe, > > > Does it make sense to check the following > by checkpatch.pl ? > > > [1] blank line at end of file > [2] no new line at end of file I'm pretty sure checkpatch does one this already. (around line 3175) # check for adding lines without a newline. if ($line =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ No newline at end of file/) { WARN("MISSING_EOF_NEWLINE", "adding a line without newline at end of file\n" . $herecurr); } > When I apply a patch, > I sometimes see the following warning from 'git am'. > > > Applying: kunit: test: add string_stream a std::stream like string builder > .git/rebase-apply/patch:223: new blank line at EOF. > + > > > I just thought it could be checked > before the patch submission. perhaps: --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 1c421ac42b07..ceb32c584ee5 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3356,6 +3356,12 @@ sub process { $last_blank_line = $linenr; } +# check the last line isn't blank + if ($linenr >= $#rawlines && $line =~ /^\+\s*$/) { + WARN("LINE_SPACING", + "Avoid blank lines at EOF\n" . $herecurr); + } + # check for missing blank lines after declarations if ($sline =~ /^\+\s+\S/ && #Not at char 1 # actual declarations