[U-Boot] scripts to sanity-check the Kconfig files

Robert P. J. Day rpjday at crashcourse.ca
Wed Jan 4 15:38:58 CET 2017


  while i'm in a chatty mood, a few years back, i wrote some simple
shell scripts that scanned the linux kernel source tree for
inconsistencies in the Kconfig files, and pointed out things like
"config" entries that were never used or tested, "select" directives
that referred to non-existent variables, and so on.

  i just ran that first script on the current u-boot source, and there
are quite a number of these. as just partial output, here are some
Kconfig variables that are (apparently, as long as i didn't screw up
anything in the script) defined but never used or tested anywhere:

  ... snip ...
  >>>>> CMD_MX_CYCLIC
  cmd/Kconfig:338:config CMD_MX_CYCLIC
  >>>>> CPU_SPECIFIC_OPTIONS
  arch/x86/cpu/ivybridge/Kconfig:23:config CPU_SPECIFIC_OPTIONS
  arch/x86/cpu/broadwell/Kconfig:21:config CPU_SPECIFIC_OPTIONS
  >>>>> DEBUG_EFI_CONSOLE
  drivers/serial/Kconfig:115:config DEBUG_EFI_CONSOLE
  >>>>> DM_MOD_EXP
  drivers/crypto/rsa_mod_exp/Kconfig:1:config DM_MOD_EXP
  ... snip ...

so as to that first example, that shows that the variable
CMD_MX_CYCLIC is defined in cmd/Kconfig:

  config CMD_MX_CYCLIC
        bool "mdc, mwc"
        help
          mdc - memory display cyclic
          mwc - memory write cyclic

but is never tested for anything, and a grep seems to show that:

$ grep -r CMD_MX_CYCLIC *
cmd/Kconfig:config CMD_MX_CYCLIC
configs/sandbox_noblk_defconfig:CONFIG_CMD_MX_CYCLIC=y
configs/sandbox_spl_defconfig:CONFIG_CMD_MX_CYCLIC=y
configs/sandbox_defconfig:CONFIG_CMD_MX_CYCLIC=y
$

  OTOH, if you search for just "MX_CYCLIC":

$ grep -r MX_CYCLIC *A
cmd/Kconfig:config CMD_MX_CYCLIC
cmd/mem.c:#ifdef CONFIG_MX_CYCLIC
cmd/mem.c:#endif /* CONFIG_MX_CYCLIC */
cmd/mem.c:#ifdef CONFIG_MX_CYCLIC
cmd/mem.c:#endif /* CONFIG_MX_CYCLIC */
configs/sandbox_noblk_defconfig:CONFIG_CMD_MX_CYCLIC=y
configs/sandbox_spl_defconfig:CONFIG_CMD_MX_CYCLIC=y
configs/sandbox_defconfig:CONFIG_CMD_MX_CYCLIC=y
include/configs/ea20.h:#define CONFIG_MX_CYCLIC
include/configs/lwmon5.h:#define CONFIG_MX_CYCLIC        1       /* enable mdc/mwc commands      */
include/configs/M5249EVB.h:#define CONFIG_MX_CYCLIC	1	/* enable mdc/mwc commands	*/
include/configs/PMC405DE.h:#define CONFIG_MX_CYCLIC	1	/* enable mdc/mwc commands      */
include/configs/x600.h:#define CONFIG_MX_CYCLIC		/* enable mdc/mwc commands      */
include/configs/ipam390.h:#define CONFIG_MX_CYCLIC
include/configs/da850evm.h:#define CONFIG_MX_CYCLIC
include/configs/bcm23550_w1d.h:#define CONFIG_MX_CYCLIC
include/configs/bcm28155_ap.h:#define CONFIG_MX_CYCLIC
include/configs/omapl138_lcdk.h:#define CONFIG_MX_CYCLIC
include/configs/bcm_ep_board.h:#define CONFIG_MX_CYCLIC
include/configs/amcore.h:#define CONFIG_MX_CYCLIC		1 /* enable mdc/mwc commands	*/
include/configs/digsy_mtc.h:#define CONFIG_MX_CYCLIC	1
include/configs/amcc-common.h:#define CONFIG_MX_CYCLIC		/* enable mdc/mwc commands      */
include/configs/xtfpga.h:#define CONFIG_MX_CYCLIC
include/configs/xilinx-ppc.h:#define CONFIG_MX_CYCLIC		/* enable mdc/mwc commands      */
include/configs/ti_armv7_keystone2.h:#define CONFIG_MX_CYCLIC
include/configs/PMC440.h:#define CONFIG_MX_CYCLIC	1	/* enable mdc/mwc commands      */
include/configs/calimain.h:#define CONFIG_MX_CYCLIC
include/configs/legoev3.h:#define CONFIG_MX_CYCLIC
README:- CONFIG_MX_CYCLIC
scripts/config_whitelist.txt:CONFIG_MX_CYCLIC
$

  so it would appear that the *correct* spelling is "CONFIG_MX_CYCLIC"
as defined in the header file, which is what is being tested in the
source file cmd/mem.c.

  a more obvious example:

$ grep -r DM_MOD_EXP *
drivers/crypto/rsa_mod_exp/Kconfig:config DM_MOD_EXP
$

there is, however, "UCLASS_MOD_EXP"; perhaps that's what was meant:

$ grep -r UCLASS_MOD_EXP *
board/freescale/common/fsl_validate.c:	ret = uclass_get_device(UCLASS_MOD_EXP, 0, &mod_exp_dev);
drivers/crypto/fsl/fsl_rsa.c:	.id	= UCLASS_MOD_EXP,
drivers/crypto/rsa_mod_exp/mod_exp_sw.c:	.id	= UCLASS_MOD_EXP,
drivers/crypto/rsa_mod_exp/mod_exp_uclass.c:	.id		= UCLASS_MOD_EXP,
include/dm/uclass-id.h:	UCLASS_MOD_EXP,		/* RSA Mod Exp device */
lib/rsa/rsa-verify.c:	ret = uclass_get_device(UCLASS_MOD_EXP, 0, &mod_exp_dev);
$

  there appears to be quite a lot of stuff like this.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================



More information about the U-Boot mailing list