Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ rlint(CP) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cpp(CP)

make(CP)

rcc(CP)


 rlint(CP)                      6 January 1993                      rlint(CP)


 Name

    rlint - a C program checker

 Syntax

    rlint [ option ] ... file ...

 Description

    The rlint command attempts to detect features of 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.

    rlint is based on the AT&T compiler rcc, and does not accept either the
    ANSI or Microsoft dialects of the C language.  For checking programs
    written with either of these dialects, use the lint command (see the
    lint(CP) manual page).

    Arguments whose names end with .c are taken to be C source files.  Argu-
    ments whose names end with .rln are taken to be the result of an earlier
    invocation of rlint with either the -c or the -o option used.  The .rln
    files are analogous to .o (object) files that are produced by the rcc(CP)
    command when given a .c file as input.  Files with other suffixes are
    warned about and ignored.

    The rlint command will take all the .c, .rln, and llib-lx.rln (specified
    by -lx) files and process them in their command line order.  By default,
    rlint appends the standard C rlint library (llib-lc.rln) to the end of
    the list of files.  However, if the -p option is used, the portable C
    rlint library (llib-port.rln) is appended instead.  When the -c option is
    not used, the second pass of rlint checks this list of files for mutual
    compatibility.  When the -c option is used, the .rln and the llib-lx.rln
    files are ignored.

    Any number of rlint 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 com-
        plaints.)

    -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 rlint 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 rlint's behavior:

    -c  Cause rlint to produce a .rln file for every .c file on the command
        line.  These .rln files are the product of rlint's first pass only,
        and are not checked for inter-function compatibility.

    -lx Include additional rlint library llib-lx.rln. For example, you can
        include a rlint version of the math library llib-lm.rln by inserting
        -lm on the command line.  This argument does not suppress the default
        use of llib-lc.rln.  These rlint libraries must be in the assumed
        directory.  This option can be used to reference local rlint
        libraries and is useful in the development of multifile projects.

    -n  Do not check compatibility against either the standard or the port-
        able rlint library.

    -o lib
        Cause rlint to create a rlint library with the name llib-llib.rln.
        The -c option nullifies any use of the -o option.  The rlint library
        produced is the input that is given to rlint's second pass.  The -o
        option simply causes this file to be saved in the named rlint
        library.  To produce a llib-llib.rln without extraneous messages, use
        of the -x option is suggested.  The -v option is useful if the source
        file(s) for the rlint library are just external interfaces (for exam-
        ple, the way the file llib-lc is written).  These option settings are
        also available through the use of ``rlint comments'' (see below).

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

    The -D, -U, and -I options of cpp(CP) and the -g and -O options of
    rcc(CP) are also recognized as separate arguments.  The -g and -O options
    are ignored, but, by recognizing these options, rlint's behavior is
    closer to that of the rcc(CP) command.  Other options are warned about
    and ignored.  The preprocessor symbols ``lint'' and ``__lint'' are
    defined to allow certain questionable code to be altered or removed for
    rlint.  Therefore, the symbols ``lint'' and ``__lint'' should be thought
    of as reserved words for all code that you plan to check with rlint.

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

       /*ARGSUSED*/
          Turns on the -v option for the next function.

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

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

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

    The rlint command 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
    rlint on a set of C source files.  Generally, one invokes rlint once for
    each source file with the -c option.  Each of these invocations produces
    a .rln file for each .c file, and prints all messages that are about just
    that source file.  After all the source files have been separately run
    through rlint, it is invoked once more (without the -c option), listing
    all the .rln files with the needed -lx options.  This will print all the
    interfile inconsistencies.  This scheme works well with make(CP); it
    allows make to be used to rlint only the source files that have been
    modified since the last time the set of source files were rlinted.

 Files


    LLIBDIR                the directory where the rlint libraries specified
                           by the -lx option must exist, usually /usr/lib.

    LLIBDIR/rlint[12]      first and second passes

    LLIBDIR/llib-lc.rln    declarations for C Library functions (binary for-
                           mat; source is in LLIBDIR/llib-lc.c)

    LLIBDIR/llib-port.rln  declarations for portable functions (binary for-
                           mat; source is in LLIBDIR/llib-port.c)

    LLIBDIR/llib-lm.rln    declarations for Math Library functions (binary
                           format; source is in LLIBDIR/llib-lm.c)

    TMPDIR/*rlint*         temporaries

    TMPDIR                 usually /usr/tmp but can be redefined by setting
                           the environment variable TMPDIR (see tempnam() in
                           tmpnam(S)).

 Notes

    exit(S), setjmp(S), and other functions that do not return are not under-
    stood; this causes various mistaken diagnoses.

 See also

    cpp(CP), make(CP), rcc(CP)

 Standards conformance

    rlint is conformant with:
    AT&T SVID Issue 2;
    and X/Open Portability Guide, Issue 3, 1989.


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