1988-10-28 16:27:32 +00:00
|
|
|
.\" (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
.\" See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
.\"
|
1994-06-24 14:02:31 +00:00
|
|
|
.\" $Id$
|
1991-10-01 12:18:39 +00:00
|
|
|
.TH LINT 1 "$Revision$"
|
1988-10-13 11:31:00 +00:00
|
|
|
.SH NAME
|
|
|
|
lint \- a C program checker
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B lint
|
1991-10-01 12:18:39 +00:00
|
|
|
[ \-abhuvx \-KR -ansi ] [file | libname | \-l\fIxxx\fP ] ...
|
1988-10-13 11:31:00 +00:00
|
|
|
.br
|
|
|
|
.B lint
|
1991-10-01 12:18:39 +00:00
|
|
|
\-L\fIlibname\fP [ file | libname2 | \-l\fIxxx\fP ] ...
|
1988-10-13 11:31:00 +00:00
|
|
|
.br
|
|
|
|
.SH DESCRIPTION
|
|
|
|
.I Lint
|
|
|
|
does an extensive consistency and plausibility check on a set of C
|
|
|
|
program files.
|
|
|
|
When it detects a doubtful construction
|
|
|
|
(which need not be an error) it gives a warning.
|
1988-10-28 16:27:32 +00:00
|
|
|
.PP
|
|
|
|
It does a full flow-of-control check, except that
|
1988-10-13 11:31:00 +00:00
|
|
|
.BR goto s
|
1991-03-12 10:58:22 +00:00
|
|
|
are not followed and that the fact that a function never returns
|
1988-10-28 16:27:32 +00:00
|
|
|
is not propagated.
|
1988-10-13 11:31:00 +00:00
|
|
|
If, however, no
|
|
|
|
.BR goto s
|
1988-10-28 16:27:32 +00:00
|
|
|
are used, each call of a non-returning function is followed by
|
1988-10-13 11:31:00 +00:00
|
|
|
/*NOTREACHED*/ and each switch has a default clause (possibly consisting
|
|
|
|
of /*NOTREACHED*/), the initialization state of all local variables will
|
|
|
|
be checked correctly.
|
|
|
|
.PP
|
1991-03-12 10:58:22 +00:00
|
|
|
.I Lint
|
|
|
|
checks the types of the arguments implied by the format in a call of
|
1988-10-28 16:27:32 +00:00
|
|
|
.IR printf() ,
|
|
|
|
.IR scanf()
|
1991-03-12 10:58:22 +00:00
|
|
|
and family, if the format string is a direct argument in the call.
|
1988-10-28 16:27:32 +00:00
|
|
|
Formats of user functions can be indicated using a FORMAT pseudo-comment; see
|
|
|
|
below.
|
|
|
|
.PP
|
|
|
|
.I Libraries
|
|
|
|
.PP
|
1991-03-12 10:58:22 +00:00
|
|
|
The second command (using the
|
1988-10-28 16:27:32 +00:00
|
|
|
.BR \-L -option)
|
|
|
|
is used to maintain lint libraries; these are ASCII files
|
1988-10-13 11:31:00 +00:00
|
|
|
that contain the output of the first pass.
|
1988-10-28 16:27:32 +00:00
|
|
|
A library name ends in
|
|
|
|
.BR .llb .
|
1988-10-13 11:31:00 +00:00
|
|
|
A lint user library can be created and updated by using the
|
|
|
|
.B \-L
|
|
|
|
option. The
|
|
|
|
.I libname
|
1991-03-12 10:58:22 +00:00
|
|
|
end in
|
1988-10-28 16:27:32 +00:00
|
|
|
.BR .llb ,
|
|
|
|
and can be passed to
|
1988-10-13 11:31:00 +00:00
|
|
|
.I lint
|
|
|
|
again as a normal argument.
|
|
|
|
.PP
|
1988-10-28 16:27:32 +00:00
|
|
|
Standard libraries are searched by default or by explicitly giving the
|
1988-10-13 11:31:00 +00:00
|
|
|
.B \-l
|
|
|
|
option; their format is identical to that of the user library files.
|
|
|
|
Possibilities are
|
|
|
|
.BR \-lm ,
|
|
|
|
.B \-ltermcap
|
|
|
|
and
|
|
|
|
.BR \-lcurses .
|
|
|
|
.B \-lc
|
|
|
|
is default; a single
|
|
|
|
.B \-l
|
|
|
|
tells
|
|
|
|
.I lint
|
|
|
|
not to use the standard C library.
|
1988-10-28 16:27:32 +00:00
|
|
|
The standard libraries are searched for in the standard lint directory or
|
|
|
|
in the directory given in the environment variable LINTLIB, if present.
|
|
|
|
.PP
|
|
|
|
.I Options
|
1988-10-13 11:31:00 +00:00
|
|
|
.PP
|
|
|
|
The
|
|
|
|
.BR \-D ,
|
|
|
|
.B \-U
|
|
|
|
and
|
|
|
|
.B \-I
|
1988-10-28 16:27:32 +00:00
|
|
|
options are recognized as separate arguments and conform to those of
|
|
|
|
.IR cc .
|
|
|
|
The
|
1988-10-13 11:31:00 +00:00
|
|
|
.B \-KR
|
|
|
|
option tells
|
|
|
|
.I lint
|
|
|
|
to check strictly according to Kernighan & Ritchie; since
|
|
|
|
.I lint
|
|
|
|
is trying to be helpful rather than obnoxious, this is not the default.
|
1991-09-30 16:55:35 +00:00
|
|
|
The
|
|
|
|
.B \-ansi
|
|
|
|
option tells lint to check according to ANSI C.
|
1988-10-13 11:31:00 +00:00
|
|
|
.PP
|
|
|
|
.I Lint
|
|
|
|
understands the following additional options:
|
|
|
|
.TP
|
|
|
|
.B a
|
|
|
|
Warn about conversions that may cause a loss of precision.
|
|
|
|
.TP
|
|
|
|
.B b
|
|
|
|
Do not report not-reachable
|
|
|
|
.I break
|
|
|
|
statements.
|
|
|
|
This flag may be useful when
|
|
|
|
.I lint
|
|
|
|
is run on a generated source file.
|
|
|
|
.TP
|
|
|
|
.B h
|
1988-10-28 16:27:32 +00:00
|
|
|
Apply several heuristics:
|
|
|
|
signal "null effects", possible pointer alignment problems and odd
|
|
|
|
constructs; report definitions of variables that have a scope wider than
|
1988-10-13 11:31:00 +00:00
|
|
|
necessary: extern variables that are used in one file only, automatic
|
|
|
|
variables that could be more local.
|
|
|
|
.TP
|
|
|
|
.B u
|
|
|
|
Do not complain about unused and undefined functions and global variables.
|
|
|
|
.TP
|
|
|
|
.B v
|
|
|
|
Do not warn about unused arguments of functions.
|
|
|
|
.TP
|
|
|
|
.B x
|
|
|
|
Complain about unused external variables.
|
|
|
|
.PP
|
1988-10-28 16:27:32 +00:00
|
|
|
.I Pseudo-comments
|
|
|
|
.PP
|
|
|
|
The following pseudo-comments can be used to influence the behaviour of
|
|
|
|
.IR lint:
|
1988-10-13 11:31:00 +00:00
|
|
|
.TP
|
1991-03-12 10:58:22 +00:00
|
|
|
/*\ ARGSUSED\ */
|
1988-10-13 11:31:00 +00:00
|
|
|
Do not warn about arguments not used in the next function
|
|
|
|
(see also the \-\fBv\fR option).
|
|
|
|
.TP
|
1991-03-12 10:58:22 +00:00
|
|
|
/*\ NOTREACHED\ */
|
1988-10-13 11:31:00 +00:00
|
|
|
This tells
|
|
|
|
.I lint
|
|
|
|
that the flow of control "cannot reach" this comment.
|
|
|
|
This is a way to tell
|
|
|
|
.I lint
|
|
|
|
that a statement never "returns".
|
|
|
|
.TP
|
1991-03-12 10:58:22 +00:00
|
|
|
/*\ LINTLIBRARY\ */
|
|
|
|
The definitions following this pseudo-comment are assumed to be part of a
|
|
|
|
library.
|
1988-10-13 11:31:00 +00:00
|
|
|
It suppresses complaints about unused functions and variables
|
|
|
|
and is used in the creation of lint libraries.
|
1991-03-12 10:58:22 +00:00
|
|
|
It implies /*\ ARGSUSED\ */.
|
1988-10-28 16:27:32 +00:00
|
|
|
.TP
|
1991-03-12 10:58:22 +00:00
|
|
|
/*\ VARARGS\fIn\fR\ */
|
1988-10-28 16:27:32 +00:00
|
|
|
The next function can be called with a variable number of
|
|
|
|
arguments.
|
|
|
|
Only check the types of the first \fIn\fR arguments.
|
|
|
|
The \fIn\fR must follow the word VARARGS immediately.
|
1991-03-12 10:58:22 +00:00
|
|
|
/*\ VARARGS0\ */ may be abbreviated to /*\ VARARGS\ */.
|
1988-10-28 16:27:32 +00:00
|
|
|
.TP
|
1991-03-12 10:58:22 +00:00
|
|
|
/*\ FORMAT\fIn\fR $ ... $\ */
|
1988-10-28 16:27:32 +00:00
|
|
|
The \fIn\fP-th argument (counting from 0) of the next function declaration
|
|
|
|
corresponds to a
|
|
|
|
.IR printf -like
|
1989-10-04 15:33:49 +00:00
|
|
|
format string. Details about the format are given between the $$; see below.
|
|
|
|
A missing $$ repeats the latest format.
|
1988-10-28 16:27:32 +00:00
|
|
|
The \fIn\fR must follow the word FORMAT immediately.
|
1991-03-12 10:58:22 +00:00
|
|
|
/*\ FORMAT\fIn\fR $ ... $\ */ implies /*\ VARARGS\fIn+1\fP\ */; if the format
|
|
|
|
is followed by more required arguments, a separate /*\ VARARGS\fIm\fP\ */
|
1988-10-28 16:27:32 +00:00
|
|
|
must be given after the FORMAT pseudo-comment.
|
1989-10-04 15:33:49 +00:00
|
|
|
.IP
|
|
|
|
If the printf-like heading also has to conform to some varargs.h convention,
|
|
|
|
error messages may result; these can be suppressed by appending the letter v
|
|
|
|
to the word FORMAT\fIn\fR without intervening space.
|
1988-10-28 16:27:32 +00:00
|
|
|
.PP
|
|
|
|
.I Formats
|
|
|
|
.PP
|
1991-03-12 10:58:22 +00:00
|
|
|
The $$-part of the FORMAT pseudo-comment consists of a list of format
|
|
|
|
specifications, each of the form
|
|
|
|
.IR %T = type ,
|
|
|
|
where
|
|
|
|
.I T
|
|
|
|
is an arbitrary (short) string and
|
1988-10-28 16:27:32 +00:00
|
|
|
.I type
|
|
|
|
is the expected type in "C normal form" (like in a cast, with no superfluous
|
1991-03-12 10:58:22 +00:00
|
|
|
parentheses and without the use of typedefs). E.g., %ld=long indicates that
|
|
|
|
the format string ld corresponds to a parameter of type long. For a shorter
|
|
|
|
notation see the example below.
|
|
|
|
.I Lint
|
|
|
|
recognizes conversion specifications of the form %[N|*|][.[N|*]]T where N is
|
|
|
|
a number, the * is itself and T is a string as defined above. For the above
|
|
|
|
example this would include %ld, %5.2ld, %.*ld, etc.
|
1988-10-28 16:27:32 +00:00
|
|
|
.PP
|
|
|
|
Example: the FORMAT pseudo-comment for
|
|
|
|
.I printf()
|
|
|
|
is:
|
|
|
|
.br
|
1991-03-12 10:58:22 +00:00
|
|
|
/*\ FORMAT0 $
|
1988-10-28 16:27:32 +00:00
|
|
|
.br
|
|
|
|
%[dox] = int %l[dox] = long %[DOX] = long
|
|
|
|
.br
|
|
|
|
%u = unsigned int %lu = unsigned long %U = unsigned long
|
|
|
|
.br
|
|
|
|
%[feg] = double
|
|
|
|
.br
|
1991-03-12 10:58:22 +00:00
|
|
|
%c = int %s = char *
|
1988-10-28 16:27:32 +00:00
|
|
|
.br
|
1991-03-12 10:58:22 +00:00
|
|
|
$\ */
|
1989-10-04 15:33:49 +00:00
|
|
|
.PP
|
|
|
|
.I Output
|
|
|
|
.PP
|
|
|
|
Some users feel it is a good idea to pipe the output of
|
|
|
|
.I lint
|
|
|
|
through the command
|
|
|
|
.br
|
|
|
|
sort \-t' ' +0d \-1 +2n \-3
|
|
|
|
.br
|
|
|
|
where the character between the apostrophes is a space.
|
1988-10-28 16:27:32 +00:00
|
|
|
.SH "ENVIRONMENT VARIABLES"
|
1991-03-12 10:58:22 +00:00
|
|
|
LINTFLAGS additional flag arguments (e.g. LINTFLAGS=\-h)
|
1988-10-28 16:27:32 +00:00
|
|
|
.br
|
|
|
|
LINTLIB directory in which the standard libraries are looked up
|
1988-10-13 11:31:00 +00:00
|
|
|
.SH FILES
|
1988-10-28 16:27:32 +00:00
|
|
|
.IP ???/lnt 24
|
1988-10-13 11:31:00 +00:00
|
|
|
first pass
|
|
|
|
.IP ???/lpass2/lpass2
|
|
|
|
second pass
|
1988-10-28 16:27:32 +00:00
|
|
|
.IP ???/llib/*.llb
|
1988-10-13 11:31:00 +00:00
|
|
|
lint libraries
|
|
|
|
.SH SEE ALSO
|
|
|
|
cem(1)
|
|
|
|
.br
|
|
|
|
Frans Kunst,
|
|
|
|
.I Lint, a C Program Checker
|
|
|
|
.SH BUGS
|
|
|
|
Conflicting options in the command line are not detected.
|
|
|
|
.br
|
|
|
|
After a label, all automatic variables are assumed initialized.
|
|
|
|
.SH AUTHOR
|
|
|
|
Frans Kunst, Vrije Universiteit, Amsterdam.
|
1988-10-28 16:27:32 +00:00
|
|
|
.br
|
|
|
|
Dick Grune, Vrije Universiteit, Amsterdam.
|
|
|
|
.br
|