Search code examples
linuxmodulekernelsplintinsmod

Is there a way to get Splint or a similar static checker to work with Linux Kernel modules?


I compiled ( no warnings ) the hello-5.c example from "The Linux Kernel Module Programming Guide" and when I tried to insmod it, I received the following error:

insmod: error inserting 'hello-5.ko': -1 Unknown symbol in module

I thought I would try splint to see if it came up with any obvious errors, but when I ran it I got a slew of warnings from the kernel headers until it barfed trying to parse asm/types.h

anon@anon:~/kernel-source/lkmpg$ splint -I/lib/modules/$(uname -r)/build/include hello-5.c
Splint 3.1.1 --- 03 Nov 2006

( ... lots of warnings ... )

/lib/modules/2.6.24-24-insp8600/build/include/asm/types.h:13:24: Parse Error:
    Suspect missing struct or union keyword: __signed__ :
    unsigned short int. (For help on parse errors, see splint -help
    parseerrors.)
*** Cannot continue.

So really there are two questions:

  1. How do I fix the insmod error?
  2. How do I get splint to play nice with the kernel headers?

Solution

  • I'm not sure but this might be what I'm looking for:

    splint-discuss Using Splint on Linux kernel modules

    It provides a custom make file to help splint get through the gcc specific extensions used in the Kernel.