]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
kconfig: warn no new line at end of file
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Tue, 11 Dec 2018 11:00:51 +0000 (20:00 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Sat, 15 Dec 2018 08:44:35 +0000 (17:44 +0900)
It would be nice to warn if a new line is missing at end of file.

We could do this by checkpatch.pl for arbitrary files, but new line
is rather essential as a statement terminator in Kconfig.

The warning message looks like this:

  kernel/Kconfig.preempt:60:warning: no new line at end of file

Currently, kernel/Kconfig.preempt is the only file with no new line
at end of file. Fix it.

I know there are some false negative cases. For example, no warning
is displayed when the last line contains some whitespaces/comments,
but no new line. Yet, this commit works well for most cases.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
kernel/Kconfig.preempt
scripts/kconfig/zconf.l

index cd1655122ec0bb8b73def7adbb8d8f8f3c7d0cb8..0fee5fe6c89905257a65969846c45a12794b898e 100644 (file)
@@ -57,4 +57,4 @@ config PREEMPT
 endchoice
 
 config PREEMPT_COUNT
-       bool
\ No newline at end of file
+       bool
index 9038e9736bf03cf489ab50d1348e429d3885268a..8e856f9e6da980c2e94a72f77f56154c61503e0d 100644 (file)
@@ -261,6 +261,10 @@ n  [A-Za-z0-9_-]
 <<EOF>>        {
        BEGIN(INITIAL);
 
+       if (prev_token != T_EOL && prev_token != T_HELPTEXT)
+               fprintf(stderr, "%s:%d:warning: no new line at end of file\n",
+                       current_file->name, yylineno);
+
        if (current_file) {
                zconf_endfile();
                return T_EOL;