Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought



lint(1)                  MAXION/OS 1.2v9                  lint(1)



NAME
     lint - a C program checker

SYNOPSIS
     lint [options] 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 detects are
     unreachable  statements,  loops  not  entered  at  the  top,
     automatic  variables  declared  and  not  used,  and logical
     expressions whose value is constant.  lint checks for  func-
     tions  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 not returned.

     Arguments that 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 suffixes are
     warned about and ignored.

     lint takes all the .c, .ln,  and  llib-lx.ln  (specified  by
     -lx)  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 compati-
     bility.

     Any number of lint options may be used in any order,  inter-
     mixed 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.

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

     -m   Suppress complaints about external symbols  that  could



                                                                1





lint(1)                  MAXION/OS 1.2v9                  lint(1)



          be declared static.

     -u   Suppress complaints about functions and external  vari-
          ables  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  func-
          tions.

     -x   Do  not  report  variables  referred  to  by   external
          declarations but never used.
     The following arguments alter lint's behavior:

     -Idir
          Search for included header files in the  directory  dir
          before searching the current directory and/or the stan-
          dard place.

     -lx  Include the lint library llib-lx.ln.  For example,  you
          can  include  a  lint version of the math library llib-
          lm.ln by inserting -lm on the command line.  This argu-
          ment  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  multi-
          file projects.

     -Ldir
          Search for lint libraries in dir before  searching  the
          standard place.

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

     -p   Attempt to check portability to other machines.   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   Produce one-line diagnostics only.   lint  occasionally
          buffers messages to produce a compound report.

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

     -y   Specify that the file being linted will be  treated  as
          if the /*LINTLIBRARY*/ directive had been used.  A lint



                                                                2





lint(1)                  MAXION/OS 1.2v9                  lint(1)



          library  is  normally  created  by  using  the  /*LINT-
          LIBRARY*/ 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.

     -ox  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 file(s) for the lint library are
          just external interfaces.

Some of the above settings are also available through
the use of ``lint comments'' (see below).
-V Write to standard error the product name and release.
-Wfile
Write a .ln file to file, for use by cflow(1).
-Rfile
Write a .ln file to file, for use by cxref(1).
-YD,dir
Search in the directory dir for the file
lint_defaultops which contains the standard definitions
to be set (as if by the -D option).
-Yp1,dir
Search in the directory dir for the lint1 executable
for the first pass.
-Yp2,dir
Search in the directory dir for the lint2 executable
for the second pass.
-Yc,dir
Search in the directory dir for the llib-lc.ln standard
C lint library.
-Yinstall,dir
Search in the directory dir for the files
lint_defaultops, lint1, and lint2.
3


lint(1)                  MAXION/OS 1.2v9                  lint(1)



     lint recognizes many cc(1) command line  options,  including
     -D,  -U,  -g,  -O, -Xt, -Xa, and -Xc, although -g and -O are
     ignored.  Unrecognized options are warned about and ignored.
     The  predefined  macro  lint  is  defined  to  allow certain
     questionable code to be altered or removed for lint.   Thus,
     the  symbol lint should be thought of as a reserved word for
     all code that is planned to be checked by lint.

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

     /*ARGSUSEDn*/
          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 expression, and  before  the  semicolon.
          This  directive  is supplied to support empty if state-
          ments  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 directive.   Instead
          of  suppressing messages, lint will print an additional
          message, if any, contained in the comment.  This direc-
          tive  is  useful  in conjunction with the -s option for
          post-lint filtering.

     /*NOTREACHED*/
          at appropriate points stops comments about  unreachable
          code.   [This  comment  is  typically placed just after



                                                                4





lint(1)                  MAXION/OS 1.2v9                  lint(1)



          calls to functions like exit(2)].

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

     /*PROTOLIBn*/
          causes lint to treat function declaration prototypes as
          function  definitions if n is non-zero.  This directive
          can only be used in conjunction with the /* LINTLIBRARY
          */  directive.   If n is zero, function prototypes will
          be treated normally.

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

     /*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 use of the ellipsis
          terminator (. . .) in the definition  is  suggested  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  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 filename will be
     printed followed by a question mark.

     The behavior of the -c and the -o options allows for  incre-
     mental  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 .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; 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.





                                                                5





lint(1)                  MAXION/OS 1.2v9                  lint(1)



FILES
     LIBDIR                  the   directory   where   the   lint
                             libraries   specified   by  the  -lx
                             option must exist
     LIBDIR/lint[12]         first and second passes
     LIBDIR/lint_defaultopts standard definitions file
     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  func-
                             tions  (binary  format; source is in
                             LIBDIR/llib-lm)
     TMPDIR/*lint*           temporaries
     TMPDIR                  usually /var/tmp but  can  be  rede-
                             fined  by  setting  the  environment
                             variable  TMPDIR  [see  tempnam   in
                             tmpnam(3S)].
     LIBDIR                  usually /ccs/lib
     LIBPATH                 usually /usr/ccs/lib:/usr/lib

REFERENCES
     cc(1), make(1)

NOTICES
     Modified, August 1996






























                                                                6



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