Re: [PATCH] checkpatch: error if file terminates without a new-line

From: Greg KH
Date: Tue Apr 16 2024 - 04:48:38 EST


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@xxxxxxxxxx> 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@xxxxxxxxxxxxxxxxx>
>
> Add check to flag an error if a patch terminates a file
> without a new line (\n) character.
>
> Suggested-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Signed-off-by: Prasad Pandit <pjp@xxxxxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxx/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