LINT
-
" "
/P 2.1
LINT
1988
-
lint. lint.
lint lint,
-,
. -
lint -
.
,
, .. ,
. lint -
, -
. lint -
.
lint -
, .
-
. , -
, . -
lint
,
.
lint, , -
- -
.
1.
,
file1.c, file2.c, -
.
lint file1.c file2.c
, -
. lint -
, - (
).
lint -p file1.c file2.c
, , ,
.
-p -h
- 3 -
, , , -
. -hp
.
, , -
-.
lint.
2.
, , -
lint, . , ,
-
, -
. , -
exit, " ",
.
, lint
.
, .
, lint -
, .
, .
lint
. " -
" ,
,
. ,
-
,
.
,
, lint.
3.
,
. ,
, -
.
"" .
,
:
, , -
!
- 4 -
lint -
, - . -
,
extern, ;
,
extern float sin();
, sin
. , -
. ,
-
; -x
lint.
,
-
, -
. -v -
-
.
, , -
, , -
; -
, -
.
,
, .
lint , ,
, -
. -
, , -
, .
-u.
4.
lint
-
. ;
, ,
. lint -
( ),
,
.
,
,
-
.
- 5 -
-
,
. , lint
, -
, -
(,
goto).
,
.
, ,
, .
, -
, .
,
.
5.
lint
. -
,
goto, break, continue, return.
, -
;
while(1)
for(;;). lint , -
; -
,
, -
.
, -
lint " ":
, ,
. ,
exit
, lint.
-
(. ).
, -
lint: -
break. , , yacc[2]
, , lex[3], -
break. -O -
-
. ,
,
. ..
- 6 -
lint.
, lint
-b.
6.
,
; "-
" , . lint
.
,
,
return();
return;
; lint
function name contains ruturn(e) and return" ("
name return() return").
, -
, -
. -
:
f(a){
if(a) return(3);
g
}
, a , f g
, -
; lint.
g, exit, , -
,
.
;
"" , -
lint.
lint ,
, ,
, ( ) . -
,
.
, -
(,
).
- 7 -
, -
, -
, . .
, -
"" ; ,
, .
lint
, .
:
, ,
,
.
,
.
, (?:) .
char, short, int, long, unsigned,float
double .
, , , -
. ,
->> ,
. ()
, -
.
.
-
.
float double , char,
short, int unsigned. , -
. -
,
.
,
-
;
=, ==, !=, -
.
7.
-
-
.
p=1;
p - . lint -
.
- 8 -
p = (char*) 1;
-
. , -
.
lint,
. ,
-
. -c -
. -c ,
,
,
.
8. , .
-1420
, -128 127.
. lint
. -
,
char c;
...
if ((c=getchar())<0)...
-1420, ,
.
,
getchar .
lint "nonportable
character comparison" (" -
"). ;
,
. , -
.
, ,
int, 3; -
,
unsigned.
9. int long
-
long int,
. -
, -
typedef. typedef -
int long, ,
- 9 -
-
int, .
,
long int, -
-a.
10.
lint -
, .
,
. -
-h. , *p++
* .
lint "null effect" ("
").
unsigned x ;
if (x<0) ...
,
. ,
if (x>0) ...
if (x!=0)
.
lint: "degenerate unsigned comparison"
(" unsigned").
if (1!=0)...
lint "constant in conditional con-
text" (" "), -
1 0 .
lint , -
. ,
- -
, -
, . -
,
if (x & 077 ==0) ...
x<<2 + 40
- 10 -
, . -
, lint
.
, -h lint
,
,
. -
, ,
, -
.
11.
, -
.
- .
(,
=+, =-, ...) ,
a=-i;
a =- 1;
a = -1;
,
-
. , -
(+=, -= ..), -
, . -
lint -
.
.
int x 1;
x 1. -
: ,
int x (-1);
:
int x (y) {....
- 11 -
x , ,
. ,
, ,
.
:
int x= -1;
- -
.
12.
-
, , -
. ,
-1420
" double", .. -
. Honeywell 6000
; ,
. lint
.
, -p -h,
"possible pointer alignment problem" ("
").
13.
-
-
. , ( -1420),
, -
, , .
-
. ,
, -
, .
,
, ,
.
, -
( ) . -
,
. , -
- ,
- 12 -
.
lint ,
. ,
a[i]=b[i++] ;
warning: i evaluation order undefined
(: i).
14.
lint
.
-[4,5]
IBM-370, IHoneywell 6000 Interdata
8/32. -
, -
.
, -
, -
, lint , -
ASCII.
, ,
(, -
, ..), ,
. ,
,
.
""
.
. ,
,
.
, ,
, -
.
- ,
,
lint.
15.
-
UNIX.
-
- 13 -
. -
,
lint.
- . ,
,
- (,
int a;).
a .
( ,
!),
. -
. lint
-c,
.
-
.
,
. -
, -
. ,
,
. -p
, "
".
:
-8,
. ,
(" ") ,
(" ") -1420. ,
,
,
, .
lint , -
, -
.
, -
. , ,
, , 16-
32-. ,
.
, -
-
.
-
. , -
,
- 14 -
x &= 0177700
x. -
-1420,
. -
:
x &= 077;
-
.
-1420 .
, -
. -
-1420,
. ""
PDP-11, -
.
,
,
. , lint .
,
,
.
,
,
.
-
.
,
, -
,
. ,
lint -
-
.
16.
, lint.
, "-
" ,
.. , ,
, lint, " ",
-
. ,
lint,
.
- 15 -
, ,
. , , ,
. ,
, -
.
, ,
, lint.
: -
, ,
. , lint
;
, lint
.
-
: - -
, lint ,
lint /* NOTREACHED */, -
. ,
,
/* NOSTRICT */
lint
( ) . -v
/* ARGUSED */
/* VARARGS */
.
,
.
VARARGS, ,
, ;
,
/* VARARGS2 */
. ,
/* LINTLIBRARY */
- 16 -
, ,
.
.
17.
lint -
, -ly, -
. -
, ()
. -
/* LINTLIBRARY */
. -
:
, -
,
. -
VARARGS
ARGUSED.
lint
, .
, , -
, , -
. lint
,
, -
(-!).
lint -
, -
,
. -p ,
/, , , -
.
-n.
18. ..
lint
,
, ,
,
,
. (, , lint -
, -
).
- 17 -
lint
. , -
,
. , -
typedef;
, -
- .
lint -.
-
,
, -
, -
, , -
..
, lint, -
. ,
.
.
, ,
.
, lint
,
. lint -
, ,
, . -
, "", lint
" ". , -
, -
,
lint -
.
. lint
lint :
lint [-] ... -...
:
h
p
- 18 -
v
u -
b break
x -
a long
int