public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [kconfig] results of some syntactical checks
@ 2013-07-16 22:34 Martin Walch
  2013-07-16 23:18 ` Paul Bolle
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Walch @ 2013-07-16 22:34 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 4100 bytes --]

As I am working on yet another project for analyzing LKC's input files, I have 
some intermediate results from simple syntactical checks.

The results below are an excerpt from a run against tche current master. If 
anyone is interested in the code (it's written in Java), please contact me. I 
plan on releasing my program under a FLOSS license later this year. If you find 
the results interesting or even useful, I can post updates on a regular basis.

Actually defined symbols with dangerous names: 2
  8260 at
    arch/powerpc/platforms/82xx/Kconfig:55:0
  8272 at
    arch/powerpc/platforms/82xx/Kconfig:64:0

Symbols used, but not defined: 31
  Symbol: ARCH_EFM32 at
    drivers/tty/serial/Kconfig:1427:0
  Symbol: ARCH_MULTI_V4 at
    arch/arm/Kconfig:914:0
  Symbol: ARM_S3C24XX at
    arch/arm/mach-s3c24xx/Kconfig:210:0
  Symbol: ATHEROS_AR231X at
    drivers/net/wireless/ath/ath5k/Kconfig:2:0
    drivers/net/wireless/ath/ath5k/Kconfig:8:0
    drivers/net/wireless/ath/ath5k/Kconfig:9:0
    drivers/net/wireless/ath/ath5k/Kconfig:56:0
    drivers/net/wireless/ath/ath5k/Kconfig:63:0
  Symbol: CPU_MMP3 at
    drivers/video/mmp/Kconfig:2:0
    drivers/video/mmp/hw/Kconfig:4:0
    drivers/usb/phy/Kconfig:53:0
  Symbol: CPU_PXA988 at
    drivers/video/mmp/Kconfig:2:0
    drivers/video/mmp/hw/Kconfig:4:0
  Symbol: CPU_SUBTYPE_SH7764 at
    arch/sh/drivers/dma/Kconfig:14:0
  Symbol: DEPRECATED at
    arch/mn10300/Kconfig.debug:34:0
  Symbol: EXYNOS_DEV_SYSMMU at
    drivers/iommu/Kconfig:170:0
  Symbol: GENERIC_HAS_IOMAP at
    arch/score/Kconfig:27:0
    arch/score/Kconfig:33:0
    arch/score/Kconfig:39:0
  Symbol: GENERIC_TIME at
    arch/arm/mach-bcm/Kconfig:11:0
  Symbol: GPIO_BCM at
    arch/arm/mach-bcm/Kconfig:12:0
  Symbol: HAVE_SCHED_CLOCK at
    arch/arm/mach-keystone/Kconfig:10:0
  Symbol: HOTPLUG at
    arch/powerpc/platforms/pseries/Kconfig:22:0
  Symbol: M at
    drivers/usb/host/Kconfig:568:0
    drivers/usb/misc/Kconfig:130:0
  Symbol: MACH_NOKIA_RM696 at
    arch/arm/mach-omap2/Kconfig:314:0
  Symbol: MACH_OMAP_H4_OTG at
    drivers/usb/gadget/Kconfig:208:0
  Symbol: MACH_SMDKC210 at
    sound/soc/samsung/Kconfig:138:0
  Symbol: MACH_SMDKV310 at
    sound/soc/samsung/Kconfig:138:0
  Symbol: MN10300_PROC_MN2WS0038 at
    arch/mn10300/Kconfig:185:0
  Symbol: MPILIB_EXTRA at
    crypto/asymmetric_keys/Kconfig:24:0
  Symbol: MTD_JEDEC at
    drivers/mtd/maps/Kconfig:161:0
    drivers/mtd/maps/Kconfig:170:0
  Symbol: MV64360 at
    arch/powerpc/Kconfig:400:0
  Symbol: N at
    drivers/usb/core/Kconfig:12:0
    drivers/usb/host/Kconfig:336:0
    drivers/usb/host/Kconfig:348:0
    drivers/staging/usbip/Kconfig:3:0
    drivers/staging/usbip/Kconfig:20:0
    drivers/staging/usbip/Kconfig:31:0
    drivers/staging/usbip/Kconfig:42:0
    drivers/staging/asus_oled/Kconfig:3:0
    drivers/staging/rtl8187se/Kconfig:8:0
    drivers/staging/rtl8192u/Kconfig:7:0
    drivers/staging/rtl8192e/rtl8192e/Kconfig:7:0
    drivers/staging/rtl8712/Kconfig:6:0
    drivers/staging/rtl8712/Kconfig:14:0
    drivers/staging/frontier/Kconfig:3:0
    drivers/staging/bcm/Kconfig:3:0
    drivers/staging/media/go7007/Kconfig:15:0
    drivers/staging/media/go7007/Kconfig:26:0
    drivers/staging/media/go7007/Kconfig:48:0
    drivers/staging/android/Kconfig:4:0
    drivers/staging/android/Kconfig:61:0
    arch/cris/arch-v32/drivers/Kconfig:13:0
    arch/cris/arch-v32/drivers/Kconfig:413:0
    arch/arc/Kconfig:357:0
  Symbol: OF_VIDEOMODE at
    drivers/staging/imx-drm/Kconfig:36:0
  Symbol: OMAP_PM_SRF at
    drivers/staging/tidspbridge/Kconfig:19:0
  Symbol: PICOXCELL_PC3X3 at
    drivers/char/hw_random/Kconfig:242:0
  Symbol: PLATFORM_MICROBLAZE_AUTO at
    arch/microblaze/platform/Kconfig.platform:10:0
  Symbol: PLAT_SPEAR_SINGLE at
    arch/arm/mach-spear/Kconfig:6:0
    arch/arm/mach-spear/Kconfig:19:0
    arch/arm/mach-spear/Kconfig:51:0
    arch/arm/mach-spear/Kconfig:84:0
    arch/arm/mach-spear/Kconfig:99:0
  Symbol: SOC_DRA7XX at
    drivers/thermal/ti-soc-thermal/Kconfig:52:0
  Symbol: false at
    drivers/staging/lustre/lustre/Kconfig:45:0
-- 

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [kconfig] results of some syntactical checks
  2013-07-16 22:34 [kconfig] results of some syntactical checks Martin Walch
@ 2013-07-16 23:18 ` Paul Bolle
  2013-07-17  6:30   ` Paul Bolle
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Bolle @ 2013-07-16 23:18 UTC (permalink / raw)
  To: Martin Walch; +Cc: linux-kernel

On Wed, 2013-07-17 at 00:34 +0200, Martin Walch wrote:
> As I am working on yet another project for analyzing LKC's input files, I have 
> some intermediate results from simple syntactical checks.

Naive question: LKC?

> The results below are an excerpt from a run against tche current master.

One thing I noticed is that it is practical to be able to parse
arbitrary tags (commits) in the git tree. So you can quickly parse a
tree you don't actually have checked out in git. But perhaps your
checker also does that.

> If 
> anyone is interested in the code (it's written in Java), please contact me. I 
> plan on releasing my program under a FLOSS license later this year. If you find 
> the results interesting or even useful, I can post updates on a regular basis.
> 
> Actually defined symbols with dangerous names: 2
>   8260 at
>     arch/powerpc/platforms/82xx/Kconfig:55:0
>   8272 at
>     arch/powerpc/platforms/82xx/Kconfig:64:0

I've wondered for some time what happens when one uses either of these
numbers as the value for an "int" Kconfig symbol. I've never tried.

> Symbols used, but not defined: 31
>   Symbol: ARCH_EFM32 at
>     drivers/tty/serial/Kconfig:1427:0
>   Symbol: ARCH_MULTI_V4 at
>     arch/arm/Kconfig:914:0
>   Symbol: ARM_S3C24XX at
>     arch/arm/mach-s3c24xx/Kconfig:210:0
>   Symbol: ATHEROS_AR231X at
>     drivers/net/wireless/ath/ath5k/Kconfig:2:0
>     drivers/net/wireless/ath/ath5k/Kconfig:8:0
>     drivers/net/wireless/ath/ath5k/Kconfig:9:0
>     drivers/net/wireless/ath/ath5k/Kconfig:56:0
>     drivers/net/wireless/ath/ath5k/Kconfig:63:0
>   Symbol: CPU_MMP3 at
>     drivers/video/mmp/Kconfig:2:0
>     drivers/video/mmp/hw/Kconfig:4:0
>     drivers/usb/phy/Kconfig:53:0
>   Symbol: CPU_PXA988 at
>     drivers/video/mmp/Kconfig:2:0
>     drivers/video/mmp/hw/Kconfig:4:0
>   Symbol: CPU_SUBTYPE_SH7764 at
>     arch/sh/drivers/dma/Kconfig:14:0
>   Symbol: DEPRECATED at
>     arch/mn10300/Kconfig.debug:34:0
>   Symbol: EXYNOS_DEV_SYSMMU at
>     drivers/iommu/Kconfig:170:0
>   Symbol: GENERIC_HAS_IOMAP at
>     arch/score/Kconfig:27:0
>     arch/score/Kconfig:33:0
>     arch/score/Kconfig:39:0
>   Symbol: GENERIC_TIME at
>     arch/arm/mach-bcm/Kconfig:11:0
>   Symbol: GPIO_BCM at
>     arch/arm/mach-bcm/Kconfig:12:0
>   Symbol: HAVE_SCHED_CLOCK at
>     arch/arm/mach-keystone/Kconfig:10:0
>   Symbol: HOTPLUG at
>     arch/powerpc/platforms/pseries/Kconfig:22:0
>   Symbol: M at
>     drivers/usb/host/Kconfig:568:0
>     drivers/usb/misc/Kconfig:130:0

This looks odd. I think your checker doesn't like an uppercase M after
default. There are exactly two of those in the tree.

>   Symbol: MACH_NOKIA_RM696 at
>     arch/arm/mach-omap2/Kconfig:314:0
>   Symbol: MACH_OMAP_H4_OTG at
>     drivers/usb/gadget/Kconfig:208:0
>   Symbol: MACH_SMDKC210 at
>     sound/soc/samsung/Kconfig:138:0
>   Symbol: MACH_SMDKV310 at
>     sound/soc/samsung/Kconfig:138:0
>   Symbol: MN10300_PROC_MN2WS0038 at
>     arch/mn10300/Kconfig:185:0
>   Symbol: MPILIB_EXTRA at
>     crypto/asymmetric_keys/Kconfig:24:0
>   Symbol: MTD_JEDEC at
>     drivers/mtd/maps/Kconfig:161:0
>     drivers/mtd/maps/Kconfig:170:0
>   Symbol: MV64360 at
>     arch/powerpc/Kconfig:400:0
>   Symbol: N at
>     drivers/usb/core/Kconfig:12:0
>     drivers/usb/host/Kconfig:336:0
>     drivers/usb/host/Kconfig:348:0
>     drivers/staging/usbip/Kconfig:3:0
>     drivers/staging/usbip/Kconfig:20:0
>     drivers/staging/usbip/Kconfig:31:0
>     drivers/staging/usbip/Kconfig:42:0
>     drivers/staging/asus_oled/Kconfig:3:0
>     drivers/staging/rtl8187se/Kconfig:8:0
>     drivers/staging/rtl8192u/Kconfig:7:0
>     drivers/staging/rtl8192e/rtl8192e/Kconfig:7:0
>     drivers/staging/rtl8712/Kconfig:6:0
>     drivers/staging/rtl8712/Kconfig:14:0
>     drivers/staging/frontier/Kconfig:3:0
>     drivers/staging/bcm/Kconfig:3:0
>     drivers/staging/media/go7007/Kconfig:15:0
>     drivers/staging/media/go7007/Kconfig:26:0
>     drivers/staging/media/go7007/Kconfig:48:0
>     drivers/staging/android/Kconfig:4:0
>     drivers/staging/android/Kconfig:61:0
>     arch/cris/arch-v32/drivers/Kconfig:13:0
>     arch/cris/arch-v32/drivers/Kconfig:413:0
>     arch/arc/Kconfig:357:0

Ditto (but I haven't actually counted the occurrences of "default N").

>   Symbol: OF_VIDEOMODE at
>     drivers/staging/imx-drm/Kconfig:36:0
>   Symbol: OMAP_PM_SRF at
>     drivers/staging/tidspbridge/Kconfig:19:0
>   Symbol: PICOXCELL_PC3X3 at
>     drivers/char/hw_random/Kconfig:242:0
>   Symbol: PLATFORM_MICROBLAZE_AUTO at
>     arch/microblaze/platform/Kconfig.platform:10:0

This is a default of a "choice". There used to be quite a lot of invalid
"choice" defaults, so I stopped checking those. (But I didn't bother to
look how my local script now handles these.) In practice these are
treated as "no default", aren't they? 

>   Symbol: PLAT_SPEAR_SINGLE at
>     arch/arm/mach-spear/Kconfig:6:0
>     arch/arm/mach-spear/Kconfig:19:0
>     arch/arm/mach-spear/Kconfig:51:0
>     arch/arm/mach-spear/Kconfig:84:0
>     arch/arm/mach-spear/Kconfig:99:0
>   Symbol: SOC_DRA7XX at
>     drivers/thermal/ti-soc-thermal/Kconfig:52:0
>   Symbol: false at
>     drivers/staging/lustre/lustre/Kconfig:45:0

My script currently finds 28 undefined symbols. That equals this result
(given you have 2 false positive and 1 undefined choice default.)


Paul Bolle


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [kconfig] results of some syntactical checks
  2013-07-16 23:18 ` Paul Bolle
@ 2013-07-17  6:30   ` Paul Bolle
  2013-07-17 13:07     ` Martin Walch
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Bolle @ 2013-07-17  6:30 UTC (permalink / raw)
  To: Martin Walch; +Cc: linux-kernel

On Wed, 2013-07-17 at 01:18 +0200, Paul Bolle wrote:
> On Wed, 2013-07-17 at 00:34 +0200, Martin Walch wrote:
> >   Symbol: M at
> >     drivers/usb/host/Kconfig:568:0
> >     drivers/usb/misc/Kconfig:130:0
> 
> This looks odd. I think your checker doesn't like an uppercase M after
> default. There are exactly two of those in the tree.

After posting this I actually looked into this and even tested it a bit.
It turns out an uppercase 'M' isn't a valid alias for the magic 'm'
value. Your checker is right about warning for this.

> >   Symbol: N at
> >     drivers/usb/core/Kconfig:12:0
> >     drivers/usb/host/Kconfig:336:0
> >     drivers/usb/host/Kconfig:348:0
> >     drivers/staging/usbip/Kconfig:3:0
> >     drivers/staging/usbip/Kconfig:20:0
> >     drivers/staging/usbip/Kconfig:31:0
> >     drivers/staging/usbip/Kconfig:42:0
> >     drivers/staging/asus_oled/Kconfig:3:0
> >     drivers/staging/rtl8187se/Kconfig:8:0
> >     drivers/staging/rtl8192u/Kconfig:7:0
> >     drivers/staging/rtl8192e/rtl8192e/Kconfig:7:0
> >     drivers/staging/rtl8712/Kconfig:6:0
> >     drivers/staging/rtl8712/Kconfig:14:0
> >     drivers/staging/frontier/Kconfig:3:0
> >     drivers/staging/bcm/Kconfig:3:0
> >     drivers/staging/media/go7007/Kconfig:15:0
> >     drivers/staging/media/go7007/Kconfig:26:0
> >     drivers/staging/media/go7007/Kconfig:48:0
> >     drivers/staging/android/Kconfig:4:0
> >     drivers/staging/android/Kconfig:61:0
> >     arch/cris/arch-v32/drivers/Kconfig:13:0
> >     arch/cris/arch-v32/drivers/Kconfig:413:0
> >     arch/arc/Kconfig:357:0
> 
> Ditto (but I haven't actually counted the occurrences of "default N").

Lowercase 'n' is the correct magic value. But using uppercase 'N'
doesn't matter. Since there's no Kconfig symbol "N", both evaluate to
"not set" and you'll end up with the same .config file.

> My script currently finds 28 undefined symbols. That equals this result
> (given you have 2 false positive and 1 undefined choice default.)

So those 2 were actually correct positives.


Paul Bolle


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [kconfig] results of some syntactical checks
  2013-07-17  6:30   ` Paul Bolle
@ 2013-07-17 13:07     ` Martin Walch
  2013-07-18 12:17       ` Paul Bolle
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Walch @ 2013-07-17 13:07 UTC (permalink / raw)
  To: Paul Bolle; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2825 bytes --]

On Wednesday 17 July 2013 01:18:00 Paul Bolle wrote:
> On Wed, 2013-07-17 at 00:34 +0200, Martin Walch wrote:
> > As I am working on yet another project for analyzing LKC's input files, I
> > have some intermediate results from simple syntactical checks.
> 
> Naive question: LKC?

Sorry, I thought the abbreviation of the kconfig system "LinuxKernelConf" was 
common.

> > The results below are an excerpt from a run against tche current master.
> 
> One thing I noticed is that it is practical to be able to parse
> arbitrary tags (commits) in the git tree. So you can quickly parse a
> tree you don't actually have checked out in git. But perhaps your
> checker also does that.

Actually no, it does not. So far, a tree has to be checked out and a branch 
has to be manually selected.

> > Actually defined symbols with dangerous names: 2
> > 
> >   8260 at
> >   
> >     arch/powerpc/platforms/82xx/Kconfig:55:0
> >   
> >   8272 at
> >   
> >     arch/powerpc/platforms/82xx/Kconfig:64:0
> 
> I've wondered for some time what happens when one uses either of these
> numbers as the value for an "int" Kconfig symbol. I've never tried.

I would not expect anything bad to happen when the user manually assigns a 
value like 8260. However, it can break a range value like this:

config FOO
        int "FOO"
        range 8260 8272

On ARCH=powerpc, this will effectively make LKC print a warning "range is 
invalid" and pin down the value of FOO to 0.

Similar problems occur with default values:

config FOO
        int "FOO" if n
        default 8260

This will raise a warning "'FOO': number is invalid" and default FOO to 0.

No warning will show up if the symbol with the integer name would be actually 
an int:

config 4711
        int "4711"

config FOO
        int "FOO" if n
        default 4711

In this case, FOO will be set to whatever 4711 is set to.

All this can be avoided by quoting values, i. e.

	range "8260" "8272"

and

        default "4711"

Also, avoiding integers (and hex values) as symbol names looks like a 
reasonable idea.

> >   Symbol: PLATFORM_MICROBLAZE_AUTO at
> >   
> >     arch/microblaze/platform/Kconfig.platform:10:0
> 
> This is a default of a "choice". There used to be quite a lot of invalid
> "choice" defaults, so I stopped checking those. (But I didn't bother to
> look how my local script now handles these.) In practice these are
> treated as "no default", aren't they?

As far as I can tell, yes. Such a default line will be basically just ignored.


On Wednesday 17 July 2013 08:30:58 Paul Bolle wrote:
> > My script currently finds 28 undefined symbols. That equals this result
> > (given you have 2 false positive and 1 undefined choice default.)
> 
> So those 2 were actually correct positives.

I am glad that our results match. So they are presumably correct.
-- 

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [kconfig] results of some syntactical checks
  2013-07-17 13:07     ` Martin Walch
@ 2013-07-18 12:17       ` Paul Bolle
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Bolle @ 2013-07-18 12:17 UTC (permalink / raw)
  To: Martin Walch; +Cc: linux-kernel

On Wed, 2013-07-17 at 15:07 +0200, Martin Walch wrote:
> All this can be avoided by quoting values, i. e.
> 
> 	range "8260" "8272"
> 
> and
> 
>         default "4711"

Documentation/kbuild/kconfig-language.txt even states
    Constant symbols are always surrounded by single or double quotes.

But apparently the parser doesn't care. All "range" digits are unquoted,
and most "default" digits are unquoted.

> Also, avoiding integers (and hex values) as symbol names looks like a 
> reasonable idea.

I was actually surprised that these were allowed, and only discovered
that when my local script generated a few false positives. But, anyhow,
in practice those symbol names seem to work just fine.


Paul Bolle


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-18 12:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-16 22:34 [kconfig] results of some syntactical checks Martin Walch
2013-07-16 23:18 ` Paul Bolle
2013-07-17  6:30   ` Paul Bolle
2013-07-17 13:07     ` Martin Walch
2013-07-18 12:17       ` Paul Bolle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox