Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1960979lqp; Tue, 16 Apr 2024 03:14:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWXXBedFSq0bPOqLhu43rn3k9IXPomelOZt8HcHOrc0zm4oTEL7nQas/YKDZdD0R+de08x//KbwnMbQ5u10E2+DzYUcmAala3uNxYoteA== X-Google-Smtp-Source: AGHT+IFXpW4kaU0JRuulyFUqKA6JUosS3LP9EaCgohs7Ow7k61/T6RypgKYmu7C9ByvofdfLHp9Y X-Received: by 2002:a05:6a20:8427:b0:1a5:6be8:2d70 with SMTP id c39-20020a056a20842700b001a56be82d70mr2253709pzd.21.1713262489879; Tue, 16 Apr 2024 03:14:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713262489; cv=pass; d=google.com; s=arc-20160816; b=NgYz2ruA2E/eva3++zC0UAOidsjZ3FBeIONQMmHXW2GR77CyHG/YM9qKEnt46Op2Ss q4I8qt2LprSQbqb4TmnvpIsDDV1q3Dog9kWIPDsDNVrN9C0dc5I4sZj1l/QGmYR8dKNQ bT/Uegl2S6Bgy5Phau1GeoonNTwrBzrq4bcz+rYwbcZJRUSXXJ6ks1fmXqaDoGWEgNnV +pFqKd9ah1VxiqZg8WjCu5TbY6uqw7dT9IXvintbhr6e7xFk2HbEC+lSP5M0eoDSA0Bg 8Jt6PiAM/6GwTg4z7wwk2LUDFghsB5/p9ZC9mTAUQKSO2SpGBjau5DYhBIl4payuLdfP Q7ow== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id; bh=iwfgv9+WuDaqTiXxerMPGhRV2sxYyR6jjRu0/Fu5wG0=; fh=U03vQFKeWbDEIjLwnXJGIHnT4FI55OULufpWTt4LckI=; b=yv/RMQ/ZM6VUo2AZ7IidaYwMgeCbnz3ntWwYq2Fjo/wmps0grlEpAINu3F+4fukI9Z QNfvH+KKZLZsSq9WcueDesjqC8GYUw6ReGnl+5wbBrhaO7u9tAYenacer7gR9cDGwekL wcbU1DauXSbgayMO5RkLZMTxxgxHVUf8cgiQ1O7YuNeVo8kRl26FSZ9M66pm7EqbkgxI 0JWYB/e8a8JD99NB0lEpmLsxTp2qWilj57d3Z7HblwnG3Mf8hjq0lUJtD0KD8A6x764p 7lVG+5KK0QQRKGFPpYaVvMWQQyLCKVdH96FOTpBdhJ8IRFBg2sfNe4GVln4fm7j95Xt0 +yEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=perches.com); spf=pass (google.com: domain of linux-kernel+bounces-146607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146607-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q2-20020a056a00084200b006e72d056ae5si9718271pfk.276.2024.04.16.03.14.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 03:14:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=perches.com); spf=pass (google.com: domain of linux-kernel+bounces-146607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146607-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8767D281988 for ; Tue, 16 Apr 2024 10:14:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE7E6126F36; Tue, 16 Apr 2024 10:14:44 +0000 (UTC) Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8860126F0F for ; Tue, 16 Apr 2024 10:14:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=216.40.44.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713262484; cv=none; b=Q7MH8gq3iFbwCSbHqFG/lb6Q79zlpznPoPySSwO1D/L3P6Yxrca4IrMYlh4dPqm2a9heLDPjLkEp42KVmqf90BoyIJzDoQX0ZA11wcdTzwFMnLH/3T8m0jDUR0s0Ydh64NnuF8Cu415IZrI49QBa6/9EYRKTuEOwUDxJwbd2SFA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713262484; c=relaxed/simple; bh=I+0+BTbsmwoTIEEVNzepNEL2Vxzt2tzpP8xjp+mA12A=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=r3uOzx69dqlN8O3kMn/b2mIEhizJ0lNyAhDap4mhUjeP6KbbNF+NI+sht9fIdW5mB3r5zV8UrLbQ6pWhvWAvAC3iAmq5PNLdIc6SQElP9cYLpSJF84YIbF6q7ahArRVH1ggrkL07ipp6jClAXp33C2EGWIJVcJU8a6TEneW28CY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com; spf=pass smtp.mailfrom=perches.com; arc=none smtp.client-ip=216.40.44.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=perches.com Received: from omf17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 08CE7C098E; Tue, 16 Apr 2024 09:55:14 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf17.hostedemail.com (Postfix) with ESMTPA id A4C191A; Tue, 16 Apr 2024 09:55:12 +0000 (UTC) Message-ID: Subject: Re: [PATCH] checkpatch: error if file terminates without a new-line From: Joe Perches To: Dan Carpenter , Greg KH Cc: Prasad Pandit , "linux-kernel@vger.kernel.org" , Dwaipayan Ray , Lukas Bulwahn , Andy Whitcroft Date: Tue, 16 Apr 2024 02:55:11 -0700 In-Reply-To: References: <20240330033858.3272184-1-ppandit@redhat.com> <1568855168.5949322.1713251087824@mail.yahoo.com> <2024041627-overgrown-ripping-2348@gregkh> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: A4C191A X-Stat-Signature: bw3duwewrot44jmugjm99o7jnzywb1xn X-Rspamd-Server: rspamout04 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1/vYlRzHUsKRvWlK7CBLxcaHWmex+J4wIo= X-HE-Tag: 1713261312-25940 X-HE-Meta: U2FsdGVkX1+Ajd9m6OJpXDsmwkHfDTckIPUDxgOwxTvB9mmWT0H1YjV6KUfAmV7JKPzeiNsQ3nW+/p5Ur9DWBpSkCuWa4IMjOs8J9QWsrFZUenXSz6PdoPOi7yBV9qNlz4RBmDIOO4nJjXmz2wMmgwxd9OHWIogcyJhydy4S1vWHM8fqlIl0Y9vbUthHqFcy8988+qsHEEWsfrI44tQbmZR4QlT0Cwu9MS+J7oOfCdX4KPiUY77oRRpkyCT5mhvYThFKa4sQStqyOS7pv71Pm99zJ5E70tMfLf877PZfNIDdtVTyfI9hrMQGNw+JCfMd On Tue, 2024-04-16 at 11:59 +0300, Dan Carpenter wrote: > On Tue, Apr 16, 2024 at 10:48:27AM +0200, Greg KH wrote: > > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > > > index 9c4c4a61bc83..df34c0709410 100755 > > > --- a/scripts/checkpatch.pl > > > +++ b/scripts/checkpatch.pl > > > @@ -2795,6 +2795,13 @@ sub process { > > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 $is_patch =3D 1; > > > =A0=A0=A0 =A0=A0=A0 } > > >=20 > > > +# check if patch terminates file without a new line (\n) > > > +=A0 =A0 =A0 =A0 if ($line =3D~ /^\\ No newline at end of file$/ > > > +=A0 =A0 =A0 =A0 =A0 =A0 and $rawlines[$linenr - 2] =3D~ /^\+.*$/) { > > > +=A0 =A0 =A0 =A0 =A0 =A0 ERROR("NOEOL_FILE", > > > +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "patch terminates file without a= new line (\\n)."); > > > +=A0 =A0 =A0 =A0 } > >=20 > > Why is this a problem? files without a new line should not cause > > problems with a compiler, right? You don't have a justification for wh= y > > this change needs to be checked for anywhere. > >=20 >=20 > I gave him such a good reason too... It breaks `cat file.c`. Plus, it > looks weird in `git log -p` because it has a "No newline at the end of > file" comment. >=20 > regards, > dan carpenter >=20 > diff --git a/test.c b/test.c > new file mode 100644 > index 000000000000..d808cac2d962 > --- /dev/null > +++ b/test.c > @@ -0,0 +1,12 @@ > +#include > +#include > +#include "check_debug.h" > + > +void kfree(int *p); > + > +int *p; > +int main(void) > +{ > + kfree(p); > + *p =3D 1; > +} > \ No newline at end of file >=20 > commit f4a997924122d0094675c897a220371f0a129d90 >=20 There's an existing check for this. I believe it at least used to work. Fix that instead. # check for adding lines without a newline. if ($line =3D~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =3D~ /= ^\\ No newline at end of file/) { if (WARN("MISSING_EOF_NEWLINE", "adding a line without newline at end of file\n" . $herecurr) &= & $fix) { fix_delete_line($fixlinenr+1, "No newline at end of file"); } }