1 06/18/88 LINT
2
3 Name:
4
5 lint -- a C program checker
6
7
8 Synopsis:
9
10 lint -abhlnpuvx -DUI files
11
12
13 Description:
14
15 LINT attempts to detect features of the C program files that are
16 likely to be bugs, non-portable, or wasteful. It also checks type
17 usage more strictly than the compiler. Among the things that are
18 currently detected are unreachable statements, loops not entered at
19 the top, automatic variables declared and not used, and logical
20 expressions whose value is constant. Moreover, the usage of functions
21 is checked to find functions that return values in some places and not
22 in others, functions called with varying numbers or types of
23 arguments, and functions whose values are not used or whose values are
24 used but none returned.
25
26
27 Options:
28
29 Any number of LINT options may be used in any order, intermixed with
30 filename arguments. The following options are used to suppress
31 certain kinds of complaints.
32
33 -a Suppress complaints about assignments of long values to
34 variables that are not long.
35
36 -b Suppress complaints about "break" statements that cannot be
37 reached. Programs produced by lex or yacc will often result in
38 many such complaints.
39
40 -h Do not apply heuristic test that attempt to intuit bugs, improve
41 style, and reduce waste.
42
43
44 -u Suppress complaints about functions and external variables used
45 and not defined, or defined and not used. This option is
46 suitable for running LINT on a subset of files of a larger
47 program.
48
49 -v Suppress complaints about unused arguments in functions.
50
51 -x Do not report variables referred to by external declarations but
52 never used.
53
54
55 The following arguments alter LINT's behavior.
56
57 -lx Include additional lint library llib-lx.ln. For example, you can
58 include a lint version of the Math Library llib-lm.ln by
59 inserting -lm on the command line. This argument does not
60 suppress the default use of llib-lc.ln. This option can be used
61 to reference local lint libraries and is useful in the
62 development of multi-file projects.
63
64 -n Do not check compatibility against either the standard or the
65 portable lint library.
66
67
68 -p Attempt to check portability to other dialects IBM and GCOS
69 of C. Along with stricter checking, this option causes all non-
70 external names to be truncated to eight characters and all
71 external names to be truncated to six characters and one case.
72
73 -c Cause LINT to produce a .ln file for every .c file on the command
74 line. These .ln files are the product of LINT's first pass only,
75 and are not checked for inter-function compatibility.
76
77
78 -o lib Cause LINT to create a lint library with the name llib-llib.ln.
79 The -c option nullifies any use of the -o option. The lint
80 library produced is the input that is given to LINT's second
81 pass. The -o option simply causes this file to be saved in the
82 named lint library. To produce a llib-llib.ln without extraneous
83 messages, use of the -x option is suggested. The -v option is
84 useful if the source files for the lint library are just
85 external interfaces for example the way the file llib-lc is
86 written. These option settings are also available through the
87 use of "lint comments" see below.
88
89
90 The -D, -U, and -I options of C preprocessor cpp are also recognized
91 as separate arguments. Other options are warned about and ignored.
92 The pre-processor symbol "lint" is defined to allow certain
93 questionable code to be altered or removed for LINT. Therefore, the
94 symbol "lint" should be thought of as a reserved word for all code
95 that is planned to be checked by LINT.
96
97
98 Invoking Lint:
99
100 Arguments whose names end with .c are taken to be C source files.
101 Arguments whose names end with .ln are taken to be the result of an
102 earlier invocation of LINT with either the -c or the -o option used.
103
104 The .ln files are analogous to .cob object files that are produced
105 by the c_compile cc command when given a .c file as input. Files
106 with other suffixes are warned about and ignored.
107
108 LINT will take all the .c, .ln, and llib-lx.ln specified by -lx
109 files and process them in their command line order. By default, LINT
110 appends the standard C lint library llib-lc.ln to the end of the
111 list of files. However, if the -p option is used, the portable C lint
112 library llib-port.ln is appended instead. When the -c option is not
113 used, the second pass of LINT checks this list of files for mutual
114 compatibility. When the -c option is used, the .ln and the llib-lx.ln
115 files are ignored.
116
117
118 Source Comments:
119
120 Certain conventional comments in the C source will change the behavior
121 of LINT.
122
123 /*NOTREACHED*/
124 at appropriate points stops comments about unreachable
125 code. This comment is typically placed just after
126 calls to functions like exit .
127
128 /*VARARGSn*/
129 suppresses the usual checking for variable numbers of
130 arguments in the following function declaration. The
131 data types of the first n arguments are checked; a
132 missing n is taken to be 0.
133
134
135 /*ARGSUSED*/
136 turns on the -v options for the next function.
137
138 /*LINTLIBRARY*/
139 at the beginning of a file shuts off complaints about
140 unused functions and function arguments in this file.
141 This is equivalent to using the -v and -x options.
142
143
144 Diagnostics:
145
146 LINT produces its first output on a per-source-file basis. Complaints
147 regarding included files are collected and printed after all source
148 files have been processed. Finally, if the -c option is not used,
149 information gathered from all input files is collected and checked for
150 consistency. At this point, if it is not clear whether a complaint
151 stems from a given source file or from one of its included files, the
152 source file name will be printed followed by a question mark.
153
154
155 The behavior of the -c and -o options allows for incremental use of
156 LINT on a set of C source files. Generally, one invokes LINT once for
157 each source file with the -c option. Each of these invocations
158 produces a .ln file which corresponds to the .c file, and prints all
159 messages that are about just that source file. After all the source
160 files have been separately run through LINT, it is invoked once more
161 without the -c option, listing all the .ln files with the needed -lx
162 options. This will print all the inter-file inconsistencies. This
163 scheme works well with MAKE; it allows MAKE to be used to LINT only
164 the source files that have been modified since the last time the set
165 of source files were LINTed.
166