lint runs the C preprocessor as its first phase, with the following preprocessor symbols defined to allow certain questionable code to be altered or skipped: __LINT__, lint, __lint, __lint__. These symbols should therefore be thought of as reserved words for all code that is to be checked by .
Among the possible problems that are currently noted are unreachable statements, loops not entered at the top, variables declared and not used, and logical expressions with constant values. Function calls are checked for inconsistencies, such as calls to functions that return values in some places and not in others, functions called with varying numbers of arguments, function calls that pass arguments of a type other than the type the function expects to receive, functions whose values are not used, and calls to functions not returning values that use the non-existent return value of the function.
Filename arguments ending with
.c
are taken to be C source files.
Filename arguments with names ending with
.ln
are taken to be the result of an earlier invocation of
,
with either the
-i,
-o
or
-C
option in effect.
The
.ln
files are analogous to the
.o
(object) files produced by
cc(1)
from
.c
files.
lint
also accepts special libraries specified with the
-l
option, which contain definitions of library routines and
variables.
lint
takes all the
.c
, .ln
,
and
llib-l
library.ln
(lint library) files and processes them in command-line order.
By default,
lint
appends the standard C lint library
(llib-lc.ln
)
to the end of the list of files.
When the
-i
option is used, the
.ln
files are ignored.
Also, when the
-o
or
-i
options are used, the
llib-l
library.ln
files are ignored.
When the
-i
option is
omitted
the second pass of
lint
checks this list of files for mutual compatibility.
At this point, if a complaint stems not from a given source file,
but from one of its included files, the source filename will be
printed followed by a question mark.
The special input file name
``-
''
causes
lint
to take input from standard input (until end of file) and process
it as if it were a
.c
file.
If the
-i
flag is given and
``-
''
is named as one of the input files, the
-o
flag must also be specified to provide an output file name.
Options
.ln
file for every
.c
file on the command line.
These
.ln
files are the product of
Ns's
first pass only, and are not checked for compatibility
between functions.
__STRICT_ANSI__
is a predefined preprocessor macro.
__STDC__
is not predefined in this mode.
Warnings are printed for constructs not allowed in traditional C.
Warnings for constructs which behave differently in traditional C
and ANSI C are suppressed.
Preprocessor macros describing the machine type (e.g.
sun3
)
and machine architecture (e.g.
m68k
)
are defined without leading and trailing underscores.
The keywords
const,
volatile
and
signed
are not available in traditional C mode (although the alternative
keywords with leading underscores still are).
/usr/libexec
.
llib-l
library
.ln
.
This library is built from all
.c
and
.ln
input files.
After all global definitions of functions and
variables in these files are written to the newly created library,
lint
checks all input files, including libraries specified with the
-l
option, for mutual compatibility.
#define
directive.
If no definition is given,
name
is defined as 1.
llib-l
library
.ln
.
/lint
before searching the standard place.
llib-l
library
.ln
without extraneous messages, use of the
-u
option is suggested.
The
-v
option is useful if the source file(s) for the lint library
are just external interfaces.
Input Grammar
Ns's first pass reads standard C source files. lint recognizes the following C comments as commands.
/*
ARGSUSED
n
*/
/*
BITFIELDTYPE
*/
/*
CONSTCOND
*/
or Xo
/*
CONSTANTCOND
*/
or
/*
CONSTANTCONDITION
*/
Suppress complaints about constant operands for the next expression.
/* FALLTHRU */
or Xo
/*
FALLTHROUGH
*/
Suppress complaints about fall through to a
case
or
default
labeled statement.
This directive should be placed immediately preceding the label.
/*
LINTLIBRARY
*/
/*
LINTED
Xo
*/
or
/*
NOSTRICT
[comment]
*/
Suppresses any intra-file warning except those dealing with
unused variables or functions.
This directive should be placed
on the line immediately preceding where the lint warning occurred.
/*
LONGLONG
*/
/*
NOTREACHED
*/
/*
PRINTFLIKE
n
*/
/*
PROTOLIB
n
*/
/*
LINTLIBRARY
*/
directive.
If
n
is zero, function prototypes will be treated normally.
/*
SCANFLIKE
n
*/
/*
VARARGS
n
*/
The behavior of the
-i
and the
-o
options allows for incremental use of
lint
on a set of C source files.
Generally, one invokes
lint
once for each source file with the
-i
option.
Each of these invocations produces a
.ln
file that corresponds to the
.c
file, and prints all messages that are about just that
source file.
After all the source files have been separately run through
,
it is invoked once more (without the
-i
option), listing all the
.ln
files with the needed
-llibrary
options.
This will print all the inter-file inconsistencies.
This scheme works well with
make(1);
it allows
make(1)
to be used to
lint
only the source files that have been modified since the last
time the set of source files were
Nsed.
LIBDIR
/usr/libdata/lint
will be used to search for the libraries.
TMPDIR
CC
/usr/bin/cc
.
/usr/libexec/lint
[12]
/usr/libdata/lint/llib-l*.ln
/tmp/lint*
Static functions which are used only before their first extern declaration are reported as unused.
Libraries created by the -o option will, when used in later lint runs, cause certain errors that were reported when the libraries were created to be reported again, and cause line numbers and file names from the original source used to create those libraries to be reported in error messages. For these reasons, it is recommended to use the -C option to create lint libraries.