Commit Graph

17 Commits

Author SHA1 Message Date
Martin Roth 15f4d8c1bb kconfig_lint: demote 'always defined' errors to warnings
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-09 21:52:45 +01:00
Martin Roth 662237614b kconfig_lint: Check for IS_ENABLED used on symbols without CONFIG_
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-02-09 21:51:46 +01:00
Martin Roth 08cf90f860 kconfig_lint: add comments and whitespace fixes.
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-30 17:29:26 +01:00
Martin Roth ab2d777360 kconfig_lint: Skip temp files when looking for unused Kconfig files.
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-30 17:29:04 +01:00
Martin Roth b58d349ca9 kconfig_lint: Update prompt structure
- 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-30 17:28:44 +01:00
Martin Roth 08ee1cfafc kconfig_lint: Add warning if tristate type is used in coreboot
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-30 17:28:19 +01:00
Martin Roth 819e67242f kconfig_lint: merge 'git grep' and 'grep' exclude dir and files
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-30 17:27:30 +01:00
Martin Roth 572a856b97 kconfig_lint: Don't look at IS_ENABLED() text in comments.
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-30 17:27:07 +01:00
Martin Roth 6bfbf1c66f kconfig_lint: Exclude some Kconfig symbols from unused symbol checks
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-30 17:26:34 +01:00
Martin Roth 63ea4930e4 kconfig_lint: merge 'git grep' and 'grep' exclude dir and files
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-30 17:26:03 +01:00
Martin Roth b7c39b2bc1 util/lint/kconfig_lint: Add 3 new checks
- 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-18 01:50:09 +01:00
Martin Roth 1b44f7e390 util/lint/kconfig_lint: Run through perltidy to fix whitespace
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>
2016-01-12 22:32:45 +01:00
Martin Roth b6acc3071f kconfig_lint: Fix check_is_enabled for 2 symbols on the same line
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-02 16:09:34 +01:00
Martin Roth 7aa3ceaf24 kconfig_lint: Change from '$file at line $line' to $file:$line
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-02 16:09:06 +01:00
Martin Roth d808017760 kconfig_lint: Separate errors from warnings
- 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-12-02 16:08:39 +01:00
Patrick Georgi a73b93157f tree: drop last paragraph of GPL copyright header
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-31 21:37:39 +01:00
Martin Roth bcaaad1c55 lint: Add Kconfig / Kconfig symbol lint tool
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>
2015-10-29 17:05:08 +01:00