PC-Lint使用报告 联系客服

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

760 762 765 766 774 785 818 825 826 830 831 834 835 838 843 844 845 3 4 126 11 1 13 60 1 7 1227 221 8 87 17 117 2 11 Redundant macro 'Symbol' defined identically at Location Redundantly declared symbol 'Symbol' previously declared at Location external 'Symbol' (Location) could be made static Header file FileName not used in module String Boolean within 'String' always evaluates to [True/False] Too few initializers for aggregate 'Symbol' Pointer parameter 'Symbol' (Location) could be declared ptr to const control flows into case/default without -fallthrough comment Suspicious pointer-to-pointer conversion (area too small) Location cited in prior message Reference cited in prior message Operator 'Name' followed by operator 'Name' is confusing. Use parentheses. A zero has been given as [left/right] argument to operator 'Name' Previously assigned value to variable 'Symbol' has not been used Variable 'Symbol' (Location) could be declared as const Pointer variable 'Symbol' (Location) could be declared as pointing to const The [left/right] argument to operator 'Name' is certain to be 0 表4

5.舵机程序

5.1舵机程序PC-Lint配置文件《co-iar80.lnt》

co-iar80.lnt

5.2舵机程序Lint输出结果《STM8_SERVO_result.txt》

STM8_SERVO_result.txt

5.3输出结果见表5、6、7,有16种语法、10种告警和23种消息错误

错误类型 PC-Lint错误编码 计数 7 10 14 18 19 31 36 语法错误 40 49 63 101 102 129 132 161 309 7 126 16 14 23 15 1 55 44 13 21 100 154 6 5 14 PC-Lint告警信息 Unable to open include file Expecting 'String' Symbol 'Symbol' previously defined (Location) Symbol 'Symbol' redeclared (TypeDiff) conflicts with Location Useless Declaration Redefinition of symbol 'Symbol' conflicts with Location Redefining the storage class of symbol 'Symbol' conflicts with Location Undeclared identifier 'Name' Expected a type Expected an lvalue Expected an identifier Illegal parameter specification declaration expected, identifier 'Symbol' ignored Expected function definition Repeated use of parameter 'Symbol' in parameter list #error ... 表5

错误类型 PC-Lint错误编码 计数 506 526 告警 533 552 578 1 4 15 2 16 PC-Lint告警信息 Constant value Boolean 'Symbol' (Location) not defined function 'Symbol' should (not) return a value (see Location) Symbol 'Symbol' (Location) not accessed Declaration of symbol 'Symbol' hides symbol 'Symbol' (Location) 601 628 641 647 679 1 4 18 1 8 Expected a type for symbol Symbol, int assumed no argument information provided for function 'Symbol' (Location) Converting enum to int Suspicious truncation Suspicious Truncation in arithmetic expression combining with pointer 表6

错误类型 PC-Lint错误编码 计数 704 714 715 716 718 725 732 734 745 746 747 消息 750 765 766 772 774 776 783 818 830 831 832 843 3 3 18 3 4 1 2 2 15 5 1 2 5 1 2 1 1 3 1 118 1 16 1 PC-Lint告警信息 Shift right of signed quantity (long) Symbol 'Symbol' (Location) not referenced Symbol 'Symbol' (Location) not referenced while(1) ... Symbol 'Symbol' undeclared, assumed to return int Expected positive indentation from Location Loss of sign (Context) (Type to Type) Loss of precision (Context) (Integer bits to Integer bits) function 'Name' has no explicit type or class, int assumed 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 external 'Symbol' (Location) could be made static Header file FileName not used in module String Symbol 'Symbol' (Location) conceivably not initialized Boolean within 'String' always evaluates to [True/False] Possible truncation of addition Line does not end with new-line Pointer parameter 'Symbol' (Location) could be declared ptr to const Location cited in prior message Reference cited in prior message Parameter 'Symbol' not explicitly declared, int assumed Variable 'Symbol' (Location) could be declared as const 表7

6.对比分析

6.1语法错误对比

对比表2和表5,错误类型10、14和40在两个程序都有出现。由于测试机上缺少必要的头文件导致舵机程序出现更多的语法错误。

6.2告警错误对比

对比表3和表6,错误类型506、526、552、578、628和641在两个程序都有出现。其中错误类型641:枚举类型转为整型在两个程序均出现多次。

6.3消息错误对比

对比表4和表7,错误类型714、715、716、718、725、732、734、746、747、750、765、766、774、818、830、831和843在两个程序都有出现。其中错误类型830:地址引用在之前的信息中,在两个程序中出现次数均是最多的。通过提高告警级别至-w3或者-w2都不能禁止此错误信息,必须在配置文件中明确设置-e830来禁止。

7.常见问题

7.1不能打开头文件,一种解决方案是添加头文件包含路径到图1所示位置

图1

7.2错误信息太多,通过设置告警级别和禁止输出特定类型错误信息(-e#)解决