blob: c36320edb22ebb315008c35c95d4b74c1ab350eb [file] [log] [blame]
Martin Rothb5400ad2016-01-25 20:10:14 -07001kconfig_lint is a tool to help identify issues within coreboot's Kconfig
2files. It is very specific to coreboot, and is not intended to be used as a
3generic Kconfig lint tool for other projects.
4
5Operation:
6kconfig_lint parses the entire kconfig tree, building up a hash table of all
7of the statements. It then searches the coreboot tree looking for all usage of
8any Kconfig symbols. By combining these two, it is able to find many issues
9that would be difficult to locate otherwise.
10
11Usage:
12kconfig_lint <options>
13 -o|--output=file Set output filename
14 -p|--print Print full output
15 -e|--errors_off Don't print warnings or errors
16 -w|--warnings_off Don't print warnings
17 -n|--notes Show minor notes
18 -G|--no_git_grep Use standard grep tools instead of git grep
19
20
21Options:
22 -o|--output=file Send the output to a file instead of printing to stdout.
23
24 -p|--print Shows the entire Kconfig tree as parsed by kconfig_lint,
25 including the filename and line number of each statement.
26 This can be very helpful for debugging Kconfig issues.
27
28 -e|--errors_off Suppress both error and warning output. Useful along with
29 the --print command
30
31-w|--warnings_off Suppress warning output
32
33-n|--notes Enable the display of minor notes that kconfig_lint has
34 found. These might be issues, but probably are not.
35
36 -G|--no_git_grep Instead of using the 'git grep' command, use regular grep.
37 This is useful for checking coreboot trees that are not
38 contained in a git repo.
39
40Issues that kconfig_lint checks for:
41
42Notes:
43- Show when the range set for a hex or int does not match a previous range
44
45Warnings in Kconfig files:
46- Any 'default' expressions that can never be reached.
47- Symbols that are defined but never used.
48- Help text starting with no whitespace.
49- Directories specified in a 'source' keyword do not exist.
50- A 'source' keyword loading a Kconfig file that has already been loaded.
51- A 'source' keyword loading a Kconfig file that doesn't exist. Note that
52 globs are excluded from this check.
53
54Warnings in coreboot source files:
55- #define of Kconfig symbol - Symbols should only be defined in Kconfig.
56- #define starting with 'CONFIG_' - these should be reserved for Kconfig
57 symbols.
58- 'IS_ENABLED()' block that could not be interpreted.
59- Kconfig files that are not loaded by a 'source' keyword.
Martin Roth15f4d8c2016-01-31 10:44:33 -070060- '#ifdef' or '#if defined' used on bool, int, or hex - these are always
61 defined in coreboot's version of Kconfig.
Martin Rothb5400ad2016-01-25 20:10:14 -070062
63Errors in Kconfig files:
64- Selects do not work on symbols created in a choice block.
65- All symbols used in selects or expressions must be defined in a config
66 statement.
67- 'endchoice' keyword not used in a choice block
68- Choice block defined with no symbols.
69- The 'tristate' type is not used in coreboot.
70- A 'select' keyword used outside of a config block.
71- Symbols created both inside and outside of a choice block.
72- A 'range' keyword has higher minimum than maximum value.
73- A config block with a prompt at the top level (the top level is currently
74 just for menus).
75- Indentation using spaces instead of tabs. We indent using tabs, although
76 the tab may be followed by spaces, particularly for help blocks.
77- Lines not ending with a linefeed. These can cause some keywords to not
78 function properly ('source' keywords in particular). It's also just
79 generally good to end the file with a linefeed.
80
81Errors in Kconfig that are also caught by Kconfig itself:
82- Invalid expressions.
83- Unrecognized keywords.
84- An 'optional' keyword used outside of a choice block
85- The 'select' keyword only works on bool symbols.
86- A 'range' keyword used outside of a config block.
87- A 'default' keyword used outside of a config or choice block.
88- Symbol types must be consistent - they cannot be bool in one location and
89 int in another location.
90- Type keywords (bool, int, hex, string) used outside of a config block.
91- Using a 'prompt' keyword not inside a config or choice block.
Martin Roth08705f12016-11-09 14:27:00 -070092- Symbols with no defined type.
Martin Rothb5400ad2016-01-25 20:10:14 -070093
94Errors in coreboot source files:
Martin Rothb5400ad2016-01-25 20:10:14 -070095- The IS_ENABLED macro is only valid for bool symbols.
96- The IS_ENABLED used on unknown CONFIG_ value, like an obsolete symbol.
Martin Roth66223762016-01-31 10:34:13 -070097- The IS_ENABLED macro is used on a symbol without the CONFIG_ prefix.
Martin Rothb5400ad2016-01-25 20:10:14 -070098
99TODO: check for choice entries at the top level