* Re: [PATCH] checkpatch: error if file terminates without a new-line [not found] <20240330033858.3272184-1-ppandit@redhat.com> @ 2024-04-16 7:04 ` Prasad Pandit 2024-04-16 8:48 ` Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Prasad Pandit @ 2024-04-16 7:04 UTC (permalink / raw) To: linux-kernel@vger.kernel.org Cc: Joe Perches, Dwaipayan Ray, Lukas Bulwahn, Dan Carpenter, Greg KH, Andy Whitcroft [+linux-kernel] On Saturday, 30 March, 2024 at 09:09:12 am IST, Prasad Pandit <ppandit@redhat.com> wrote: From: Prasad Pandit <pjp@fedoraproject.org> Add check to flag an error if a patch terminates a file without a new line (\n) character. Suggested-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Prasad Pandit <pjp@fedoraproject.org> --- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+) -> https://lore.kernel.org/all/CAE8KmOxG=3sWKpeB5fdWTK-SCipS=JyDE-_DNgY--DtoSQZ0Qw@mail.gmail.com/T/#t 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 { $is_patch = 1; } +# check if patch terminates file without a new line (\n) + if ($line =~ /^\\ No newline at end of file$/ + and $rawlines[$linenr - 2] =~ /^\+.*$/) { + ERROR("NOEOL_FILE", + "patch terminates file without a new line (\\n)."); + } + #extract the line range in the file after the patch is applied if (!$in_commit_log && $line =~ /^\@\@ -\d+(?:,\d+)? \+(\d+)(,(\d+))? \@\@(.*)/) { -- 2.44.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] checkpatch: error if file terminates without a new-line 2024-04-16 7:04 ` [PATCH] checkpatch: error if file terminates without a new-line Prasad Pandit @ 2024-04-16 8:48 ` Greg KH 2024-04-16 8:59 ` Dan Carpenter 0 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2024-04-16 8:48 UTC (permalink / raw) To: Prasad Pandit Cc: linux-kernel@vger.kernel.org, Joe Perches, Dwaipayan Ray, Lukas Bulwahn, Dan Carpenter, Andy Whitcroft On Tue, Apr 16, 2024 at 07:04:47AM +0000, Prasad Pandit wrote: > [+linux-kernel] > > On Saturday, 30 March, 2024 at 09:09:12 am IST, Prasad Pandit <ppandit@redhat.com> wrote: Why are these lines in a changelog of a patch to submit? That's not going to work :( I suggest taking some time and talking to some other kernel developers in red hat as to how to submit changes, that will make things much easier. > From: Prasad Pandit <pjp@fedoraproject.org> > > Add check to flag an error if a patch terminates a file > without a new line (\n) character. > > Suggested-by: Dan Carpenter <dan.carpenter@linaro.org> > Signed-off-by: Prasad Pandit <pjp@fedoraproject.org> Also, I see 3 different emails for you here, none of which match, pick one for kernel development and stick with it? > --- > scripts/checkpatch.pl | 7 +++++++ > 1 file changed, 7 insertions(+) > > -> https://lore.kernel.org/all/CAE8KmOxG=3sWKpeB5fdWTK-SCipS=JyDE-_DNgY--DtoSQZ0Qw@mail.gmail.com/T/#t > > 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 { > $is_patch = 1; > } > > +# check if patch terminates file without a new line (\n) > + if ($line =~ /^\\ No newline at end of file$/ > + and $rawlines[$linenr - 2] =~ /^\+.*$/) { > + ERROR("NOEOL_FILE", > + "patch terminates file without a new line (\\n)."); > + } 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 why this change needs to be checked for anywhere. thanks, greg k-h ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] checkpatch: error if file terminates without a new-line 2024-04-16 8:48 ` Greg KH @ 2024-04-16 8:59 ` Dan Carpenter 2024-04-16 9:55 ` Joe Perches 0 siblings, 1 reply; 5+ messages in thread From: Dan Carpenter @ 2024-04-16 8:59 UTC (permalink / raw) To: Greg KH Cc: Prasad Pandit, linux-kernel@vger.kernel.org, Joe Perches, Dwaipayan Ray, Lukas Bulwahn, Andy Whitcroft 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 { > > $is_patch = 1; > > } > > > > +# check if patch terminates file without a new line (\n) > > + if ($line =~ /^\\ No newline at end of file$/ > > + and $rawlines[$linenr - 2] =~ /^\+.*$/) { > > + ERROR("NOEOL_FILE", > > + "patch terminates file without a new line (\\n)."); > > + } > > 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 why > this change needs to be checked for anywhere. > 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. regards, dan carpenter 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 <stdio.h> +#include <stdbool.h> +#include "check_debug.h" + +void kfree(int *p); + +int *p; +int main(void) +{ + kfree(p); + *p = 1; +} \ No newline at end of file commit f4a997924122d0094675c897a220371f0a129d90 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] checkpatch: error if file terminates without a new-line 2024-04-16 8:59 ` Dan Carpenter @ 2024-04-16 9:55 ` Joe Perches 2024-04-17 6:36 ` Prasad Pandit 0 siblings, 1 reply; 5+ messages in thread From: Joe Perches @ 2024-04-16 9:55 UTC (permalink / raw) To: Dan Carpenter, Greg KH Cc: Prasad Pandit, linux-kernel@vger.kernel.org, Dwaipayan Ray, Lukas Bulwahn, Andy Whitcroft 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 { > > > $is_patch = 1; > > > } > > > > > > +# check if patch terminates file without a new line (\n) > > > + if ($line =~ /^\\ No newline at end of file$/ > > > + and $rawlines[$linenr - 2] =~ /^\+.*$/) { > > > + ERROR("NOEOL_FILE", > > > + "patch terminates file without a new line (\\n)."); > > > + } > > > > 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 why > > this change needs to be checked for anywhere. > > > > 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. > > regards, > dan carpenter > > 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 <stdio.h> > +#include <stdbool.h> > +#include "check_debug.h" > + > +void kfree(int *p); > + > +int *p; > +int main(void) > +{ > + kfree(p); > + *p = 1; > +} > \ No newline at end of file > > commit f4a997924122d0094675c897a220371f0a129d90 > 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 =~ /^\+/ && defined $lines[$linenr] && $lines[$linenr] =~ /^\\ 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"); } } ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] checkpatch: error if file terminates without a new-line 2024-04-16 9:55 ` Joe Perches @ 2024-04-17 6:36 ` Prasad Pandit 0 siblings, 0 replies; 5+ messages in thread From: Prasad Pandit @ 2024-04-17 6:36 UTC (permalink / raw) To: Joe Perches Cc: linux-kernel@vger.kernel.org, Dwaipayan Ray, Lukas Bulwahn, Andy Whitcroft, Greg Kroah-Hartman, Dan Carpenter On Tuesday, 16 April, 2024 at 03:25:18 pm IST, Joe Perches wrote: >There's an existing check for this. Fix that instead. > ># check for adding lines without a newline. > if ($line =~ /^\+/ && defined $lines[$linenr] > && $lines[$linenr] =~ /^\\ 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"); Okay, will check; Thank you. --- -Prasad ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-04-17 6:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240330033858.3272184-1-ppandit@redhat.com>
2024-04-16 7:04 ` [PATCH] checkpatch: error if file terminates without a new-line Prasad Pandit
2024-04-16 8:48 ` Greg KH
2024-04-16 8:59 ` Dan Carpenter
2024-04-16 9:55 ` Joe Perches
2024-04-17 6:36 ` Prasad Pandit
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.