1.登陆splint官网下载原码http://www.splint.org/download.html
这里要注意:由于机器是mips所以选择上面的原码自行编译
2.tar -xzf splint-3.1.2.src.tgz
sudo ./configure –prefix=/usr/local/splint
sudo make
sudo make install
3.修改配置文件
#vi ~/.bashrc
最后一行加上:
LARCH_PATH=/usr/local/splint/share/splint/lib
LCLIMPORTDIR=/usr/splint/share/splint/imports
#source ~/.bashrc
# exprot PATH=/usr/local/splint/bin/splint:$PATH
4.验证
#vi null.c
输入:
//null.c
char firstChar1 (/*@null@*/ char *s)
{
return *s;
}
char firstChar2 (/*@null@*/ char *s)
{
if (s ==NULL) return '\0'; return *s;
}
//END
用splint扫面:#splint null.c
Splint 3.1.1 --- 28 Apr 2005
null.c: (in function firstChar1)
null.c:3:11: Dereference of possibly null pointer s: *s null.c:1:35: Storage s may become null Finished checking --- 1 code warning found
由于firstChar1和firstChar2都使用了null说明,表示指针s可能是个NULL值.
所以,splint会对s值的使用情况进行检查.因为firstChar2函数中,对s的值进行
了NULL的判断.所以,没有对firstChar2函数的指针s输出警告信息.