 |
Index for Section 1 |
|
 |
Alphabetical listing for L |
|
lint(1)
NAME
lint - a C program checker
SYNOPSIS
lint [-abchlnpuxv] [-cpp] [-dpath] [-Dname[=definition]] [-Idirectory]
[-lkey] [-olibrary] [-MA] [-Msuboptions] [-stdn] [-Pppoptions]
[-Qsuboptions] [-Ndnumber] [-Nlnumber] [-Nnnumber] [-Ntnumber] [-Uname]
[-wclass...] [-Xdollar] [-XEnum] file...
OPTIONS
Any number of lint options may be used, in any order, intermixed with
file-name arguments. The following options are used to suppress certain
kinds of complaints:
-a Suppress complaints about assignments of long values to variables that
are not long.
-b Suppress complaints about break statements that cannot be reached.
(Programs produced by lex or yacc will often result in many such
complaints).
-h Do not apply heuristic tests that attempt to intuit bugs, improve
style, and reduce waste.
-u Suppress complaints about functions and external variables used and not
defined, or defined and not used. (This option is suitable for running
lint on a subset of files of a larger program).
-v Suppress complaints about unused arguments in functions.
-x Do not report variables referred to by external declarations but never
used.
-Xdollar
Suppress complaints about the use of the dollar sign ($) in variable
names.
-wclass
Controls the reporting of warning classes. All warning classes are
active by default. They can however, be individually activated by
including the appropriate option as part of the class argument. For
example, to report only declaration consistency and Heuristic
complaints, enter the following command:
lint -wA -wdh prog.c
In the preceding example, -wA deactivates all warnings and -wdh
activates the desired reports. The following list describes available
classes of warnings:
a Non-ANSI features
c Comparisons with unsigned values
d Declaration consistency
h Heuristic complaints
k Suppresses the following messages: function prototype not in scope
and old style argument declaration.
l Assignment of long values to variables that are not long
n Null-effect code
o Unknown order of evaluation
p Various portability concerns
r Return statement consistency
u Proper usage of variables and functions
A Deactivates all warnings
C Constants occurring in conditionals
D Declarations that are never used or defined.
O Obsolete features
P Function prototype presence
R Detection of unreachable code
S Storage capacity checks
U Equivalent to -u
The following options alter lint's behavior:
-cpp
Cause lint to use /lib/cpp as its preprocessor instead of /usr/bin/cc.
-lx Include additional lint library llib-lx.ln. For example, you can
include a lint version of the Math Library llib-lm.ln by inserting -lm
on the command line. This argument does not suppress the default use
of llib-lc.ln. These lint libraries must be in the assumed directory.
This option can be used to reference local lint libraries and is useful
in the development of multi-file projects.
-n Do not check compatibility against either the standard or the portable
lint library.
-1 Do not check compatibility between files or the lint libraries.
-p Attempt to check portability to other dialects (IBM and GCOS) of C.
Along with stricter checking, this option causes all non-external names
to be truncated to eight characters and all external names to be
truncated to six characters and one case.
-c Cause lint to produce a .ln file for every .c file on the command line.
These .ln files are the product of lint's first pass only, and are not
checked for inter-function compatibility.
-olib
Cause lint to create a lint library with the name llib-llib.ln. The -c
option nullifies any use of the -o option. The lint library produced is
the input that is given to lint's second pass. The -o option simply
causes this file to be saved in the named lint library. To produce a
llib-llib.ln without extraneous messages, use of the -x option is
suggested. The -v option is useful if the source file(s) for the lint
library are just external interfaces (for example, the way the file
llib-lc is written). These option settings are also available through
the use of "lint comments" (see below).
-dpath
Cause lint to store the files created as a result of the -o or -c
option in the specified path.
-MA Enforces ANSI C standard rules. The default lint preprocessing and
parsing mode is Extended C (K&R). ANSI preprocessing and parsing rules
may be selected as an option. ANSI mode prepends (adds at the
beginning) the standard ANSI library function prototypes in place of
the default extended mode C library. ANSI mode enforces a stricter
interfile object reference/definition linkage checking. This option
also invokes the -std1 C preprocessor option and defines the macro
_ANSI_C_SOURCE.
-Msuboption
The suboptions enforce some of the ANSI parsing rules. These are
implemented as toggles. This option and set of suboptions can be used
to turn on or off specific ANSI features. For example, -MAt turns on
all ANSI rules except ANSI typing rules.
a follow ANSI parsing rules
b follow ANSI const array struct member bug
c follow ANSI type compatibility rules
p follow ANSI type promotion rules
r follow ANSI strict ref/def rules
s follow ANSI scoping rules for externs
t follow ANSI typing rules
-P Allows C preprocessor options to be specified when executing the lint
command. For example, specifying -PV invokes the preprocessor with the
-V option specified.
-std[0,1]
Directs the C Preprocessor to generate the appropriate predefined
macros. The -std option causes the macro __STDC__=0 to be passed to the
preprocessor; -std1 causes the macro __STDC__=1 to be passed, and -std0
causes __STDC__ to be undefined. The default is -std0. The -std0
option is incompatible with the -M option. If -std or -std1 are
selected, the -MA ANSI parsing rules are automatically selected.
-XEnum
Specifies the number (num) of errors lint accepts before terminating.
By default, lint terminates after encountering 30 errors.
The -Q option provides support for migration from ULTRIX and DEC OSF/1
Version 1.0 systems to DEC OSF/1 Version 1.2 (now known as Tru64 UNIX) and
higher versions of the Tru64 UNIX operating system. This option turns on
checking for all common programming techniques which might cause problems
when moving from 32-bit systems to 64-bit systems. The -Q option disables
checking for other programming problems, so this switch should be used only
for migration checking.
Suboptions to -Q have the form -Qn. You can enter more than one suboption
with the -Q option, for example, -QacP to suppress checking for pointer
alignment problems, problematic type casts, and function prototype checks,
respectively.
The following suboptions are available to suppress specific categories of
checking:
a Suppresses checking of pointer alignment problems.
c Suppresses checking for problematic type casts. (Overrides -QG option.)
f Suppresses checking for format control strings in scanf and printf.
l Suppresses checking for assignments of long values to variables of a
type other than long.
p Suppresses checking for illegal combinations pointer and integer data
types.
s Suppresses checking for problematic sign extensions to long
u Suppresses checking to see if a variable is used before it is set.
C Suppresses checking to see if there is constant truncation of longs in
an assignment.
F Suppresses checking to see if precision has been lost in field
assignment.
G Suppresses truncation message when casting to char *. (Overridden by
-Qc option.)
P Suppresses function prototype checks.
S Suppresses checking for a problematic combination of structure
pointers. If structure checking and cast checking are not suppressed
then the casting of differing structures and pointers to structures are
flagged if the structures differ in size and/or alignment as described
in the following two suboptions.
z Suppresses warnings about casting a structure or structure pointer to
one of a different size. Takes effect only if c and S are not specified
on the command line.
g Suppresses warnings about casting a structure or structure pointer to
on of a different alignment. Takes effect only if c and S are not
specified on the command line.
The -N option and its related suboptions allow you to increase the size of
various internal tables at runtime. Suboptions to the -N option take the
form -Nzx where z is a suboption and x is an integer size.
-N Use this option with its suboptions to increase the initial size of
various internal tables at runtime if the default values are not
sufficient. All of the tables are dynamically expandable; however,
larger initial values may improve run-time performance.
nxxxx
Use with -N to increase the initial size of the symbol table. To
increase the number of entries, use -Nnxxxx to increase the number of
entries. Use a number greater than 1500, which is the default value.
The larger the number, the fewer collisions. As a rule of thumb, use a
number roughly twice the number of source code lines.
dxxxx
Use with -N when you encounter the error that the dimension table has
overflowed or is full. To increase the number of base elements
allocated to the members of the dimension tables, use a number greater
than 2000, which is the default value.
tx Use with -N when you encounter the error stating that the parse tree
limit has been reached, "out of tree space; recompile with Ntx option
with x greater than xxxx". Run lint again, do not recompile, on the
module that generated the error using -Ntyyyy with yyyy greater than
the value in the error message.
lx Use with -N when you encounter the error stating that the local type
table limit has been reached, "out of tree space; recompile with -Nlx
option with x greater than xxxx". Run lint again, do not recompile, on
the module that generated the error, using -Nlyyyy with yyyy greater
than the value in the error message.
The -D, -U, and -I options of cpp(1) and the -g and -O options of cc(1) are
also recognized as separate arguments. The -g and -O options are ignored,
but, by recognizing these options, lint's behavior is closer to that of the
cc(1) command. Other options are warned about and ignored. The pre-
processor symbol "lint" is defined to allow certain questionable code to be
altered or removed for lint. Therefore, the symbol "lint" should be thought
of as a reserved word for all code that is planned to be checked by lint.
The following lint directives, which appear as conventional comments in the
C source program, change the behavior of lint:
/*ARGSUSED*/
Prevents lint from warning against unused function arguments (that is,
turns on the -v option) for the next function.
/*LINTLIBRARY*/
When placed at the beginning of a file, suppresses complaints about
unused functions and function arguments in this file. This is
equivalent to using the -v and -x options. This directive is used for
building lint libraries.
/*LINTSTDLIB*/
Permits a standard prototype checking library to be formed from header
files by making function prototype declarations appear as function
definitions. The /*LINTSTDLIB*/ directive implicitly activates the
functions of the /*NOTUSED*/ and /*LINTLIBRARY*/ directives to reduce
warning noise levels.
/*NOTDEFINED*/
When placed in a file, suppresses warnings about all used but undefined
external symbols and functions that are subsequently encountered in the
file.
/*NOTREACHED*/
When placed at appropriate points in a program (typically immediately
following a return, break, or continue statement), stops comments about
unreachable code. Note that lint does not recognize the exit function
and other functions that may not return.
/*NOTUSED*/
When placed in a file, suppresses warnings about all unused external
symbols, functions, and function parameters that are subsequently
encountered in the file. This directive is similar to the
/*LINTLIBRARY*/ directive, although /*NOTUSED*/ also applies to
external symbols.
/*VARARGSn*/
Suppresses the usual checking for variable numbers of arguments in the
following function declaration. The data types of the first n arguments
are checked; for instance, if /*VARARGS2*/ is specified, lint checks
only the first two arguments. If n is not specified, it is interpreted
as a 0 (zero).
The lint utility produces its first output on a per-source-file basis.
Complaints regarding included files are collected and printed after all
source files have been processed. Finally, if the -c option is not used,
information gathered from all input files is collected and checked for
consistency. At this point, if it is not clear whether a complaint stems
from a given source file or from one of its included files, the source file
name will be printed followed by a question mark.
The behavior of the -c 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 -c option. Each of these invocations produces a .ln
file which 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 lint, it is invoked once more (without the -c
option), listing all the .ln files with the needed -lx options. This will
print all the inter-file inconsistencies. This scheme works well with
make(1); it allows make to be used to lint only the source files that have
been modified since the last time the set of source files were run through
lint.
DESCRIPTION
The lint program checker attempts to detect features of the C program files
that are likely to be bugs, non-portable, or wasteful. It also checks type
usage more strictly than the compilers. Among the things that are currently
detected are unreachable statements, loops not entered at the top,
automatic variables declared and not used, and logical expressions whose
value is constant.
Moreover, the usage of functions is checked to find functions that return
values in some places and not in others, functions called with varying
numbers or types of arguments, and functions whose values are not used or
whose values are used but none returned.
Arguments whose names end with .c are taken to be C source files. Arguments
whose names end with .ln are taken to be the result of an earlier
invocation of lint with either the -c or the -o option used. The .ln files
are analogous to .o (object) files that are produced by the cc(1) command
when given a .c file as input. Files with other suffixes produce warnings
and are ignored.
The lint program checker will take all the .c, .ln , and llib-lx.ln
(specified by -lx) files and process them in their command line order. It
appends a lint library file to this list of files, as follows:
· If the -p option is used, the portable C lint library (llib-port.ln)
is appended.
· If the -std or -std1 option is used, the C standard lint library
llib-lcstd.ln) is appended.
· If the -MA option is used, the ANSI standard lint library (llib-
lansi.ln) is appended.
· Otherwise, the standard C lint library (llib-lc.ln) is appended.
When the -c option is not used, the second pass of lint checks this list of
files for mutual compatibility. When the -c option is used, the .ln and the
llib-lx.ln files are ignored.
RESTRICTIONS
The exit(2), setjmp(3) and other functions that do not return are not
understood; this causes various lies.
FILES
/usr/ccs/lib
The directory where the lint libraries specified by the -lx option must
exist.
/usr/ccs/lib/lint
The directory where the lint library sources are kept.
/usr/ccs/lib/cmplrs/cc/lint[12]
first and second passes of lint
llib-lc.ln
declarations for C Library functions (binary format; source is in
llib-lc.c)
llib-port.ln
declarations for portable functions (binary format; source is in llib-
port.c)
llib-lm.ln
declarations for Math Library functions (binary format; source is in
llib-lm.c)
llib-lcrses.ln
declarations for Curses Library functions (binary format; source is in
llib-lcrses.c)
*lint*
temporary files (default directory /usr/tmp)
SEE ALSO
Commands: cc(1), cpp(1), make(1)