SourceInSight中进行pc_lint静态检查、输出检查报告

1、准备文件,这些文件在此总结输出的同级目录下:

1):co-gnu3.lnt

2):pingtai.lnt

3):project.lnt

4):/pclint_include目录(静态检查用到的标准库文件)

5):PC-Lint报告模版.xls

 

 把上述文件和目录放到统一一个目录下,如:

D:\project\project_doc\20110819_pclintcfg

其中,pingtai.lnt文件copy到sourceInSight的安装磁盘下的lint目录。默认安装的话,应该是C:\lint目录。

2、修改project.lnt文件,指向需静态检查的工程源文件(包含标准库文件)

D:\project\project_doc\20110819_pclintcfg目录下的project.lnt文件做如下修改:下文是此文件的结尾部分,其中红色部分为【要检视的工程源文件路径+标准库文件(/pclint_include)】的路径。

//*『说明』*****************工程头文件路径,注意:您的路径不同!

各个工程的头文件路径,根据需要修改。下面是一个例子,请根据实际情况修改。

 

-iD:\project\E6000_mm\201108_Integrity\IPMI\src\ipmi

-iD:\project\E6000_mm\201108_Integrity\IPMI\src\vos

//-iE:\work\代码检视\模块和Pclint\82xx\mtv_82xx\include

-iD:\project\project_doc\20110819_pclintcfg\pclint_include

-elib(*)

 

-w2

3、配置sourceInsight(在安装时已经配置了pc_lint检查的)

1)打开sourceInsight,打开待检工程;

2)在options菜单中打开custom Commands,如图:

3)在打开的Custom Commands窗口中,

(1)选择Command为“PC-LintICP--Ctrl+1”【没有的则自己手工添加Add一个】,

(2)修改run

cmd.exe /c SI_ICP.cmd LNT

 D:\project\project_doc\20110819_pclintcfg/project.lnt %f”,

其中,红色字体部分D:\project\project_doc\20110819_pclintcfg/project.lnt,project.lnt文件的路径。

(3)pattern修改为“^Error\s\([\\\sa-zA-Z:].*\)\s\([0-9]+\).*”。

具体内容如下图:

此时选择run按钮,即开始静态检查。

4、静态检查结果及处理步骤

1)输出静态检查结果的统计文件【有输出模板PC-Lint报告模版.xls,在本输出报告的同级目录】

先修改D:\project\project_doc\20110819_pclintcfg/project.lnt文件中的format参数为如下红色字体部分:

// 2006-05-19 Add by FanRong

-"format=%(%F(%l):%) error %n: (%t -- %m)"  //平台标准的PC-Lint执行结果输出格式

//-"format=Error %(%F %l: %)%t %n %m"

 

 


 

再执行上述3步骤中的run。此时的静态检查输出结果为标准格式的文本,将这些内容手工copy.txt文件,如《pc_lint20110819.txt》。

打开《PC-Lint报告模版.xls,点击上方的“导入Pc_lint检查结果”按钮,如下图:

选择导入《pc_lint20110819.txt》文件【如提示宏命令未打开,则在此文件的左上角点击激活】。

这样即可生成本轮pc_lint静态检查的问题记录,后续执行相应的静态检查时,可根据此文件的记录,最终生成本轮静态检查报告《PC-Lint报告20110819.xls》。如下图:

2)执行静态检查结果的调整

为方便链接到静态检查结果的对应文件记录行,此时要再修改一次

D:\project\project_doc\20110819_pclintcfg/project.lnt文件中的format参数为如下红色字体部分:(上一个步骤是为了方便输出检查报告,这一个步骤是为了方便在工程中链接修改)

// 2006-05-19 Add by FanRong

//-"format=%(%F(%l):%) error %n: (%t -- %m)"  //平台标准的PC-Lint执行结果输出格式

-"format=Error %(%F %l: %)%t %n %m"

 

  再执行上述 3 步骤中的 run 。此时的静态检查输出结果为各条带链接的记录,如下图:

可以看到每条记录前面都有链接按钮,点击即可跳转到相应的代码行去做修改操作了。

修改后,要同步记录《PC-Lint报告20110819.xls》文件,最终输出此报告,完成本轮pc_lint静态检查。

5、其他内容请参考本输出报告同级目录下的/pclint目录。

 

附:

co-gnu3.lnt


//    co-gnu3.lnt
//    Compiler Options for GCC versions 2.95.3 and later

//    This file contains options to allow FlexeLint to process source
//    files for the Gnu compiler (GCC).
//
//    flint  co-gnu.lnt  source-file(s)
//
//    If you are using GCC on some other system you will need to change
//    the following options:

-cgnu       // Notifies FlexeLint that gcc is being used.

// Begin: System Dependent Options
// -------------------------------

-d__i386__  // a define of this type is machine-dependent
            // modify if you are running on non-intel hardware.
-d__linux__ // Linux define!
//-d__mc68000__  //a machine dependent define

-di386=1         // needed for some Unix's
-a#machine(i386) //  #assert's machine(i386)  (SVR4 facility).

// What follows is the trickiest thing about a gcc installation, i.e.,
// one or more -i options to tell FlexeLint where the header files
// are coming from.

-i/usr/include   // This is pretty standard throughout the Unix world

-i/FlexeLint/supp/ansi  // This we humbly offer as a collection of ...
            // ANSI (i.e ISO) header files.  Replace the word "FlexeLint"
            // with the name of the directory in which FlexeLint has
            // been installed.  Note, you might want to replace "ansi"
            // with "posix".

-i/usr/lib/gcc-lib/i486-linux/2.5.8/include // This is only offered as
            // an example.  It will clearly change with the version
            // of GCC.

-si4    // int's are typically 4 bytes
-sp4    // ptr's are typically 4 bytes          

// -----------------------------
// End: System Dependent Options

+cpp(.cc,.C)  // extensions for C++ that are commonly used in addition
            // to the default extensions of .cpp and .cxx

            // while processing library headers
-wlib(1)    // sets the warning level within library headers to 1
     // (no warnings, just syntax errors).  Comment out if you
     // are actually linting library headers.  This
     // option makes obsolete options of the form -elib(axxx) where
     // xxx >= 400 which may be retained for historical reasons.
-elib(15)   // redeclaration of symbol
-elib(516)  // lots of redeclarations in Linux stdlib.h
-elib(652)  // suppress message about #define of earlier declared symbols
-elib(762)  // suppress message about multiple identical declarations and
-elib(760)  // suppress message about multiple identical macro defs
-elib(553)  // undefined preprocessor variables are taken as 0
-elib(410)  // unusual size_t
-elib(767)  // differently defined macro
-elib(624)  // typedef symbol redeclared
-elib(607)  // parameter substitution within string
-elib(602)  // in dial.h there are comments within comments ?
-elib(537)  // repeated include files
-elib(2)    // unclosed quotes in nserve.h
-elib(123)  // size is both a variable and a macro with args
-elib(1014) // class member definition within extern "C++"

-emacro(734,putc)   // don't complain about items being too large.
-emacro((???),va_arg)   // the va_arg() macro can yield 415, 416, 661, 662
   // 796 and 797 (out-of-bounds errors).
-emacro(413,offsetof)  // use of NULL pointer creates a stir
-emacro(545,offsetof)  // addressing an array member is OK

-elib(793)   // Linux has minor ANSI violation in stddef.h
-elib(569)   // Linux truncates some data in huge_val.h
-esym(528,__huge_val,__nan,__qnan,__qnanf,__snan,__snanf)
           // We don't care if we don't reference some GNU funcs
-esym(528,__gnu_malloc,__gnu_calloc)


//  The following options were found necessary when processing
//  the Unix headers within /usr/include

//+fdi            // Use the directory of the including file

+ppw(ident)     // Tolerate #ident
+rw(__inline)   // enable the (non-standard) __inline keyword
+rw(__inline__)   // enable the (non-standard) __inline__ keyword

//  The following functions exhibit variable return modes.
//  That is, they may equally-usefully be called for a value
//  as called just for their effects.  Accordingly we inhibit
//  Warning 534 for these functions.
//  Feel free to add to or subtract from this list.

-esym(534,close,creat,fclose,fprintf,fputc,closedir)
-esym(534,fputs,fscanf,fseek,fwrite,lseek,memcpy,memmove,memset)
-esym(534,printf,puts,scanf,sprintf,sscanf,strcat,strcpy)
-esym(534,strncat,strncpy,unlink,write)

// For non-ANSI compilers we suppress messages 515 and 516
// for functions known to have variable argument lists.
// For ANSI compilers, header files should take care of this.

-esym(515,fprintf,printf,sprintf,fscanf,scanf,sscanf)
-esym(516,fprintf,printf,sprintf,fscanf,scanf,sscanf)

// The following options are required by most compilers to
// noiselessly process iostream.h

-elib(1717) //empty prototypes
-elib(522) //function return value ignored
-elib(1053) //prototypes cannot be distinguished
-elib(1721) //unusual operator =() declaration
-elib(1720) //assignment op has non-const parameter
-elib(655)  // bitwise operator combining compatible enum's
-elib(641)  // converting enum's to int
-elib(537)  // repeated include file (ios.h)
-elib(1511) // member (rdbuf) hides nonvirtual member
-elib(1712) // default constructor not defined for class
-esym(1702,operator<<,operator>>)

// These functions return things that are frequently ignored.

-esym(534,ostream::operator<<,istream::operator>>)

-elib(747) //significant prototype coercion
-elib(740) //unusual pointer casts
-elib(1029) //default argument repeated -- can't dist. char, signed char
-elib(1055) //call to rdbuf() questioned?
-elib(1708,1709) // minor C/C++ declaration conflict

-elib(763)   // redundant declaration
-elib(1510)  // base class has no destructor
-elib(1516)  // data member hiding inherited member
-elib(1730)  // class/struct inconsistancy
-elib(569)   // loss of information 8-bits - 7bits

// What follows here is a collection of options we have found
// to be needed to support Version 3 of GCC.  The need for these
// options actually predate Version 3 and are of the 2.9... time frame

-e93         // allow newlines within quoted string arguments to macros
-dasm()=     // support inline assembly code by ignoring asm(...)
-d__attribute__()=   // ignore this keyword and following parenthetical
-d__extension__=            // ignore this keyword
-d__builtin_va_list=void*   // used by stdarg.h
-d__builtin_stdarg_start()=_to_semi  // ditto
-d__builtin_va_end()=_to_semi        // ditto
+rw(_to_semi)               // needed for the two macros above.
-d__const=const             // gconv.h uses __const rather than const
-d__STDC_VERSION__=199901L  // required by C99
-d__FUNCTION__="somefunction"
-d__PRETTY_FUNCTION__="somefunction"
+fwc                    // wchar_t is builtin
-d_WCHAR_T              // tell the header files as much
-elib(148)              // Some of the libraries are redefining member
                        // functions
-elib(1073)             // reverse_iterator<> is being invoked with
                        // an insufficient number of parameters.
+rw(__typeof__)         // activate __typeof__ keyword
-d__typeof=__typeof__   // an alternative to using __typeof__

================================================================

pingtai.lnt


// 中央平台质量部制定的标准选项文件
// 本文件只能由专门人员进行修改,任何其他人不得修改
//
//  2005-11-4 create by lidongqin. 

-e46          //编译器支持BIT域定义的数据结构,可以使用非int型定义
-e537         //头文件被多次包含是不可避免的,这个问题是可以由在书写头文件时,做到防止重复包含来解决。
              //而且,即使头文件没有做到防止重入,此告警被屏蔽,还是会用其他告警产生:如宏定义重复定义等,这些编译器都会告警的。
-e641         //允许屏蔽
-e715         //参数没使用时出现,有时是为了跟已有的函数原型匹配,但并不使用其中的部分参数,如定时器,这个没有必要消除
-e717         //一般可供多个函数公用,但又不宜组织成函数的一段代码最好是组织成宏函数,但是为了不致引用错误,可以定义成do{…}while(0)这样的形式
-e788         //在switch语句中,如果变量是一个枚举的类型,这个告警要求每个枚举都有一个case分支,但程序设计时,
              //经常会使用default缺省处理,不需要每个都列一遍


/*C++特有的*/
-e1701        //重复的访问限定符(public, prtected, private).屏蔽,向导经常产生重复的限定符.  (确认一下此项告警的真正含义)
-e1702        //在C++模式中非常常见,一些operator操作符作为全局和成员函数同时定义(用新pclint版本确认一下两个类都有同样的操作符是否也会告警)
-e1704        //在C++模式中非常常见,构造函数为私有,这是为了独体类实现需要
-e1711        //使用的第三方代码中存在这种用法] 类中有虚函数但是该类未被继承。类不被继承则虚函数没有优点反而带来开销。
-e1717        //空的函数原型如void f();空的参数对于C与C++的意义是不同的。可声明为(void).屏蔽,在VC中这是习惯写法. 
-e1736        //类中多余的访问限定符。显式的操作限定符不是必需的,因为较早的操作限定符将会起作用。屏蔽,向导经常产生重复的限定符 yes

 

=====================================================================================

project.lnt

// 中央平台质量部制定的标准选项文件
// 本文件只能由专门人员进行修改,任何其他人不得修改
//
//  2005-11-4 create by lidongqin. 
co-gnu3.lnt
pingtai.lnt

-e46          //编译器支持BIT域定义的数据结构,可以使用非int型定义
-e537         //头文件被多次包含是不可避免的,这个问题是可以由在书写头文件时,做到防止重复包含来解决。
              //而且,即使头文件没有做到防止重入,此告警被屏蔽,还是会用其他告警产生:如宏定义重复定义等,这些编译器都会告警的。
-e641         //允许屏蔽
-e715         //参数没使用时出现,有时是为了跟已有的函数原型匹配,但并不使用其中的部分参数,如定时器,这个没有必要消除
-e717         //一般可供多个函数公用,但又不宜组织成函数的一段代码最好是组织成宏函数,但是为了不致引用错误,可以定义成do{…}while(0)这样的形式
-e788         //在switch语句中,如果变量是一个枚举的类型,这个告警要求每个枚举都有一个case分支,但程序设计时,
              //经常会使用default缺省处理,不需要每个都列一遍


/*C++特有的*/
-e1701        //重复的访问限定符(public, prtected, private).屏蔽,向导经常产生重复的限定符.  (确认一下此项告警的真正含义)
-e1702        //在C++模式中非常常见,一些operator操作符作为全局和成员函数同时定义(用新pclint版本确认一下两个类都有同样的操作符是否也会告警)
-e1704        //在C++模式中非常常见,构造函数为私有,这是为了独体类实现需要
-e1711        //使用的第三方代码中存在这种用法] 类中有虚函数但是该类未被继承。类不被继承则虚函数没有优点反而带来开销。
-e1717        //空的函数原型如void f();空的参数对于C与C++的意义是不同的。可声明为(void).屏蔽,在VC中这是习惯写法. 
-e1736        //类中多余的访问限定符。显式的操作限定符不是必需的,因为较早的操作限定符将会起作用。屏蔽,向导经常产生重复的限定符 yes


// 2006-05-19 Add by FanRong
//-"format=%(%F(%l):%) error %n: (%t -- %m)"   //平台标准的PC-Lint执行结果输出格式
-"format=Error %(%F %l: %)%t %n %m"

//中硬定义的告警屏蔽文件,不需要的请用双斜杠注释掉--2010.11.5 modified by wangjing
-e818  // 函数指针必须声明为const类型,否则会出现此警告
-e155  //对于gcc编译器,默认把花括号中的内容{..}当作0,从而引起其他告警,因此去除。
-e160  //支持({...})格式的代码段

//BSP特定的汇编宏定义统一使用的头文件
+libh(asmPpcInc.h)

//BSP特定的汇编宏定义
-emacro( {522}, EIEIO, EIEIO_SYNC, END_RCV_RTN_CALL )
-emacro( {746}, EIEIO )
-emacro( {1055}, EIEIO )
-emacro( {572}, BYTE_SWAP16 )
-emacro( {572}, BYTE_SWAP32 )
-emacro( (572), LONGSWAP )

-wlib(1)  //只显示库函数中的句法错误
-esym(*,_*) //PCLINT不识别__asm__预插入宏等内联指令而产生的告警*/

//DSP软件常用,添加编译器或者在工程文件中需要的宏和关键字
-DCHIP_DSP=1   //算法所需要定义的芯片类型;
--rw(__SIZE_T_TYPE__)
+rw(__SIZE_T_TYPE__)
--rw(cregister) //增加cregister关键字
+rw(cregister)

-width(0)   // don't break lines
-hFmn1      // always supply a File but no macro
-dVOS_OS_VER=VOS_LINUX

//*『说明』*****************工程头文件路径,注意:您的路径不同!
各个工程的头文件路径,根据需要修改。下面是一个例子,请根据实际情况修改。

-iD:\project\E6000_mm\201108_Integrity\IPMI\src\ipmi
-iD:\project\E6000_mm\201108_Integrity\IPMI\src\vos
//-iE:\work\代码检视\模块和Pclint\82xx\mtv_82xx\include
-iD:\project\project_doc\20110819_pclintcfg\pclint_include
-elib(*)

-w2

 

 

你可能感兴趣的:(SourceInSight中进行pc_lint静态检查、输出检查报告)