up | Inhaltsverzeichniss | Kommentar

Manual page for LINT(1V)

lint - a C program verifier

SYNOPSIS

lint [ -abchinquvxz ] [ -Dname[=def] ] [ -host=arch ] [ -Idirectory ] [ -llibrary ] [ -o outputfile ]
          [ -target=arch ] [ -Uname ] filename ...
lint [ -Clibrary ] [ -Dname[=def] ] [ -host=arch ] [ -Idirectory ] [ -llibrary ] [ -target=arch ]
          [ -Uname ] filename ...

SYSTEM V SYNOPSIS

/usr/5bin/lint [ -abcghnpquvxzO ] [ -Dname[=def] ] [ -Idirectory ] [ -llibrary ] [ -o outputfile ]
          [ -Uname ] filename ...

AVAILABILITY

The System V version of this command is available with the System V software installation option. Refer to [a manual with the abbreviation INSTALL] for information on how to install optional software.

DESCRIPTION

lint attempts to detect features of the named C program files that are likely to be bugs, to be non-portable, or to be wasteful. It also performs stricter type checking than does the C compiler. lint runs the C preprocessor as its first phase, with the preprocessor symbol lint defined to allow certain questionable code to be altered or skipped by lint. Therefore, this symbol should be thought of as a reserved word for all code that is to be checked by lint.

Among the possible problems that are currently noted are unreachable statements, loops not entered at the top, automatic 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 lint, with either the -i or the -C option in effect. The .ln files are analogous to the .o (object) files produced by the cc.1v from .c files. lint also accepts special libraries specified with the -l option, which contain simplified definitions of standard library routines (preprocessed by `lint -C') for faster checking of function calls.

lint processes the various .c, .ln, and llib-llibrary.ln (lint library) files and process 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 -C and -i options are omitted the second pass of lint checks this list of files for mutual compatibility. When the -C or the -i options are used, the .ln and the llib-llibrary.ln files are ignored.

SYSTEM V DESCRIPTION

Filename arguments with names ending with .ln are taken to be the result of an earlier invocation of lint, with either the -c or the -o option in effect.

lint processes the various .c, .ln, and llib-llibrary.ln (lint library) files and process 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. However, if the -p option is used, the portable C lint library (llib-port.ln) is appended instead. When the -c option is omitted the second pass of lint checks this list of files for mutual compatibility. When the -c option is used, the .ln and the llib-llibrary.ln files are ignored.

lint produces its first-pass output on a per-source-file basis. Complaints regarding included files are collected and printed after all source files have been processed. If the -c option is not used, information gathered from all input files is then 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.

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 many such complaints.
-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
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.
-q
Do not complain about constructs that do not cause portability problems between current Sun implementations of the C language but that will cause portability problems between other implementations. If the -q flag is specified, lint treats type enum as an int, treats type long as type int and type unsigned long as unsigned int, and treats a 0 argument as being conformable with any pointer.
-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).
-Clibrary
Create a lint library with the name llib-llibrary.ln.
-Dname[=def]
Define name for cpp.1 as if by a #define directive. If no definition is given, name is defined as 1.
-host=arch (Sun-2, Sun-3, and Sun-4 systems only)
Define the host architecture to be arch. The default is the architecture returned by the arch.1 command. arch can be one of sun2, sun3, or sun4.
-Idirectory
Add directory to the list of list of directories in which to search for include files. Include files with names that do not begin with / are always sought first in the directory of the filename argument, then in directories named in -I options, then in the /usr/include directory.
-llibrary
Use the lint library library from the /usr/lib/lint directory.
-o outputfile
Name the output file outputfile. outputfile cannot be the same as sourcefile (lint will not overwrite the source file).
-target=arch (Sun-2, Sun-3, and Sun-4 systems only)
Define the target architecture to be arch, for additional portability checks specific to that architecture. The default is the value returned by the arch.1 command. arch can be one of: sun2, sun3, or sun4.
-Uname
Remove any initial definition of name for the preprocessor.

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. The -i option is not used; instead, the -c option can be used. The -q, -host, and -target options are not available.
-c
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.
-g
-O
These options are accepted but ignored. By recognizing these options, lint's behavior is closer to that of the cc.1v command.
-n
Do not check compatibility against either the standard or the portable lint library.
-p
Attempt to check portability of code to other dialects of C, such as IBM 370 and Honeywell GCOS. Along with performing stricter checking, this option truncates all non-external names to eight characters, and all external names to six characters and one case.
-o library
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 saves this file 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 Input Grammar below).

USAGE

For more information about lint refer to lint in [a manual with the abbreviation PUL]

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

example% lint -Ccongress filenames ...

where filenames are the C sources of library congress, produces a file llib-lcongress.ln in the current directory in the correct library format suitable for ``linting'' programs using -lcongress.

Input Grammar

lint's first pass reads standard C source files. lint recognizes the following C comments as commands.

/*NOTREACHED*/
At appropriate points, inhibit comments about unreachable code. (This comment is typically placed just after calls to functions like exit.2v
/*VARARGSn*/
Suppress 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. In this version of lint, /*VARARGS0*/ is allowed. It no longer indicates the absence of variable arguments.
/*ARGSUSED*/
Enable the -v option for the next function.
/*LINTLIBRARY*/
At the beginning of a file, shut off complaints about unused functions and function arguments in this file. This is equivalent to using the -v and -x options.

SYSTEM V USAGE

The behavior of the -c and the -o options allows for incremental use of lint on a set of C source files. Invoking `lint -c' for each source file produces a corresponding .ln file, and prints all messages pertaining to that source file. After all of the source files have been run through lint separately, it is invoked once more (without the -c option), and with all of the .ln files and -lx options. This produces messages about any inconsistencies between files. This scheme works well with make.1 since it allows make to ``lint'' only those source files that have been modified since the last time lint was run.

To create lint libraries, use the -o option. For example

example% lint -x -o congress filenames ...

where filenames are the C sources of library congress, produces a file llib-lcongress.ln in the current directory in the correct library format suitable for ``linting'' programs using -lcongress.

EXAMPLE

The following lint call:

example% 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[12]
programs
/usr/lib/lint/llib-l*.ln
various prebuilt lint libraries
/usr/lib/lint/llib-l*
sources of the prebuilt lint libraries

The following lint libraries are supplied with SunOS: -lc, -lcore, -lcurses, -lkvm, -llwp, -lm, -lmp, -lpixrect, -lplot, -lsuntool, -lsunwindow, -ltermcap, and -ltermlib. Additional lint libraries may be installed separately.

SYSTEM V FILES

/usr/5lib/lint/lint[12]
programs
/usr/5lib/lint/llib-l*.ln
various prebuilt lint libraries
/usr/5lib/lint/llib-l*
sources of the prebuilt lint libraries

The following System V lint libraries are supplied with SunOS: -lc, -lcore, -lcurses, -lkvm, -llwp, -lm, -lmp, -lpixrect, -lplot, -lport. -lsuntool, and -lsunwindow. Additional lint libraries may be installed separately.

SEE ALSO

cc.1v cpp.1 lex.1 make.1 yacc.1 exit.2v setjmp.3v ansic.7v bsd.7v posix.7v sunos.7 svidii.7v svidiii.7v xopen.7v

[a manual with the abbreviation PUL]

NOTES

Because cc does not generate or support 8-bit symbol names, it is inappropriate to make lint 8-bit clean. See cc.1v for an explanation about why cc is not 8-bit clean.

BUGS

There are some things you just cannot get lint to shut up about.

The routines exit.2v longjmp (see setjmp.3v and other functions that do not return are not understood; this causes various incorrect diagnostics.

Libraries created by the -C or -o options 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 still useful to produce stripped down lint library source files and to use them to generate lint libraries.


index | Inhaltsverzeichniss | Kommentar

Created by unroff & hp-tools. © somebody (See intro for details). All Rights Reserved. Last modified 11/5/97