Skip to contentSkip to conversation

fs: proc: move linux_proc_banner to where it is used

PATCH In review Rasmus Villemoes 3 participants 4 messages Oct 26, 2018 – Nov 5, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: proc: move linux_proc_banner to where it is used

With -Wformat-literal, gcc complains

fs/proc/version.c:11:16: warning: format not a string literal, argument types not checked [-Wformat-nonliteral]
seq_printf(m, linux_proc_banner,

linux_proc_banner is only used in this one place, so move the definition here, to allow the compiler to complain in the unlikely case one of the LINUX_* strings ended up containing a %. This also avoids compiling it in for !CONFIG_PROC_FS.

---
 fs/proc/version.c      | 6 ++++++
 include/linux/printk.h | 1 -
 init/version.c         | 5 -----
 3 files changed, 6 insertions(+), 6 deletions(-)
fs/proc/version.c +6 -0
index b449f186577f..40a33e1434d7 100644
@@ -1,4 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <generated/compile.h>
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -6,6 +7,11 @@
 #include <linux/seq_file.h>
 #include <linux/utsname.h>
 
+#define linux_proc_banner \
+	"%s version %s" \
+	" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" \
+	" (" LINUX_COMPILER ") %s\n"
+
 static int version_proc_show(struct seq_file *m, void *v)
 {
 	seq_printf(m, linux_proc_banner,
include/linux/printk.h +0 -1
index cf3eccfe1543..c7edf4398e4d 100644
@@ -9,7 +9,6 @@
 #include <linux/cache.h>
 
 extern const char linux_banner[];
-extern const char linux_proc_banner[];
 
 #define PRINTK_MAX_SINGLE_HEADER_LEN 2
 
init/version.c +0 -5
index ef4012ec4375..ead5e21fa3a3 100644
@@ -46,9 +46,4 @@ const char linux_banner[] =
 	"Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"
 	LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";
 
-const char linux_proc_banner[] =
-	"%s version %s"
-	" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
-	" (" LINUX_COMPILER ") %s\n";
-
 BUILD_SALT;
Signature · 1 line
2.19.1.6.gbde171bbf5
#1 lore raw

fs/proc/version.c line 13

Quoted 6 lines · Rasmus Villemoes
fs/proc/version.c +5 -0
+#include <generated/compile.h>
 
+#define linux_proc_banner \
+	"%s version %s" \
+	" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" \
+	" (" LINUX_COMPILER ") %s\n"

Include doesn't work if compiling from scratch:

rm -rf ../obj
mkdir ../obj
make O=../obj defconfig
make O=../obj fs/proc/version.o

CC fs/proc/version.o
fs/proc/version.c:2:10: fatal error: generated/compile.h: No such file or directory

#2 lore raw
Quoted 9 lines · Alexey Dobriyan

fs/proc/version.c line 13

Quoted 6 lines · Rasmus Villemoes
fs/proc/version.c +5 -0
+#include <generated/compile.h>
 
+#define linux_proc_banner \
+	"%s version %s" \
+	" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" \
+	" (" LINUX_COMPILER ") %s\n"

Include doesn't work if compiling from scratch:

Urgh, thanks. I assumed that all the include/generated/ stuff was always generated by the prepare steps in the top Makefile. But the logic for making compile.h is in init/Makefile.

Quoted 7 lines

rm -rf ../obj
mkdir ../obj
make O=../obj defconfig
make O=../obj fs/proc/version.o

CC fs/proc/version.o
fs/proc/version.c:2:10: fatal error: generated/compile.h: No such file or directory

The same happens in current mainline for arch/x86/boot/version.o:

$ make arch/x86/boot/version.o
  CALL    scripts/checksyscalls.sh
  DESCEND  objtool
  CC      arch/x86/boot/version.o
arch/x86/boot/version.c:17:31: fatal error: generated/compile.h: No such
file or directory

Cc kbuild: Wouldn't it be a little nicer creating generated/compile.h along with the other files in generated/, so that everybody can rely on them being there instead of having the logic for compile.h hidden away in init/Makefile and listing it as an explicit dependency? Or is there some reason compile.h is special?

Rasmus

#3 lore raw
Quoted 33 lines · Rasmus Villemoes
Quoted 9 lines · Alexey Dobriyan

fs/proc/version.c line 13

Quoted 6 lines · Rasmus Villemoes
fs/proc/version.c +5 -0
+#include <generated/compile.h>
 
+#define linux_proc_banner \
+    "%s version %s" \
+    " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" \
+    " (" LINUX_COMPILER ") %s\n"

Include doesn't work if compiling from scratch:

Urgh, thanks. I assumed that all the include/generated/ stuff was always generated by the prepare steps in the top Makefile. But the logic for making compile.h is in init/Makefile.

Quoted 7 lines

rm -rf ../obj
mkdir ../obj
make O=../obj defconfig
make O=../obj fs/proc/version.o

CC fs/proc/version.o
fs/proc/version.c:2:10: fatal error: generated/compile.h: No such file or directory

The same happens in current mainline for arch/x86/boot/version.o:

$ make arch/x86/boot/version.o
  CALL    scripts/checksyscalls.sh
  DESCEND  objtool
  CC      arch/x86/boot/version.o
arch/x86/boot/version.c:17:31: fatal error: generated/compile.h: No such
file or directory
Quoted 8 lines

Cc kbuild: Wouldn't it be a little nicer creating generated/compile.h along with the other files in generated/, so that everybody can rely on them being there instead of having the logic for compile.h hidden away in init/Makefile and listing it as an explicit dependency? Or is there some reason compile.h is special?

Rasmus

I think the basic idea is,
the build version should not be incremented
if you do incremental build without touching any source file.

If you create/update <generated/compile.h> first,
you never know whether the .version should be incremented or not.

Signature · 2 lines
Best Regards
Masahiro Yamada