summaryrefslogtreecommitdiff
path: root/util/lint/kconfig_lint
AgeCommit message (Collapse)Author
2018-11-17treewide: use /usr/bin/env where appropriateYegor Timoshenko
Some Unix systems (GuixSD, NixOS) do not install programs like Bash and Python to /usr/bin, and /usr/bin/env has to be used to locate these instead. Change-Id: I7546bcb881c532adc984577ecb0ee2ec4f2efe00 Signed-off-by: Yegor Timoshenko <yegortimoshenko@riseup.net> Reviewed-on: https://review.coreboot.org/28953 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2018-09-18util/lint: Ignore "visible if" statement in Kconfig filesPatrick Georgi
They allow reducing the visible set of options to remove clutter. Change-Id: I18c953c7feae23c0752392a2bf8f49783c17310e Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/28635 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Martin Roth <martinroth@google.com>
2017-07-18util/lint: update kconfig_lintMartin Roth
* Add check for '#if defined' as well as #ifdef * Add check for IS_ENABLED() around bools in #if statements. * Fix an incomplete comment. Change-Id: I0787eab80ae64f59664fb53f395389bf5ac2a067 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/20360 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
2017-06-07util/lint: Give better warning for help spacing issueMartin Roth
Because the help block uses significant whitespace to determine whether or not text is inside the help block, a mixture of spaces and tabs confuses the parser. If there's an unrecognized line, and the previous line was inside a help block, it's likely that this line is too. Additionally, this was found with a line that started ' configuration', and threw a perl warning about an uninitialized value because the parser thought this was the start of a new config line, but couldn't find the symbol. Now we make sure that config statements have whitespace after the 'config' statement. Change-Id: I46375738a18903b266ea9fff3102a1a91235e609 Signed-off-by: Martin Roth <gaumless@gmail.com> Reviewed-on: https://review.coreboot.org/19155 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2017-06-07util/lint/kconfig_lint: update help checkingMartin Roth
- Turn the check for help text with no indentation from a warning to an error. - Show an error if the help text is at the same indentation level as the 'help' keyword. Change-Id: Ibf868c83e2a128ceb6c4d3da7f2cf7dc237054e6 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/19851 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2017-03-27util/lint: Show an error if a symbol is created in two choice blocksMartin Roth
Kconfig shows a warning about this, but we want to catch it earlier and halt the build. Change-Id: I0acce1d40a6ca2b212c638bdb1ec65de5bd4d726 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/18970 Tested-by: build bot (Jenkins) Reviewed-by: Subrata Banik <subrata.banik@intel.com> Reviewed-by: Patrick Georgi <pgeorgi@google.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
2016-12-12lint/kconfig_lint: Make sure all symbols have a type definedMartin Roth
Show an error if a symbol does not have a defined type. This caused a problem of an undefined symbol in check_defaults, so we just skip those symbols there as we can't verify the default pattern without knowing the type. Change-Id: I28711a77962e16f6fc89789400363edd0fdd0931 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/17345 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@googlemail.com> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2016-11-28kconfig_lint: More updates for excluded filesMartin Roth
- All of the symbols are in the .config, so if .config is include in the search all of the symbols are always found. - There are now some Kconfig symbols in the Documentation directory, so that needs to be excluded. - 3rdparty has lots of Kconfig symbols that are unrelated to what is being searched for. Change-Id: I0ff56d0a0916338a8b94f5210b8e0b3be5194f41 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/17588 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2016-11-28kconfig_lint: exclude payloads from search, add back specific filesMartin Roth
Don't search for symbols in the payloads directory, except for specific files that are actively added back to the search. Change-Id: I6f28dc7dee040b8061fa5644066f3613367b6d84 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/17443 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2016-10-03Revert "util/lint/kconfig_lint: change warning levels and text"Martin Roth
This reverts commit dfdb0733a6a71b11d15006dafc13841e84fab7cd. Change-Id: I91bf5e42f4ac241f544742ce161bae651f9f9947 Reviewed-on: https://review.coreboot.org/16868 Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Tested-by: build bot (Jenkins)
2016-10-03util/lint/kconfig_lint: change warning levels and textMartin Roth
- Add an exception for MAINBOARD_POWER_ON_AFTER_POWER_FAIL when checking - With those exceptions set, we don't have anymore #define or #ifdef warnings, so turn them to errors so no more can be pushed. - Change the definition of an unused symbol from a warning to a note. There are times when unused symbols are expected. - Upgrade the warning for loading Kconfig files multiple times from a warning to an error. Change-Id: I6dcb06d4f0b099d5ccaf7643e72dd790719bdf58 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/16840 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-10-03util/lint/kconfig_lint: Check default typesMartin Roth
The type of the default value wasn't being checked to make sure that it matched the type of the Kconfig symbol. This makes sure that the symbol is being set to either a reasonable looking value or to another Kconfig symbol. Change-Id: Ia01bd2d8b387f319d29f0a005d55cb8e20cd3853 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/16839 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-03-03kconfig_lint: make sure if and endif statements are balancedMartin Roth
In Kconfig files, the 'if' and 'endif' statements need to match up. A file can't start an if statement that's completed in the next file. Add a check as the files are being parsed to make sure that they match up correctly. Change-Id: If51207ea037089ab84c768e5a868270468cf4c4f Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13876 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-02-24kconfig_lint: Fix checks when running in taint modeMartin Roth
The builders run perl scripts in taint mode, and some of the checks that the kconfig lint script were running were tainted, causing the script to terminate early when running on the servers. This checks to see if taint mode is enabled, and untaints the path if it is. All external tools (git & grep) must be in /bin, /usr/bin, or /usr/local/bin. This also removes the check for unused kconfig files if taint mode is enabled. Change-Id: I8d1e1c32275f759d085759fb5d8a6c85d4f99539 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13751 Reviewed-by: Patrick Georgi <pgeorgi@google.com> Tested-by: build bot (Jenkins)
2016-02-09kconfig_lint: demote 'always defined' errors to warningsMartin Roth
To be able to run this as a lint-stable test, demote these to warnings for now. After the current CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL issues get fixed, these can be promoted again. Change-Id: I1432980eb0c871fc61c12dcc351f8d46513a7965 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13541 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-02-09kconfig_lint: Check for IS_ENABLED used on symbols without CONFIG_Martin Roth
This looks at the coreboot codebase for the IS_ENABLED macro, and gives an error if there is a symbol used without the CONFIG_ prefix. This only works for symbols of type bool. A future check will be added for all symbols, but that will take a significant amount of time to run, because each symbol will need to be searched for individually. Change-Id: I92f2de2d231610d1a788da965f21966d89c2f25c Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13538 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-01-30kconfig_lint: add comments and whitespace fixes.Martin Roth
No functional changes. Change-Id: I40284b68ddda7e19741c5306a8c74761c00e4b35 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13463 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-01-30kconfig_lint: Skip temp files when looking for unused Kconfig files.Martin Roth
Don't warn on Kconfig.orig and Kconfig~ files when trying to verify that all the Kconfig files in the coreboot source tree are being loaded. Change-Id: Ie7babe60b29735e5ccc5f93f4e42ad82dfb47044 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13462 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-01-30kconfig_lint: Update prompt structureMartin Roth
- The prompts were not getting incremented, so each prompt for a symbol would overwrite the previous. - Record the menu each prompt is in. Change-Id: Ia282a30344d5e135f4f2027be9aff0e49a4e5edb Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13461 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-01-30kconfig_lint: Add warning if tristate type is used in corebootMartin Roth
Although there's no reason we COULDN'T use tristate types, we haven't up to this point. If there's a good reason to use them in the future, this check can be removed. Change-Id: I5f1903341f522bc957e394bc0fd288ba1adab431 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13460 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-01-30kconfig_lint: merge 'git grep' and 'grep' exclude dir and filesMartin Roth
The code had originally been using standard grep to look through the coreboot tree for Kconfig symbols. When this was switched to git grep, the --exclude-dir options didn't work, and nothing was added to exclude the directories that shouldn't be searched for symbols. This resulted in invalid warnings as it searched directories that had Kconfig symbols for other projects. This merges the exclusion list for both the regular and git versions of grep for consistent behavior. Change-Id: I7fed8b9fa827cb14f7373e7b774acc56e43cb6ff Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13459 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-01-30kconfig_lint: Don't look at IS_ENABLED() text in comments.Martin Roth
This fixes at least one kconfig_lint warning. Change-Id: I35edf57e90315a8372aaf3b41e923cd8dad7386a Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13458 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-01-30kconfig_lint: Exclude some Kconfig symbols from unused symbol checksMartin Roth
The configuration that coreboot uses for setting selected symbols typically involves a structure like this: config BLEH_SPECIFIC_OPTIONS def_bool y select SYMBOL This leads to an an extra kconfig symbol BLEH_SPECIFIC_OPTIONS that is never referenced by anything else, generating a warning. Since this is currently the construct that coreboot uses, filter it out of the warnings for now. Change-Id: I85a95e4c4e8469870c7f219f2a92955819845573 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13457 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-01-30kconfig_lint: merge 'git grep' and 'grep' exclude dir and filesMartin Roth
The code had originally been using standard grep to look through the coreboot tree for Kconfig symbols. When this was switched to git grep, the --exclude-dir options didn't work, and nothing was added to exclude the directories that shouldn't be searched for symbols. This resulted in invalid warnings as it searched directories that had Kconfig symbols for other projects. This merges the exclusion list for both the regular and git versions of grep for consistent behavior. Change-Id: I69a1e0b30fecca152e02a511c82248b6091b3d8b Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13456 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-01-18util/lint/kconfig_lint: Add 3 new checksMartin Roth
- Check that selected symbols are type bool - Check that selected symbols aren't created inside a choice - Check that symbols created inside a choice aren't created outside of a choice as well. Change-Id: I08963d637f8bdfb2413cfe831eafdc974d7674ab Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/12969 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2016-01-12util/lint/kconfig_lint: Run through perltidy to fix whitespaceMartin Roth
Change-Id: I7f04156fff0b65ea262b12961ce76ef329d358ab Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/12902 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
2015-12-02kconfig_lint: Fix check_is_enabled for 2 symbols on the same lineMartin Roth
The previous code would miss the first of two IS_ENABLED(CONFIG_symbol) sequences on a line. This patch saves the rest of the line and loops to check any other entries on the same line of text. Change-Id: If4e66d5b393cc5703a502887e18f0ac11adff012 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/12562 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-12-02kconfig_lint: Change from '$file at line $line' to $file:$lineMartin Roth
Combine the file and line number into a combination that editors understand when opening files. This makes it easier to edit the errors. Change-Id: Id2fae6a0a2ca8d726b95e252d80ac918f4edbe23 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/12561 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-12-02kconfig_lint: Separate errors from warningsMartin Roth
- Create subroutines for printing warnings and errors - Change all the existing warning and error routines to use subroutines - Add new command line options to suppress errors and to print notes Change-Id: I04893faffca21c5bb7b51be920cca4620dc283c3 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/12555 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-10-31tree: drop last paragraph of GPL copyright headerPatrick Georgi
It encourages users from writing to the FSF without giving an address. Linux also prefers to drop that and their checkpatch.pl (that we imported) looks out for that. This is the result of util/scripts/no-fsf-addresses.sh with no further editing. Change-Id: Ie96faea295fe001911d77dbc51e9a6789558fbd6 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/11888 Tested-by: build bot (Jenkins) Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2015-10-29lint: Add Kconfig / Kconfig symbol lint toolMartin Roth
This is a tool to help identify issues in coreboot's Kconfig structure and in how the Kconfig symbols are used in the coreboot codebase. It identifies a number of issues: - #ifdef used on Kconfig symbol of type bool, hex, or int. These are always defined. - #define CONFIG_ in the coreboot code - these should be reserved for Kconfig symbols. - Redefinition of Kconfig symbols in the code. - Use of IS_ENABLED() on non-bool kconfig symbols. - Use of IS_ENABLED() on values that are not kconfig symbols. - Attempts to find default values that will not set anything because of earlier default settings. This needs to be expanded significantly. - Kconfig expressions using symbols which are not defined. - Kconfig symbols that are defined but not used anywhere in the Kconfig structure or coreboot code. - Kconfig keywords used incorrectly. - Whitespace issues - Kconfig 'source' keyword issues -- sourcing non-existant directories -- sourcing Kconfig files multiple times -- sourcing non-existent files -- Kconfig files in the codebase that are never sourced Additionally, it can be used to help debug the Kconfig tree by putting all the files together into a single file with their source locations listed. Run from the coreboot directory: util/lint/kconfig_lint Change-Id: Ia53b366461698d949f17502e99265c1f3f3b1443 Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: http://review.coreboot.org/12088 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>