lllliiiinnnntttt((((1111)))) SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss lllliiiinnnntttt((((1111)))) NNNNAAAAMMMMEEEE _llll_iiii_nnnn_tttt - a C program checker SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS _llll_iiii_nnnn_tttt _[[[[_o_p_t_i_o_n_s_]]]] _f_i_l_e_s DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN _llll_iiii_nnnn_tttt 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. _llll_iiii_nnnn_tttt 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. _llll_iiii_nnnn_tttt 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. Note that this version of lint may not be fully backwards compatible with older versions of lint. The older version became rather useless, since it did not support the ANSI C features supported by our C compiler _c_c(1). While this is an ANSI C lint, it does not exactly match the ANSI conformance modes of _c_c(1). In particular, it treats "long long" as "long" and emits a warning about the second "long", which is viewed as a redundant keyword. The __LONGLONG macro is not predefined in any of the language models (see the _----_XXXX options) supported by _llll_iiii_nnnn_tttt. To get lint like warnings with the full _c_c(1) language and options, we recommend use of the _c_c(1) option _----_wwww_llll_iiii_nnnn_tttt. Note that the error and warning messages from _llll_iiii_nnnn_tttt contain less detail than the _c_c(1) versions of these messages. Arguments whose names end with _...._cccc are taken to be C source files. Arguments whose names end with _...._llll_nnnn are taken to be the result of an earlier invocation of _llll_iiii_nnnn_tttt with either the _----_cccc or the _----_oooo option used. The _...._llll_nnnn files are analogous to _...._oooo (object) files that are produced by the _cccc_cccc(1) command when given a _...._cccc file as input. Files with other suffixes are warned about and ignored. _llll_iiii_nnnn_tttt takes all the _...._cccc, _...._llll_nnnn, and _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn (specified by _----_llll_x) files and processes them in their command line order. By default, _llll_iiii_nnnn_tttt appends the standard C lint library (_llll_llll_iiii_bbbb_----_llll_cccc_...._llll_nnnn) to the end of the list of files. When the _----_cccc option is used, the _...._llll_nnnn and the _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn files are ignored. When the _----_cccc option is not used, the second pass of _llll_iiii_nnnn_tttt checks the _...._llll_nnnn and the _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn list of files for mutual compatibility. Any number of _llll_iiii_nnnn_tttt options may be used, in any order, intermixed with file-name arguments. The following options are used to suppress certain kinds of complaints: _----_aaaa Suppress complaints about assignments of long values to variables that are not long. Page 1 Release 6.4 lllliiiinnnntttt((((1111)))) SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss lllliiiinnnntttt((((1111)))) _----_bbbb Suppress complaints about _bbbb_rrrr_eeee_aaaa_kkkk statements that cannot be reached. _----_hhhh Do not apply heuristic tests that attempt to intuit bugs, improve style, and reduce waste. _----_mmmm Suppress complaints about external symbols that could be declared static. _----_uuuu Suppress complaints about functions and external variables used and not defined, or defined and not used. (This option is suitable for running _llll_iiii_nnnn_tttt on a subset of files of a larger program). _----_vvvv Suppress complaints about unused arguments in functions. _----_xxxx Do not report variables referred to by external declarations but never used. The following arguments alter _llll_iiii_nnnn_tttt's behavior: _----_XXXX_cccc Strict ANSI C mode. Similar (but not identical) to the _----_aaaa_nnnn_ssss_iiii _c_c(1) mode. _----_XXXX_aaaa Extended ANSI C mode. Similar (but not identical) to the _----_xxxx_aaaa_nnnn_ssss_iiii _c_c(1) mode. This is the default mode. _----_XXXX_tttt Traditional C mode. __STDC__ is not predefined in this mode. Similar (but not identical) to the _----_cccc_cccc_kkkk_rrrr _c_c(1). mode. _----_YYYY_d_i_r Changes the standard default search directory, which normally is /_u_s_r/_i_n_c_l_u_d_e to be the directory given as an argument to this option. _----_IIII_d_i_r Search for included header files in the directory _d_i_r before searching the current directory and/or the standard place. _----_llll_x Include the lint library _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn. For example, you can include a lint version of the math library _llll_llll_iiii_bbbb_----_llll_mmmm_...._llll_nnnn by inserting _----_llll_mmmm on the command line. This argument does not suppress the default use of _llll_llll_iiii_bbbb_----_llll_cccc_...._llll_nnnn. 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. _----_LLLL_d_i_r Search for lint libraries in _d_i_r before searching the standard place. _----_nnnn Do not check compatibility against the standard C lint library. Page 2 Release 6.4 lllliiiinnnntttt((((1111)))) SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss lllliiiinnnntttt((((1111)))) _----_pppp Attempt to check portability to other dialects 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. _----_ssss Produce one-line diagnostics only. _llll_iiii_nnnn_tttt occasionally buffers messages to produce a compound report. _----_kkkk Alter the behavior of /*LINTED [_m_e_s_s_a_g_e]*/ directives. Normally, _llll_iiii_nnnn_tttt will suppress warning messages for the code following these directives. Instead of suppressing the messages, _llll_iiii_nnnn_tttt prints an additional message containing the comment inside the directive. _----_yyyy Specify that the file being linted will be treated as if the /*LINTLIBRARY*/ directive had been used. A lint library is normally created by using the /*LINTLIBRARY*/ directive. _----_FFFF Print pathnames of files. _llll_iiii_nnnn_tttt normally prints the filename without the path. _----_cccc Cause _llll_iiii_nnnn_tttt to produce a _...._llll_nnnn file for every _...._cccc file on the command line. These _...._llll_nnnn files are the product of _llll_iiii_nnnn_tttt's first pass only, and are not checked for inter-function compatibility. _----_oooo_x Cause _llll_iiii_nnnn_tttt to create a lint library with the name _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn. The _----_cccc option nullifies any use of the _----_oooo option. The lint library produced is the input that is given to _llll_iiii_nnnn_tttt's second pass. The _----_oooo option simply causes this file to be saved in the named lint library. To produce a _llll_llll_iiii_bbbb_----_llll_x_...._llll_nnnn without extraneous messages, use of the _----_xxxx option is suggested. The _----_vvvv 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). _----_dddd Verbose mode, which shows the options, predefined symbols, include paths, etc. that are passed to the lint1 and lint2 passes. _----_VVVV Write to standard error the product name and release. _llll_iiii_nnnn_tttt recognizes the _cccc_cccc(1) command line options _----_DDDD and _----_UUUU, silently ignores _----_gggg and _----_OOOO, while it ignores and warns about others. The predefined macro _llll_iiii_nnnn_tttt is defined to allow certain questionable code to be altered or removed for _llll_iiii_nnnn_tttt. Thus, the symbol _llll_iiii_nnnn_tttt should be thought of as a reserved word for all code that is planned to be checked by _llll_iiii_nnnn_tttt. Certain conventional comments in the C source will change the behavior of _llll_iiii_nnnn_tttt: /*ARGSUSED_n*/ makes _llll_iiii_nnnn_tttt check only the first _n arguments for usage; a missing _n is taken to be 0 (this option acts like the _----_vvvv option for the next function). Page 3 Release 6.4 lllliiiinnnntttt((((1111)))) SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss lllliiiinnnntttt((((1111)))) /*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 statements when a valid else statement follows. It suppresses messages on an empty _eeee_llll_ssss_eeee consequent. /*FALLTHRU*/ or /*FALLTHROUGH*/ suppresses complaints about fall through to a _cccc_aaaa_ssss_eeee or _dddd_eeee_ffff_aaaa_uuuu_llll_tttt 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 _----_vvvv and _----_xxxx options. /*LINTED [_m_e_s_s_a_g_e]*/ 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 _----_kkkk option alters the way in which _llll_iiii_nnnn_tttt handles this directive. Instead of suppressing messages, _llll_iiii_nnnn_tttt will print an additional message, if any, contained in the comment. This directive is useful in conjunction with the _----_ssss option for post-lint filtering. /*NOTREACHED*/ at appropriate points stops comments about unreachable code. [This comment is typically placed just after calls to functions like _eeee_xxxx_iiii_tttt(2)]. /*PRINTFLIKE_n*/ makes _llll_iiii_nnnn_tttt check the first (_n-_1) arguments as usual. The _n_t_h argument is interpreted as a _pppp_rrrr_iiii_nnnn_tttt_ffff format string that is used to check the remaining arguments. /*PROTOLIB_n*/ causes _llll_iiii_nnnn_tttt 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. /*SCANFLIKE_n*/ makes _llll_iiii_nnnn_tttt check the first (_n-_1) arguments as usual. The _n_t_h argument is interpreted as a _ssss_cccc_aaaa_nnnn_ffff format string that is used Page 4 Release 6.4 lllliiiinnnntttt((((1111)))) SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss lllliiiinnnntttt((((1111)))) 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 suggested in new or updated code. _llll_iiii_nnnn_tttt 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 _----_ssss is not specified. Finally, if the _----_cccc 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 _----_cccc and the _----_oooo options allows for incremental use of _llll_iiii_nnnn_tttt on a set of C source files. Generally, one invokes _llll_iiii_nnnn_tttt once for each source file with the _----_cccc option. Each of these invocations produces a _...._llll_nnnn file that corresponds to the _...._cccc file, and prints all messages that are about just that source file. After all the source files have been separately run through _llll_iiii_nnnn_tttt, it is invoked once more (without the _----_cccc option), listing all the _...._llll_nnnn files with the needed _----_llll_x options. This will print all the inter-file inconsistencies. This scheme works well with _mmmm_aaaa_kkkk_eeee; it allows _mmmm_aaaa_kkkk_eeee to be used to _llll_iiii_nnnn_tttt only the source files that have been modified since the last time the set of source files were _llll_iiii_nnnn_tttted. FFFFIIIILLLLEEEESSSS _R_O_O_T the directory used as the root of the default path for finding the lint libraries. _L_P_A_S_S_D_I_R the directory where the executables for passes 1 and 2 of lint must exist. If this environment variable is undefined, then the default path _////_uuuu_ssss_rrrr_////_llll_iiii_bbbb_////_llll_iiii_nnnn_tttt will be used to search for lint1 and lint2. _L_I_B_D_I_R the directory where the lint libraries specified by the _----_llll_x option must exist. If this environment variable is undefined, then the default path _////_uuuu_ssss_rrrr_////_llll_iiii_bbbb_////_llll_iiii_nnnn_tttt under _RRRR_OOOO_OOOO_TTTT will be used to search for the libraries. _L_P_A_S_S_D_I_R_////_llll_iiii_nnnn_tttt_[[[[_1111_2222_]]]] first and second passes of lint _L_I_B_D_I_R_////_llll_llll_iiii_bbbb_----_llll_cccc_...._llll_nnnn declarations for C Library functions (binary format; source is in _L_I_B_D_I_R_////_llll_llll_iiii_bbbb_----_llll_cccc_)))) Page 5 Release 6.4 lllliiiinnnntttt((((1111)))) SSSSiiiilllliiiiccccoooonnnn GGGGrrrraaaapppphhhhiiiiccccssss lllliiiinnnntttt((((1111)))) _L_I_B_D_I_R_////_llll_llll_iiii_bbbb_----_llll_mmmm_...._llll_nnnn declarations for Math Library functions (binary format; source is in _L_I_B_D_I_R/llib-lm) _T_M_P_D_I_R_////_****_llll_iiii_nnnn_tttt_**** temporaries _T_M_P_D_I_R usually _////_vvvv_aaaa_rrrr_////_tttt_mmmm_pppp but can be redefined by setting the environment variable _TTTT_MMMM_PPPP_DDDD_IIII_RRRR [see _tttt_eeee_mmmm_pppp_nnnn_aaaa_mmmm in _tttt_mmmm_pppp_nnnn_aaaa_mmmm(3S)]. SSSSEEEEEEEE AAAALLLLSSSSOOOO _cccc_cccc(1), _cccc_pppp_pppp(1), _mmmm_aaaa_kkkk_eeee(1). BBBBUUUUGGGGSSSS _e_x_i_t(2), _l_o_n_g_j_m_p(3C), and other functions that do not return are not understood; this causes various lies. Page 6 Release 6.4