Professional Documents
Culture Documents
PCLint
PC-Lint
PC-Lint
PC-Lint
1
2 PC-Lint
3 PC-Lint
3.1
3.2
3.3
3.4
3.5
3.6
3.7 const
3.8 volatile
4 PC-Lint
4.1
4.2 PC-Lint Visual C++,Source Insight,UEdit)
5
PC-Lint
PC-Lint
C/C++
C/C++
C/C++
C/C++
LoGIScope RuleChecker PC-Lint
Logiscope RuleChecker
case
PC-Lint
PC-Lint PC-Lint
Visual C++Source Insight PCLint
PC-Lint
PC-Lint GIMPEL SOFTWARE C/C++
PC-Lint/FlexeLint for C/C++PC-Lint WindowsMSDOS OS/2 FlexeLint
PC-lint
PC-Lint PC-Lint
PC-Lint
1
2char *report( int m, int n, char *p )
3{
4 int result;
5 char *temp;
6 long nm;
7 int i, k, kk;
8 char name[11] = "Joe Jakeson";
9
10 nm = n * m;
11 temp = p == "" ? "null" : p;
12 for( i = 0; i<m; I++ ) {
14 k++;
15 kk = i;
16 }
17
18 if( k== 1 ) result = nm;
19 else if( kk > 0 ) result = 1;
20 else if( kk < 0 ) result = -1;
21
22 if( m == result ) return( temp );
23 else return( name );
24}
C C PC-Lint
8 name
nul 10 long int
11 14
k 15 kk 22 result
23
C++C/C++
BUG C++ Pascal
PC-Lint
PC- Lint
PC-Lint
PC-Lint PC-Lint
1000 C
1000 C++ 1 PCLint
1 PC-Lint
C++
1-199
1001-1199
200-299
300-399
400-699
1400-1699
700-800
1700-1899
900-999
1900-1999
C 1-199
200-299 PC-Lint
300-399 400-999
400699 700-899
900-999
PC-Lint/FelexLint wLevel 3
-w0
-w1 --
-w2
-w3
-w4
PC-Lint/FelexLint wlib(Level) C/C++wLevel 3
-wlib(0)
-wlib(1)
-wlib(2)
-wlib(3)
-wlib(4)
PC-Lint
const volatile
PC-Lint PC-Lint
PC-Lint 300
C++
lint /*//
-esym(534,
printf, scanf, operator new) operator new
operator new PC-Lint
3.1
-strong-index
typedef
strong
-strong( flags[, name] ... )
strong typedef PC-Lint
2 strong
A
A A
i
r Return
p
a
c
z Zero Zero
0 0L (int)0 Zero
(HANDLE)0 HANDLE
Zero(HANDLE *)0 strong(Ai,BITS)PC-Lint BITS
BITS
i, r, p, a, c, z X
J
e ==!=?:
r >>=<<=
o +-*/%|&^
c
z Zero
Meters
B
1. Boolean
Type Boolean
true false
&&||
2. Bolean if
while
Bolean
Type B b
B b 1bit
Boolean 1bit
Boolean
A J
B b f B b
-strong type
-strong
//lint -strong(Ab,Bool) <>
typedef int Bool;
Bool gt(int a, b)
{
if(a) return a > b; // OK
else return 0; // Warning
}
Bool b return
return
0 Bool c -strong(Acb,Bool)
Boolean Boolean
x.b = 2; // OK
x.c = x.a; // OK
118
x.e = 1; // strong type violation
x.e = x.d; // OK
}
a c Bool d e BitField b
Boolean
Boolean -strong f strong(AJXbf,Bool)
indexindex
-index( flags, ixtype, sitype [, sitype] ... )
strong strong
ixtype Strongly Indexed sitype
ixtype sitype typedef
flags c dc ixtype d
ixtype Dimensions
index
//lint -strong( AzJX, Count, Temperature )
//lint -index( d, Count, Temperature )
// Only Count can index a Temperature
typedef float Temperature;
typedef int Count;
Temperature t[100]; // OK because of d flag
Temperature *pt = t; // pointers are also checked
// ... within a function
Count i;
t[0] = t[1]; // Warnings, no c flag
for( i = 0; i < 100; i++ )
t[i] = 0.0; // OK, i is a Count
119
pt[1] = 2.0; // Warning
i = pt - t; // OK, pt-t is a Count
Temperature Count
d
Temperature t[ (Count) 100 ];
i = pt - t;
3.2
3.2.1
if( a ) b = 6;
else c = b; // 530 message
a = c;
// 645 message
b c PC-Lint b c
c a while
for if
while ( n-- )
{
b = 6;
...
}
c = b; //772 message
b b
c
if
if if
While if
switch ( k )
{
case 1: b = 2; break;
case 2: b = 3;
/* Fall Through */
case 3: a = 4; break;
default: error();
}
c = b; //645 message
b b
b c
switch b PC-Lint
PC-Lint
b case
error() PCLint
switch ( k )
{
case 1: b = 2; break;
case 2:
case 3: b = 3; a = 4; break;
default: error();
/*lint -unreachable */
}
c = b;
-unreachable error()break
free
if( n ) free( p );
...
p->value = 3;
p p goto
goto goto
if ( a ) goto label;
b = 0;
label: c = b;
if( x ) initialize y
...
if( x ) use y
y esym(644,y) y
3.2.2
(1) 415661796
(2) 0 54414795
(3) NULL 413613794
(4) 416662797
(5) 774
int a[10];
int f()
{
int k;
k = 10;
return a[k]; // Warning 415
}
415 '[' PC-Lint
k k
int a[10];
int f( int n )
{
int k;
if ( n ) k = 10;
else k = 0;
return a[k]; // Warning 661
}
661 ()
10 kPC-Lint
int a[10];
int f( int k, int n )
{
if ( k >= 10 ) a[0] = n;
return a[k]; // Warning 661 -- k could be 10
}
661 PC-Lint k k
>=10 K
int a[10];
int f( int k, int n )
{ return a[k+n]; } // no warning
k 796 (
).
int a[10];
int f(int n, int k)
{
int m = 2;
ANSI C([1]3.3.6)
int a[10];
f( a + 10 ); // OK
f( a + 11 ); // error
if ( n > 0 ) n = 0;
else if ( n <= 0 ) n = -1; // Info 774
774
3.2.3 assert
PC-Lint
assert
char buf[4];
char *p;
strcpy( buf, "a" );
p = buf + strlen( buf ); // p is 'possibly' (buf+3)
p++; // p is 'possibly' (buf+4)
*p = 'a'; // Warning 661 - possible out-of-bounds reference
PC-Lint
assert() assert.h
assert
assert.h PC-lint -i
3.2.4
PC-Lint
t1.cpp:
1 int f(int);
2 int g()
3 { return f(0); }
4 int f( int n )
5 { return 10 / n; }
f() 0
10/n 0 lin -u t1.cpp
--- Module: t1.cpp
During Specific Walk:
File t1.cpp line 3: f(0)
t1.cpp 5 Warning 414: Possible division by 0 [Reference:File t1.cpp:
line 3]
During Specific Walk
t2.cpp:
1 int f( int n )
2 { return 10 / n; }
3 int g()
4 { return f(0); }
0 f(0) f()
multi-pass
lin -u -passes(2) t2.cpp
--- Module: t2.cpp
/// Start of Pass 2 ///
--- Module: t2.cpp
During Specific Walk:
File t2.cpp line 4: f(0)
t2.cpp 2 Warning 414: Possible division by 0 [Reference:File t2.cpp:
line 4]
-passes(2)
-passes(2)-passes=2 -passes[2]
pass 2
t3.cpp:
1 int f( int n )
2 { return n - 1; }
3 int g( int n )
4 { return n / f(1); }
lin -u -passes(2) t3.cpp
--- Module: t3.cpp
/// Start of Pass 2 ///
--- Module: t3.cpp
{ return n / f(1); }
t3.cpp 4 Warning 414: Possible division by 0 [Reference:File t3.cpp:
lines 2, 4]
f() 1
f() 0
g() 0 During
Specific Walk g()
g()
pass
t4.cpp:
1 int f(int);
2 int g( int n )
3 { return f(2); }
4 int f( int n )
5 { return n / f(n - 1); }
f(n-1) f(2) f(1)
f(0) 0
lin -u -passes(3) t4.cpp
564 C/C++
n++ + n
+
a[i] = i++;
f( i++, n + i );
&&||? :
(,)
if( (n = f()) && n > 10 ) ...
3.4
typedef
PC-Lint
PC-Lint 749-769 1749-1769
if( ... )
if( ... )
statement
else statement
else if
if PC-Lint
725(no positive indentation)525(negatively indented
from)539Did not expect positive indentation from Location
tab
8 -t# -t4 tab 4
3.7 const
const PC-Lint const
volatile PC-Lint
volatile 564
PC-Lint
4.1
PC-lint
PC-lint
lint-nt u std.lnt test1.c test2.c test3.c
MAKEFILE
Source Insight/SLICKEDIT/MS VC6.0/KEIL C..PC-Lint
Scott Meyes Effective C++/More Effective C++
4.1
pc-lint.exe 4.2
4.2 pc-lint.exe
STD.LNT
4.3 STD.LNT
Create a new STD.LNT
STD.LNT
STD_x.LNT x az26
aSTD_x.LNT STD.LNT
4.3 PC-Lint
4.4
4.5
STD.LNT STD_x.LNT
32 Windows32-bit Flat Model
4.6
PC-Lint
STD.LNT STD_x.LNT
ATLMFCSTL
4.7
C/C++
AUxxx.LNT
4.8
-i
-i STD.LNT STD_x.LNT
-i
-iE:\Program Files\Microsoft Visual
C++\VC98\Indlue-i
4.9
;
ctrl+Enter Brows
4.10 std_x.lnt
Create a new STD.LNT
std_x.lntstd.lnt std_a.lnt
std.lnt
4.11
4.12 std.lnt
std_x.lnt std.lnt
std_x.lnt std.lnt
4.13 OPTIONS.LNT
OPTIONS.LNT
OPTIONS.LNT -e
OPTIONS.LNT
No
4.14
PC-Lint
VCBCSource Insight
Microsift Visual C++ 6.0 env-v6.lnt
4.15 LIN.BAT
LIN.BAT PC-Lint
LIN.BAT PATH
LSET.BAT PC-LINT
LSET.BAT AUTOEXEC.BAT
PC-Lint copy
LIN.BAT to one of my PATH directory PATH
4.16 PATH
C:\PCLint8 PATH
4.17
PC-Lint PC-Lint
*.lnt
std.lntstd_x.lnt option.lnt co-xxx.lntlibxxx.lntenv-xxx.lnt
PCLint lnt lnt
PC-lint
*.lnt
4.2 PC-Lint
PC-Lint
4.2.1
PC-lint
PC-lint PC-lint
file
*.lnt
4.18 .Lnt
4.19
VC PC-Lint
Win32 Console ApplicationHello
World
stdafx.h
std_g.lnt std_g.lnt,
-iC:\unzipped\test
C:\unzipped\test stdafx.h
PC-Lint
4.20
4.2.3 PC-Lint source insight
PC-Lint source insight
OptionsCustom CommandsAdd
4.21 Custom Commands
Name PC-lint Check Current File
E:\code
UltraEdit
4.22 UltraEdit
UltraEdit PC-lint Check Current File
PC-lint
PC-lint
PC-Lint
PC-lint
PC-lint
Msg.txt
options.lnt
env-xx.lnt PC-lint xx si
Source Insight xx vc6 Visual C++
6.0
co-xxx.lnt
std.lnt
lib-xxx.lnt C/C++MFC OWL
au-xxx.LNT C++
-e#
-e(#)
all);
!e#
printf(its all);
-esym(#, Symbol)
printf)*/
/*lint -e725 */
/*lint e(534) */
printf(its
/*lint !e534*/
/*lint esym(534,
printf(its
all);
-elib(#)
r01.h
-efunc(#, <func>)
mchRelAll)*/
/*lint elib(129) */
#include
/*lint efunc(534,
unsigned int
mchRelAll(mchHoData
*pHoData)
{
printf(its
all);
}
PC-Lint
40
506 Boolean
char c=3;
if(c<300){}
525
527 if(a > B)
return TRUE;
else
return FALSE;
return FALSE;
529
530
534
539
545 &
char arr[100], *p;
p=&arr;
603
void print_str(const char *p);
char *sz;
print_str(sz);
605
void write_str(char *lpsz);
write_str(string);
613
616 switch break;
650 if( ch == 0xFF ) ...
713
715
725 Indentation
734 int a, b, c;
c=a*b;
737 /
/
744 switch default
752
762
774 Boolean / char c;
if(c < 300)
@ 2006 07 24 23:33:00|(9
)|
: C/C++ SMC | :
PC-Lint( )
/************************/
#include <stdio.h>
void p(int i)
{
printf( "%d\n", i);
}
int main(int argc, char** argv)
{
int a = 1;
p(a);
return 0;
}
/*******************************/
dos :
C:\lint>lint-nt -u std.lnt c:\a.c
PC-lint for C/C++ (NT) Ver. 8.00e, Copyright Gimpel Software
1985-2001
options.lnt(8) : Error 90: Option '-e(970)' is only appropriate
within a lint
comment
_
}
c:\a.c(11) : Info 715: Symbol 'argv' (line 6) not referenced
c:\a.c(6) : Info 830: Location cited in prior message
_
}
c:\a.c(11) : Info 818: Pointer parameter 'argv' (line 6) could be
declared as
pointing to const
c:\a.c(6) : Info 830: Location cited in prior message
_
}
c:\a.c(11) : Info 715: Symbol 'argc' (line 6) not referenced
c:\a.c(6) : Info 830: Location cited in prior message
C:\lint>
warnning, info, 829,970 ,
#orbit 2007-08-13 19:15:26 IP: 222.71.114.*
option option
typedef
typedef unsigned int UINT;
UINT unsigned int
#sdhzzzzcd 2007-08-21 18:02:45 IP: 124.207.98.*
PC LINT8.0 Check Current File
VS2005
PC-lint for C/C++ (NT) Vers. 8.00w, Copyright Gimpel Software
1985-2007
--- Global Wrap-up
error 900: (Note -- Successful completion, 0 messages
produced)
#sdhzzzzcd 2007-08-21 18:05:11 IP: 124.207.98.*
PC LINT8.0 Check Project
PC-lint for C/C++ (NT) Vers. 8.00w, Copyright Gimpel Software
1985-2007
error 305: (Error -- Unable to open module 'Test.lnt>Test.chk')