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