checkpatch: Add check for space indentation in Kconfig
PATCH 1/1 checkpatch: Add check for space indentation in Kconfig
U-Boot requires Kconfig options to be indented with tabs, whereas Linux allows spaces. Add a U-Boot specific check to warn when spaces are used for indentation in Kconfig files.
To ensure this check is executed, move the u_boot_line() invocation in process() to occur before the valid source file check. Previously, Kconfig files were skipped by the file extension filter before the U-Boot specific checks could run.
Example warning:
WARNING: Kconfig indentation should use tabs
+ bool
--- scripts/checkpatch.pl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
scripts/checkpatch.pl +10 -4
@@ -2753,6 +2753,12 @@ sub u_boot_line { ERROR("CONFIG_xPL_BUILD", "Do not use CONFIG_xPL_BUILD in device trees\n" . $herecurr); } + + # Kconfig should use tabs for indentation + if ($realfile =~ /Kconfig/ && $line =~ /^\+ /) { + WARN("KCONFIG_INDENT", + "Kconfig indentation should use tabs\n" . $herecurr); + } } sub exclude_global_initialisers {
@@ -3943,6 +3949,10 @@ sub process { "It's generally not useful to have the filename in the file\n" . $herecurr); } + if ($u_boot) { + u_boot_line($realfile, $line, $rawline, $herecurr); + } + # check we are in a valid source file if not then ignore this hunk next if ($realfile !~ /\.(h|c|rs|s|S|sh|dtsi|dts|env)$/);
@@ -4034,10 +4044,6 @@ sub process { "Avoid using '.L' prefixed local symbol names for denoting a range of code via 'SYM_*_START/END' annotations; see Documentation/core-api/asm-annotations.rst\n" . $herecurr); } - if ($u_boot) { - u_boot_line($realfile, $line, $rawline, $herecurr); - } - # check we are in a valid source file C or perl if not then ignore this hunk next if ($realfile !~ /\.(h|c|pl|dtsi|dts)$/);
Signature · 1 line
2.52.0.322.g1dd061c0dc-goog
Quoted 9 lines · Kuan-Wei Chiu
U-Boot requires
Kconfigoptions to be indented with tabs, whereas Linux allows spaces. Add a U-Boot specific check to warn when spaces are used for indentation inKconfigfiles.To ensure this check is executed, move the
u_boot_line()invocation inprocess()to occur before the valid source file check. Previously,Kconfigfiles were skipped by the file extension filter before the U-Boot specific checks could run.
Quoted 7 lines
Example warning:
WARNING:
Kconfigindentation should use tabs
+ bool
Thanks!
Signature · 1 line
Tom
Quoted 10 lines · Kuan-Wei Chiu
U-Boot requires
Kconfigoptions to be indented with tabs, whereas Linux allows spaces. Add a U-Boot specific check to warn when spaces are used for indentation inKconfigfiles.To ensure this check is executed, move the
u_boot_line()invocation inprocess()to occur before the valid source file check. Previously,Kconfigfiles were skipped by the file extension filter before the U-Boot specific checks could run.[...]
Applied to u-boot/master, thanks!
[1/1] checkpatch: Add check for space indentation in Kconfig
commit: eea1c6ec4ead013fcdbc1f4ee1a5f595d58ca303
Signature · 1 line
Tom