views:

168

answers:

2

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?
+1  A: 

Funny. Currently I'm sitting in the office and trying to run a static checker on Linux Kernel drivers :)

Static checkers have a hard time processing linux kernel, because C dialect used in kernel code is broader than the one commonly understood as "C language". It sometimes happens that C front-end of a checker just can't parse ever-changing constructs used in the code.

As I could understand, you simply use an outdated version of the checker (03 Nov 2006), but your kernel version is outdated too, and I don't know which is older. What may help is updating the checker to its current version, or using up-to-date C front-end, if the checker supports switching it.

Moreover, if a checker can process Linux kernel, the fact outright becomes being bragged about on the checker's homepage. So, pick one that claims it and do your checks.

Pavel Shved
The Kernel and Splint are both shipped together as part of Ubuntu 8.04, so they should probably be "right" for each other I would think.
Robert S. Barnes
Take a look at the link I just found on using splint on kernel modules. http://www.cs.virginia.edu/pipermail/splint-discuss/2005-January/000531.html
Robert S. Barnes
@Robert S. Barnes , yeah, that link illustrates what I was talking about: lack of support of GCC's C dialect. Probably, that is a solution you were looking for.
Pavel Shved
A: 

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.

Robert S. Barnes