PC-Lint使用报告 联系客服

发布时间 : 星期六 文章PC-Lint使用报告更新完毕开始阅读ceb32eedf9c75fbfc77da26925c52cc58bd690e2

1.安装PC-Lint

安装和PC-Lint在Keil中配置见《使用教程》

2.配置.lnt文件

Keil安装路径\\ARM\\BIN\\CO-RV.LNT添加: -w4 //生成所有信息

-os(D:\\result.txt) //输出结果到文件result.txt

3.PC-Lint代码检查功能

PC-Lint能够检查出很多语法错误和语法上正确的逻辑错误,PC-Lint为大部分错误消息都分配了一个错误号,编号小于1000的错误号是分配给C 语言的,编号大于1000的错误号则用来说明C++的错误消息,见表1 错误类型 语法错误 内部错误 致命错误 告警 消息 可选信息 C 1-199 200-299 300-399 400-699 700-899 900-999 C++ 1001-1199 1400-1699 1700-1899 1900-1999 表1

告警级别 1 0 0 2 3 4 以C语言为例:

编号1-199指的是一般编译器也会产生的语法错误;

编号200-299是PC-Lint程序内部的错误,这类错误不会出现在代码中的; 编号300-399指的是由于内存限制等导致的系统致命错误;

编号400-999中出现的提示信息,是根据隐藏代码问题的可能性进行分类的,指的是被检查代码中很可能存在问题而产生的告警信息;

编号700-899中出现的信息,产生错误的可能性相比告警信息来说级别要低,但仍然可能是因为代码问题导致的问题;

编号900-999是可选信息,他们不会被默认检查,除非你在选项中指定检查他们。

PC-Lint告警级别分为以下几个级别,缺省告警级别为3级: -w0 不产生信息(除了遇到致命的错误)

-w1 只生成错误信息 -- 没有告警信息和其它提示信息 -w2 只有错误和告警信息

-w3 生成错误、告警和其它提示信息(这是默认设置) -w4 生成所有信息

4.FCA温度校准程序

4.1FCA温度校准程序PC-Lint配置文件《CO-RV.LNT》

CO-RV.LNT

4.2FCA温度校准程序Lint输出结果《FCA_TempCalibration_result.txt》

FCA_TempCalibration_result.txt

4.3输出结果统计见表2、3、4,有6种语法、36种告警和41种消息错误

常见错误如,40:变量未声明;91:行字符数超过600;506:固定的布尔值;525:缩排格式错误;527:无法执行到的语句;534:忽略函数返回值;616:在switch语句中未使用break;715:变量未引用;722:语句结束符“;”用在for()或者while()后面;734:赋值过程中精度丢失; 错误类型 PC-Lint错误编码 计数 PC-Lint告警信息 10 14 语法错误 40 46 91 123 128 2 128 192 56 24 Expecting a function Symbol 'Symbol' previously defined (Location) Undeclared identifier '__promise' field type should be _Bool, unsigned int or signed int Line exceeds 600 characters (use +linebuf) Macro 'min' defined with arguments at line 表2

错误类型 PC-Lint错误编码 计数 401 427 438 442 451 453 502 506 508 514 522 524 525 526 527 529 告警 534 537 539 545 550 552 569 573 578 611 613 616 628 641 644 655 1 1 14 1 9 1 2 15 68 1 5 13 23 7 1 1 268 36 7 1 2 7 41 2 3 1 83 1 7 110 2 4 PC-Lint告警信息 symbol 'Symbol' not previously declared static at Location // comment terminates in \\ Last value assigned to variable 'Symbol' not used for clause irregularity: testing direction inconsistent with increment direction repeatedly included but does not have a standard include guard Function 'Symbol', previously designated pure, String 'Name' Expected unsigned type Constant value Boolean extern used with definition Unusual use of a Boolean Highest operator or function lacks side-effects Loss of precision (Context) (Type to Type) Negative indentation from Location 'Symbol' (Location) not defined Unreachable code at token Symbol Symbol 'Symbol' (Location) not subsequently referenced Ignoring return value of function 'Symbol' (compare with Location) Repeated include file 'FileName' Did not expect positive indentation from Location Suspicious use of & -- An attempt was made to take the address of an array name. Symbol 'Symbol' (Location) not accessed Symbol 'Symbol' (Location) not accessed Loss of information (Context) (Integer bits to Integer bits) Signed-unsigned mix with divide Declaration of symbol 'Symbol' hides symbol 'Symbol' (Location) Suspicious cast Possible use of null pointer 'Symbol' in [left/right] argument to operator 'String' Reference control flows into case/default no argument information provided for function 'Symbol' (Location) Converting enum to int Variable 'Symbol' (Location) may not have been initialized bit-wise operation uses (compatible) enum's 661 662 668 669 25 1 1 1 possible access of out-of-bounds pointer ('Integer' beyond end of data) by operator 'String' possible creation of out-of-bounds pointer ('Integer' beyond end of data) by operator 'String' Possibly passing a null pointer to function 'Symbol', Context Reference Possible data overrun for function 'Symbol', argument Integer exceeds argument Integer Reference 表3

错误类型 PC-Lint错误编码 计数 701 702 705 708 713 714 715 716 717 718 722 消息 725 730 732 734 736 737 740 744 746 747 750 752 754 33 1 1 1 21 24 13 12 12 12 56 3 3 8 20 7 4 14 4 7 15 14 2 6 PC-Lint告警信息 Shift left of signed quantity (int) Shift right of signed quantity (int) Argument no. Integer nominally inconsistent with format union initialization Loss of precision (Context) (Type to Type) Symbol 'Symbol' (Location) not referenced Symbol 'Symbol' (Location) not referenced while(1) ... do ... while(0) Symbol 'Symbol' undeclared, assumed to return int Suspicious use of ; Expected positive indentation from Location Boolean argument to function Loss of sign (Context) (Type to Type) Loss of precision (Context) (Integer bits to Integer bits) Loss of precision (Context) (Integer bits to Integer bits) Loss of sign in promotion from Type to Type Unusual pointer cast (incompatible indirect types) switch statement has no default call to function 'Name' not made in the presence of a prototype Significant prototype coercion (Context) Type to Type local macro 'Symbol' (Location) not referenced local declarator 'Symbol' (Location) not referenced local structure member 'Symbol' (Location) not referenced