Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lint(1) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

cflow(1)

cxref(1)

lex(1)

make(1)

yacc(1)

lint(1)

lint(1)                                                             lint(1)

NAME
     lint - check C programs

SYNOPSIS
     lint [option... ] file...

DESCRIPTION
     lint detects features of C program files which are likely to be bugs,
     non-portable, or wasteful. It also checks type usage more strictly
     than the compiler. lint issues error and warning messages. Among the
     things it checks for are unreachable code, loops not entered at the
     top, automatic variables declared and not used, and logical expres-
     sions whose value is constant. lint checks for 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 suf-
     fixes are warned about and ignored.

     lint takes all the .c, .ln, and llib-lx.ln (specified by -l x) files
     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. When the -c option is used, the .ln and the llib-lx.ln files
     are ignored. When the -c option is not used, the second pass of lint
     checks the .ln and the llib-lx.ln list of files for mutual compatibil-
     ity.

OPTIONS
     The following options are used to suppress certain kinds of com-
     plaints:

     -a   Suppress complaints about assignments of long values to variables
          that are not long.

     -b   Suppress complaints about break statements that cannot be
          reached.

     -h   Do not apply heuristic tests that attempt to intuit bugs, improve
          style, and reduce waste.

     -m   Suppress complaints about external symbols that could be declared
          static.

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




Page 1                       Reliant UNIX 5.44                Printed 11/98

lint(1)                                                             lint(1)

     -v   Suppress complaints about unused arguments in functions.

     -x   Do not report variables referred to by external declarations but
          never used.

     The following options alter lint's behavior:

     -l x Include the lint library llib-lx.ln

          For example, you can include a lint version of the math library
          llib-lm.ln by inserting -l m on the command line. This argument
          does not suppress the default use of llib-lc.ln. These lint
          libraries must be in the directory provided for them. This option
          can be used to reference local lint libraries and is useful in
          the development of multi-file projects. The sequence of the
          specified -l options is significant, as the libraries are pro-
          cessed in this sequence.

     -n   Do not check compatibility against the standard C lint library.

     -p   Attempt to check portability to other dialects of C Along with
          stricter checking, this option causes all nonexternal names to be
          truncated to eight characters and all external names to be trun-
          cated to six characters and one case.

     -s   Produce one-line diagnostics only. lint occasionally buffers mes-
          sages to produce a compound report.

     -k   Alter the behavior of /* LINTED [message] */ directives. Nor-
          mally, lint will suppress warning messages for the code following
          these directives. Instead of suppressing the messages, lint
          prints an additional message containing the comment inside the
          directive.

     -y   Specifies that the file being linted will be treated as if the
          /* LINTLIBRARY */ directive had been used. A lint library is nor-
          mally created by using the /* LINTLIBRARY */ directive.

     -F   Print pathnames of files lint normally prints the filename
          without the path.

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










Page 2                       Reliant UNIX 5.44                Printed 11/98

lint(1)                                                             lint(1)

     -o x Cause lint to create a lint library with the name llib-lx.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-lx.ln without extraneous messages, use
          of the -x option is suggested. The -v option is useful if the
          source files for the lint library are just external interfaces.

     -V   Write to standard error the product name and release.

     -W file
          Write a .ln file to file, for use by cflow(1).

     -R file
          Write a .ln file to file.lnt, for use by cxref(1).

     --   If the first filename begins with a dash (-), the end of the
          command-line options must be marked with --.

     lint recognizes many cc options, such as -D, -U, -I, -L, -g, -O, -Xt,
     -Xa, and -Xc, although -g and -O are ignored. If other options are
     used, a warning is issued and they are ignored.
































Page 3                       Reliant UNIX 5.44                Printed 11/98

lint(1)                                                             lint(1)

     Certain conventional comments in the C source can influence the
     behavior of lint:

     /* ARGSUSED n */
          makes lint check only the first n arguments for usage; a missing
          n is taken to be 0. This option acts like the -v option for the
          next function.

     /* CONSTCOND */ or /* CONSTANTCOND */ or /* CONSTANTCONDITION */
          suppresses complaints about constant operands for the next
          expression.

     /* EMPTY */
          suppresses complaints about a null statement consequent on an if
          statement. This directive should be placed after the test expres-
          sion, and before the semicolon. This directive is supplied to
          support empty if statements when a valid else statement follows.
          It suppresses messages on an empty else consequent.

     /* FALLTHRU */ or /* FALLTHROUGH */
          suppresses complaints about fall through to a case or default
          labeled statement. This directive should be placed immediately
          preceding the label.

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

     / *LINTED [message] */
          suppresses any intra-file warning except those dealing with
          unused variables or functions. This directive should be placed on
          the line immediately preceding where the lint warning occurred.
          The -k option alters the way in which lint handles this direc-
          tive. Instead of suppressing messages, lint will print an addi-
          tional message, if any, contained in the comment. This directive
          is useful in conjunction with the -s option for post-lint filter-
          ing.

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

     /* PRINTFLIKE n */
          makes lint check the first (n-1) arguments as usual. The nth
          argument is interpreted as a printf format string to check the
          remaining arguments.

     /* PROTOLIB n */
          causes lint to treat function declaration prototypes as function
          definitions if n is non-zero. This directive can only be used in


Page 4                       Reliant UNIX 5.44                Printed 11/98

lint(1)                                                             lint(1)

          conjunction with the /* LINTLIBRARY */ directive. If n is zero,
          function prototypes will be treated normally.

     /* SCANFLIKE n */
          makes lint check the first (n-1) arguments as usual. The nth
          argument is interpreted as a scanf format string to check the
          remaining arguments.

     /* VARARGS n */
          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. The
          use of the ellipsis terminator (...) in the definition is sug-
          gested in new or updated code.

     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, if -s is not specified. Finally, if the -c
     option is not used, information gathered from all input files is col-
     lected 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 filename 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 that corresponds to the 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
     -l x options. This will print all the inter-file inconsistencies. This
     scheme works well with make; 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.




















Page 5                       Reliant UNIX 5.44                Printed 11/98

lint(1)                                                             lint(1)

NOTES
     lint is tailored for the PCC C compiler. However, lint can also be
     used to check programs that are to be compiled using the CES C com-
     piler; but when it is so used, not all of the warnings which are out-
     put will be meaningful.

LOCALE
     The language of the message texts is governed by the environment vari-
     able LCALL, LCMESSAGES or LANG.

     When the default is set, the system behaves as if it were not interna-
     tionalized, i.e. the message texts are in English. You must change one
     of these variables in order to change the language of the message
     texts.

     Detailed information on the dependencies of the environment variables
     and on internationalization in general can be found in the manual
     "Programmer's Guide: Internationalization - Localization". Refer also
     to environ(5) for information on setting the user environment.

FILES
     LIBDIR
          the directory where the lint libraries specified by the -lx
          option must exist

     LIBDIR/lint[12]
          first and second passes

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

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

     TMPDIR/*lint*
          temporary files

     MPDIR
          usually /var/tmp but can be redefined by setting the environment
          variable TMPDIR [see tempnam in tempnam(3S)].

     LIBDIR
          usually /ccs/lib

     LIBPATH
          usually /usr/ccs/lib:/usr/lib

SEE ALSO
     cc(1), cflow(1), cxref(1), lex(1), make(1), yacc(1).



Page 6                       Reliant UNIX 5.44                Printed 11/98

lint(1)                                                             lint(1)

     Chapter on "lint" in the "Guide to Tools for Programming in C".





















































Page 7                       Reliant UNIX 5.44                Printed 11/98

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