1.\" Copyright (c) 1980, 1990 Regents of the University of California. 2.\" All rights reserved. The Berkeley Software License Agreement 3.\" specifies the terms and conditions for redistribution. 4.\" 5.\" @(#)lint.1 6.3 (Berkeley) 06/24/90 6.\" 7.Dd 8.Dt LINT 1 9.Os BSD 4 10.Sh NAME 11.Nm lint 12.Nd a C program verifier 13.Sh SYNOPSIS 14.Nm lint 15.Op Fl abchnpuvx 16.Ar file ... 17.Sh DESCRIPTION 18.Nm Lint 19attempts to detect features of the C program 20.Ar files 21which are 22likely to be bugs, or non-portable, or wasteful. 23It also checks the type usage of the program more strictly 24than the compilers. 25Among the things which are currently found are 26unreachable statements, 27loops not entered at the top, 28automatic variables declared and not used, 29and logical expressions whose value is constant. 30Moreover, the usage of functions is checked to find 31functions which return values in some places and not in others, 32functions called with varying numbers of arguments, 33and functions whose values are not used. 34.Pp 35By default, it is assumed that all the 36.Ar files 37are to be loaded together; they are checked for 38mutual compatibility. 39Function definitions for certain libraries are available to 40.Nm lint ; 41these libraries are referred to by a 42conventional name, 43such as `\-lm', in the style of 44.Xr ld 1 . 45Arguments ending in 46.Va .ln 47are also treated as library files. To create lint libraries, 48use the 49.Fl C 50option: 51.Pp 52.DL lint \-Cfoo files . . . 53.Pp 54where 55.Ar files 56are the C sources of library 57.Ar foo . 58The result is a file 59.Em llib-lfoo .ln 60in the correct library format suitable for linting programs 61using 62.Ar foo . 63.Pp 64Any number of the options in the following list 65may be used. 66The 67.Fl D 68.Fl U 69and 70.Fl I 71options of 72.Xr cc 1 73are also recognized as separate arguments. 74.Tp Fl p 75Attempt to check portability to the 76.Em IBM 77and 78.Em GCOS 79dialects of C. 80.Tp Fl h 81Apply a number of heuristic tests to attempt to 82intuit bugs, improve style, and reduce waste. 83.Tp Fl b 84Report 85.Ar break 86statements that cannot be reached. 87(This is not the default because, unfortunately, 88most 89.Xr lex 1 90and many 91.Xr yacc 1 92outputs produce dozens of such comments.) 93.Tp Fl v 94Suppress complaints about unused arguments in functions. 95.Tp Fl x 96Report variables referred to by extern declarations, 97but never used. 98.Tp Fl a 99Report assignments of long values to int variables. 100.Tp Fl c 101Complain about casts which have questionable portability. 102.Tp Fl u 103Do not complain about functions and variables used and not 104defined, or defined and not used (this is suitable for running 105.Nm lint 106on a subset of files out of a larger program). 107.Tp Fl n 108Do not check compatibility against the standard library. 109.Tp Fl z 110Do not complain about structures that are never defined (e.g. 111using a structure pointer without knowing its contents.). 112.Tp 113.Pp 114.Xr Exit 2 115and other functions which do not return 116are not understood; this causes various lies. 117.Pp 118Certain conventional comments in the C source 119will change the behavior of 120.Nm lint : 121.Tw Fl 122.Tp Li /*NOTREACHED*/ 123at appropriate points 124stops comments about unreachable code. 125.Tp Li /*VARARGS n */ 126suppresses 127the usual checking for variable numbers of arguments 128in the following function declaration. 129The data types of the first 130.Ar n 131arguments are checked; 132a missing 133.Ar n 134is taken to be 0. 135.Tp Li /*NOSTRICT*/ 136shuts off strict type checking in the next expression. 137.Tp Li /*ARGSUSED*/ 138turns on the 139.Fl v 140option for the next function. 141.Tp Li /*LINTLIBRARY*/ 142at the beginning of a file shuts off complaints about 143unused functions in this file. 144.Yp 145.Sh AUTHOR 146S.C. Johnson. Lint library construction implemented by Edward Wang. 147.Sh FILES 148.Dw /usr/libdata/lint/llib-port.ln 149.Di L 150.\" Pa /usr/libdata/lint/llib.ln 151.\" .Op 12 152.\" programs 153.Dp Pa /usr/libdata/lint/llib-lc.ln 154declarations for standard functions 155.Dp Pa /usr/libdata/lint/llib-lc 156human readable version of above 157.Dp Pa /usr/lib/lintdata/llib-port.ln 158declarations for portable functions 159.Dp Pa /usr/lib/lintdata/llib-port 160human readable . . . 161.Dp Pa llib-l*.ln 162library created with 163.Fl C 164.Dp 165.Sh SEE ALSO 166.Xr cc 1 167.br 168S. C. Johnson, 169.Em Lint , 170a C Program Checker 171.Sh HISTORY 172.Nm Lint 173appeared in Version 7 AT&T Unix. 174.Sh BUGS 175There are some things you just 176can't 177get lint to shut up about. 178.Pp 179/*NOSTRICT*/ 180is not implemented in the current version (alas). 181