Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lint(1V) — SunOS 3.5

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1V)

cpp(1)

LINT(1V)  —  USER COMMANDS

NAME

lint − a C program verifier

SYNOPSIS

lint [ −abchinouvxz ] [ −Dname[=def ] ] [ −D name ] [ −U name ] [ −Idir ] [ −o outfile ] filename ...
lint [ −Clib ] filename ...

SYSTEM V SYNOPSIS

/usr/5bin/lint [ −abcghnpuvxzO ] [ −D name=def ] [ −D name ] [ −U name ] [ −Idir ] [ −o lib ] filename ...

DESCRIPTION

lint attempts to detect features of the C program files that are likely to be bugs, non-portable, or wasteful.  lint also checks the type usage of the program more strictly than the C compiler.  lint runs the C preprocessor as its first phase.  The preprocessor symbol "lint" is defined, in order 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.

Among the things that are currently found are unreachable statements, loops not entered at the top, automatic variables declared and not used, and logical expressions whose values are constant.  Moreover, the usage of functions is checked to find functions which return values in some places and not in others, functions called with varying numbers of arguments, and functions whose values are not used. 

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 the −C option used.  The .ln files are analogous to .o (object) files that are produced by the cc(1V) command when given a .c file as input. 

lint will take all the .c,.ln, and llib-lx.ln (specified by −lx) files and process 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.  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. 

To create lint libraries, use the −C option. For example

tutorial% lint −Ccongress files ...

where files are the C sources of library congress, produces a file llib-lcongress.ln in the current directory in the correct library format suitable for lint’ing programs using −lcongress. 

General Comments

The routine exit(2) and other functions which do not return are not understood; this causes various lies.

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

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

/∗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; a missing n is taken to be 0. 

/∗ARGSUSED∗/
turns on 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. 

SYSTEM V DESCRIPTION

lint will take all the .c,.ln, and llib-lx.ln (specified by −lx) files and process 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, the .ln and the llib-lx.ln files are ignored. 

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

OPTIONS

−a Report assignments of long values to variables that are not long. 

−b Report break statements that cannot be reached.  This is not the default because, unfortunately, most lex(1) and many yacc(1) outputs produce dozens of such messages.

−c Complain about casts which have questionable portability. 

−h Apply a number of heuristic tests to attempt to intuit bugs, improve style, and reduce waste. 

−i 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 compatibility between functions.

−n Do not check compatibility against the standard library. 

−u Do not complain about functions and external variables used and not defined, or defined and not used (this is suitable for running lint on a subset of files comprising part of a larger program). 

−v Suppress complaints about unused arguments in functions. 

−x Report variables referred to by extern declarations, but never used. 

−z Do not complain about structures that are never defined (for example, using a structure pointer without knowing its contents). 

−Dname=def

−Dname Define name to the preprocessor, as if by ‘#define’.  If no definition is given, the name is defined as "1". 

−Uname Remove any initial definition of name in the preprocessor. 

−Idir ‘#include’ files whose names do not begin with ‘/’ are always sought first in the directory of the file argument, then in directories named in −I options, then in the /usr/include directory. 

−o outfile
Name the output file outfile.  outfile cannot be the same as sourcefile (lint will not overwrite the source file). 

−Clib create a lint library with name lib (see DESCRIPTION section). 

−llib use lint library lib from the /usr/lib/lint directory. 

SYSTEM V OPTIONS

The sense of the −a, −b, −h, and −x options is reversed in the System V version of lint; the tests they control are performed unless the flag is specified. The −C option is not available; instead, the −c or −o options can be used. 

−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 compatibility between functions.

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

−g

−O These options are accepted but ignored.  By recognizing these options, lint’s behavior is closer to that of the cc(1V) command.

EXAMPLE

The following lint call:

tutorial% lint  −b  myfile.c

checks the consistency of the code in the C source file file myfile.c.  The −b option indicates that unreachable break statements are to be checked for. 

FILES

/usr/lib/lint/lint[1 2]programs
/usr/lib/lint/llib-l∗.lnVarious prebuilt lint libraries. 
/usr/lib/lint/llib-l∗Sources of the prebuilt lint libraries. 
These libraries exist for −lc, −lcore, −lcurses, −lm, −lmp, −lpixrect, −lsuntool, −lsunwindow, and −ltermcap. 

SYSTEM V FILES

/usr/5lib/lint/lint[1 2]programs
/usr/lib/5lint/llib-l∗.lnVarious prebuilt lint libraries. 
/usr/lib/5lint/llib-l∗Sources of the prebuilt lint libraries. 
These libraries exist for −lc, −lm, and −lport. 

SEE ALSO

cc(1V), cpp(1)
Lint, a C Program Checker, in Programming Utilities for the Sun Workstation

BUGS

There are some things you just can’t get lint to shut up about. 

Sun Release 3.5  —  Last change: 17 July 1986

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