Commit | Line | Data |
---|---|---|
61212793 C |
1 | LINT(1) UNIX Reference Manual LINT(1) |
2 | ||
3 | N\bNA\bAM\bME\bE | |
4 | l\bli\bin\bnt\bt - a C program verifier | |
5 | ||
6 | S\bSY\bYN\bNO\bOP\bPS\bSI\bIS\bS | |
7 | l\bli\bin\bnt\bt [-\b-a\bab\bbc\bch\bhn\bnp\bpu\buv\bvx\bx] _\bf_\bi_\bl_\be ... | |
8 | ||
9 | D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN | |
10 | L\bLi\bin\bnt\bt attempts to detect features of the C program _\bf_\bi_\bl_\be_\bs which are likely | |
11 | to be bugs, or non-portable, or wasteful. It also checks the type usage | |
12 | of the program more strictly than the compilers. Among the things which | |
13 | are currently found are unreachable statements, loops not entered at the | |
14 | top, automatic variables declared and not used, and logical expressions | |
15 | whose value is constant. Moreover, the usage of functions is checked to | |
16 | find functions which return values in some places and not in others, | |
17 | functions called with varying numbers of arguments, and functions whose | |
18 | values are not used. | |
19 | ||
20 | By default, it is assumed that all the _\bf_\bi_\bl_\be_\bs are to be loaded together; | |
21 | they are checked for mutual compatibility. Function definitions for cer- | |
22 | tain libraries are available to l\bli\bin\bnt\bt; these libraries are referred to by | |
23 | a conventional name, such as `-lm', in the style of ld(1). Arguments | |
24 | ending in ._\bl_\bn are also treated as library files. To create lint li- | |
25 | braries, use the -\b-C\bC option: | |
26 | ||
27 | lint -Cfoo files . . . | |
28 | ||
29 | where _\bf_\bi_\bl_\be_\bs are the C sources of library _\bf_\bo_\bo. The result is a file | |
30 | _\bl_\bl_\bi_\bb-_\bl_\bf_\bo_\bo ._\bl_\bn in the correct library format suitable for linting programs | |
31 | using _\bf_\bo_\bo. | |
32 | ||
33 | Any number of the options in the following list may be used. The -\b-D\bD -\b-U\bU | |
34 | and -\b-I\bI options of cc(1) are also recognized as separate arguments. | |
35 | ||
36 | -\b-p\bp Attempt to check portability to the _\bI_\bB_\bM and _\bG_\bC_\bO_\bS dialects of C. | |
37 | ||
38 | -\b-h\bh Apply a number of heuristic tests to attempt to intuit bugs, | |
39 | improve style, and reduce waste. | |
40 | ||
41 | -\b-b\bb Report _\bb_\br_\be_\ba_\bk statements that cannot be reached. (This is not | |
42 | the default because, unfortunately, most lex(1) and many | |
43 | yacc(1) outputs produce dozens of such comments.) | |
44 | ||
45 | -\b-v\bv Suppress complaints about unused arguments in functions. | |
46 | ||
47 | -\b-x\bx Report variables referred to by extern declarations, but never | |
48 | used. | |
49 | ||
50 | -\b-a\ba Report assignments of long values to int variables. | |
51 | ||
52 | -\b-c\bc Complain about casts which have questionable portability. | |
53 | ||
54 | -\b-u\bu Do not complain about functions and variables used and not de- | |
55 | fined, or defined and not used (this is suitable for running | |
56 | l\bli\bin\bnt\bt on a subset of files out of a larger program). | |
57 | ||
58 | -\b-n\bn Do not check compatibility against the standard library. | |
59 | ||
60 | -\b-z\bz Do not complain about structures that are never defined (e.g. | |
61 | using a structure pointer without knowing its contents.). | |
62 | ||
63 | Exit(2) and other functions which do not return are not understood; this | |
64 | causes various lies. | |
65 | ||
66 | ||
67 | Certain conventional comments in the C source will change the behavior of | |
68 | l\bli\bin\bnt\bt: | |
69 | ||
70 | /*NOTREACHED*/ | |
71 | at appropriate points stops comments about unreachable code. | |
72 | ||
73 | /*VARARGS n */ | |
74 | suppresses the usual checking for variable numbers of arguments in | |
75 | the following function declaration. The data types of the first _\bn | |
76 | arguments are checked; a missing _\bn is taken to be 0. | |
77 | ||
78 | /*NOSTRICT*/ | |
79 | shuts off strict type checking in the next expression. | |
80 | ||
81 | /*ARGSUSED*/ | |
82 | turns on the -\b-v\bv option for the next function. | |
83 | ||
84 | /*LINTLIBRARY*/ | |
85 | at the beginning of a file shuts off complaints about unused func- | |
86 | tions in this file. | |
87 | ||
88 | A\bAU\bUT\bTH\bHO\bOR\bR | |
89 | S.C. Johnson. Lint library construction implemented by Edward Wang. | |
90 | ||
91 | F\bFI\bIL\bLE\bES\bS | |
92 | /_\bu_\bs_\br/_\bl_\bi_\bb_\bd_\ba_\bt_\ba/_\bl_\bi_\bn_\bt/_\bl_\bl_\bi_\bb-_\bl_\bc._\bl_\bn declarations for standard functions | |
93 | /_\bu_\bs_\br/_\bl_\bi_\bb_\bd_\ba_\bt_\ba/_\bl_\bi_\bn_\bt/_\bl_\bl_\bi_\bb-_\bl_\bc human readable version of above | |
94 | /_\bu_\bs_\br/_\bl_\bi_\bb/_\bl_\bi_\bn_\bt_\bd_\ba_\bt_\ba/_\bl_\bl_\bi_\bb-_\bp_\bo_\br_\bt._\bl_\bn declarations for portable functions | |
95 | /_\bu_\bs_\br/_\bl_\bi_\bb/_\bl_\bi_\bn_\bt_\bd_\ba_\bt_\ba/_\bl_\bl_\bi_\bb-_\bp_\bo_\br_\bt human readable . . . | |
96 | _\bl_\bl_\bi_\bb-_\bl*._\bl_\bn library created with -\b-C\bC | |
97 | ||
98 | ||
99 | S\bSE\bEE\bE A\bAL\bLS\bSO\bO | |
100 | cc(1) | |
101 | S. C. Johnson, _\bL_\bi_\bn_\bt, a C Program Checker | |
102 | ||
103 | H\bHI\bIS\bST\bTO\bOR\bRY\bY | |
104 | L\bLi\bin\bnt\bt appeared in Version 7 AT&T Unix. | |
105 | ||
106 | B\bBU\bUG\bGS\bS | |
107 | There are some things you just can't get lint to shut up about. | |
108 | ||
109 | /*NOSTRICT*/ is not implemented in the current version (alas). |