Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

cpp(1)

make(1)

lint(1)

NAME

lint − a C program checker/verifier

SYNOPSIS

lint [options] file ... 

DESCRIPTION

lint attempts to detect features in C program files that are likely to be bugs, non-portable, or wasteful.  It also checks type usage more strictly than the compilers.  Program anomalies currently detected include unreachable statements, loops not entered at the top, automatic variables declared but not used, and logical expressions whose value is constant.  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 assumed to be C source files.  Arguments whose names end with .ln are assumed to be the result of an earlier invocation of lint with either the -c or the -o option used.  .ln files are analogous to .o (object) files produced by the cc or c89 command (see cc(1) when given a .c file as input.  Files with other suffixes are warned about and ignored. 

lint takes all the .c, .ln, and llib-lx.ln files (specified by -lx ) and processes them in their command-line order.  By default, lint appends the standard C lint library (llib-lc.ln) to the end of the list of files.  However, if the -p option is used, the portable C lint library (llib-port.ln) is appended instead.  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, all .ln and llib-lx.ln files are ignored. 

Options

Any number of lint options can 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 often result in many such complaints). 

-h Do not apply heuristic tests that attempt to intuitively find 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. 

The following arguments alter lint’s behavior:

-lx Include additional lint library llib-lx.ln.  For example, to include a lint version of the Math Library llib-lm.ln, insert -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 multiple-file projects. 

-n Do not check compatibility against either the standard or the portable lint library. 

-p Attempt to check portability to other dialects 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. 

-s Make stricter checks about pointer and structure alignments that can prevent portability.  Complain about a cast that converts a pointer from a less restrictive alignment to a more restrictive alignment.  Complain about a structure member whose offset is not a multiple of its size. 

-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. 

-o lib Cause lint to create a lint library with the name llib-llib.ln.  The -c option nullifies any use of the -o option.  The resulting lint library serves as input 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 the -x option.  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 by using “lint comments” (see below). 

-Amode Specify the compilation standard to be used by lint.  The mode can be one of the following letters:

c Process in a mode compatible with HP-UX releases prior to 7.0.  (See The C Programming Language, First Edition by Kernighan and Ritchie). This option is currently the default. The default may change in future releases.

a Process under ANSI mode (December 7, 1988 Draft proposed ANSI C standard.) 

-Y Enable support of 16-bit characters inside string literals and comments. Note that 8-bit parsing is always supported.  See hpnls(5) for more details on international language support.

The -D, -U, and -I options to cpp and the -g and -O options to cc 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 command.  Other options are warned about and ignored.  The pre-processor symbols __lint and __LINT__ are defined to allow certain questionable code to be altered or removed for lint.  In addition, the pre-processor symbol lint is defined in compatibility mode.  By default, the lint library llib-lc.ln encodes the HP-UX namespace version of libc.a.  Other standards can be checked by including the appropriate -D option on the lint command line.  For example,

lint -D_POSIX_SOURCE file.c

reprocesses llib-lc to reflect the POSIX standard. 

Certain conventional comments in the C source change the behavior of lint:

/*NOTREACHED*/ at appropriate points stops comments about unreachable code.  (This comment is typically placed just after calls to functions such as exit()). 

/*VARARGSn*/ suppresses the usual checking for variable numbers of arguments in the following function definition.  This comment must be placed just before the actual code for a function.  It is not used before extern declarations of the same function elsewhere.  The data types of the first n arguments are checked; a missing n is assumed to be 0. 

/*ARGSUSED*/ enables the -v option for the next function. 

/*LINTLIBRARY*/ at the beginning of a file shuts off complaints about unused functions and function arguments in this file.  This is equivalent to using the -v and -x options. 

lint 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 is printed, followed by a question mark. 

Behavior of the -c and -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 prints all the inter-file inconsistencies.  This scheme works well with make; allowing make to be used to lint only the source files that have been modified since the last time the set of source files were processed by lint (see make(1)).

EXTERNAL INFLUENCES

Environment Variables

LC_CTYPE determines the interpretation of comments and string literals as single- and/or multi-byte characters. 

If LC_CTYPE is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable.  If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG.  If any internationalization variable contains an invalid setting, lint behaves as if all internationalization variables are set to "C".  See environ(5).

When set, the TMPDIR environment variable specifies a directory to be used for temporary files, overriding the default directories /tmp and /usr/tmp. 

Long error messages are split across lines to make them easier to read.  The environment variable COLUMNS controls the maximum number of characters on each line. 

International Code Set Support

Single- and multi-byte character code sets are supported within file names, comments, and string literals. 

FILES

/usr/lib the directory where the lint libraries specified by the -lx option must exist

/usr/lib/lint[12] first and second passes

/usr/bin/lint shell script that invokes lint[12]

/usr/lib/llib-lc.ln declarations for C Library functions (binary format; source is in /usr/lib/llib-lc)

/usr/lib/llib-port.ln declarations for portable functions (binary format; source is in /usr/lib/llib-port)

/usr/lib/llib-lm.ln declarations for Math Library functions (binary format; source is in /usr/lib/llib-lm)

/usr/tmp/*lint* temporaries

WARNINGS

exit(), longjmp(), and other functions that do not return are not understood (see exit(2) and setjmp(3C)); this causes various inaccuracies.

SEE ALSO

cc(1), cpp(1), make(1). 

Lint C Program Checker tutorial in C Programming Tools manual. 

STANDARDS CONFORMANCE

lint: SVID2, XPG2, XPG3

Hewlett-Packard Company  —  HP-UX Release 9.0: August 1992

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026