SourceForge Logo Smatch Logo

Using Smatch!!!

Using Smatch is a two part process. The first step is to compile your source with the modified gcc. This will generate .c.sm files. The second step is to run the checker scripts against the .c.sm files

Step 1a)
Edit your /usr/src/linux/Makefile. Comment out the original CC line and add the new gcc. The --smatch option means that the new gcc should generate .c.sm files. Notice also the -B flag.

 
AS              = $(CROSS_COMPILE)as
LD              = $(CROSS_COMPILE)ld
#CC              = $(CROSS_COMPILE)gcc
CC              = $(CROSS_COMPILE)/home/carp0110/progs/gcc/build/gcc/xgcc \
                        -B/home/carp0110/progs/gcc/build/gcc/ --smatch 
CPP             = $(CC) -E
AR              = $(CROSS_COMPILE)ar
NM              = $(CROSS_COMPILE)nm

Step 1b)
Compile the kernel: make clean allyesconfig bzImage modules

Step 2)
After the .c.sm files are generated then you can run the checker scripts on the .c.sm files.

cat foo.c.sm | ./script.pl
Or you can do it all at once:
for i in *.c.sm ; do
        echo $i
        cat $i | ./script.pl >> errs
done

Click here to go to the scripts page.