143705Scael.\" Copyright (c) 1980, 1990 Regents of the University of California. 2*50837Scael.\" All rights reserved. 319171Smckusick.\" 4*50837Scael.\" %sccs.include.proprietary.roff% 519171Smckusick.\" 6*50837Scael.\" @(#)lint.1 6.6 (Berkeley) 08/09/91 7*50837Scael.\" 843705Scael.Dd 943705Scael.Dt LINT 1 1043705Scael.Os BSD 4 1143705Scael.Sh NAME 1243705Scael.Nm lint 13*50837Scael.Nd "a C program verifier" 1443705Scael.Sh SYNOPSIS 1543705Scael.Nm lint 1643705Scael.Op Fl abchnpuvx 1743705Scael.Ar file ... 1843705Scael.Sh DESCRIPTION 1943705Scael.Nm Lint 2019171Smckusickattempts to detect features of the C program 2143705Scael.Ar files 2219171Smckusickwhich are 2319171Smckusicklikely to be bugs, or non-portable, or wasteful. 2419171SmckusickIt also checks the type usage of the program more strictly 2519171Smckusickthan the compilers. 2619171SmckusickAmong the things which are currently found are 2719171Smckusickunreachable statements, 2819171Smckusickloops not entered at the top, 2919171Smckusickautomatic variables declared and not used, 3019171Smckusickand logical expressions whose value is constant. 3119171SmckusickMoreover, the usage of functions is checked to find 3219171Smckusickfunctions which return values in some places and not in others, 3319171Smckusickfunctions called with varying numbers of arguments, 3419171Smckusickand functions whose values are not used. 3543705Scael.Pp 3619171SmckusickBy default, it is assumed that all the 3743705Scael.Ar files 3819171Smckusickare to be loaded together; they are checked for 3919171Smckusickmutual compatibility. 4019171SmckusickFunction definitions for certain libraries are available to 4143705Scael.Nm lint ; 4219171Smckusickthese libraries are referred to by a 4319171Smckusickconventional name, 4419171Smckusicksuch as `\-lm', in the style of 4543705Scael.Xr ld 1 . 4619172SmckusickArguments ending in 4743705Scael.Va .ln 4819172Smckusickare also treated as library files. To create lint libraries, 4919172Smckusickuse the 5043705Scael.Fl C 5119172Smckusickoption: 5243705Scael.Pp 5344952Scael.Dl lint \-Cfoo files . . . 5443705Scael.Pp 5519172Smckusickwhere 5643705Scael.Ar files 5719172Smckusickare the C sources of library 5843705Scael.Ar foo . 5919172SmckusickThe result is a file 60*50837Scael.Pa llib-lfoo .ln 6119172Smckusickin the correct library format suitable for linting programs 6219172Smckusickusing 6343705Scael.Ar foo . 6443705Scael.Pp 6519171SmckusickAny number of the options in the following list 6619171Smckusickmay be used. 6719171SmckusickThe 68*50837Scael.Fl D , 6943705Scael.Fl U 7019171Smckusickand 7143705Scael.Fl I 7219171Smckusickoptions of 7343705Scael.Xr cc 1 7419171Smckusickare also recognized as separate arguments. 75*50837Scael.Bl -tag -width flag 76*50837Scael.It Fl p 7719171SmckusickAttempt to check portability to the 78*50837Scael.Tn IBM 7919171Smckusickand 80*50837Scael.Tn GCOS 8119171Smckusickdialects of C. 82*50837Scael.It Fl h 8319171SmckusickApply a number of heuristic tests to attempt to 8419171Smckusickintuit bugs, improve style, and reduce waste. 85*50837Scael.It Fl b 8619171SmckusickReport 8743705Scael.Ar break 8819171Smckusickstatements that cannot be reached. 8919171Smckusick(This is not the default because, unfortunately, 9019171Smckusickmost 9143705Scael.Xr lex 1 9219171Smckusickand many 9343705Scael.Xr yacc 1 9419171Smckusickoutputs produce dozens of such comments.) 95*50837Scael.It Fl v 9619171SmckusickSuppress complaints about unused arguments in functions. 97*50837Scael.It Fl x 9819171SmckusickReport variables referred to by extern declarations, 9919171Smckusickbut never used. 100*50837Scael.It Fl a 10119171SmckusickReport assignments of long values to int variables. 102*50837Scael.It Fl c 10319171SmckusickComplain about casts which have questionable portability. 104*50837Scael.It Fl u 10519171SmckusickDo not complain about functions and variables used and not 10619171Smckusickdefined, or defined and not used (this is suitable for running 10743705Scael.Nm lint 10819171Smckusickon a subset of files out of a larger program). 109*50837Scael.It Fl n 11019171SmckusickDo not check compatibility against the standard library. 111*50837Scael.It Fl z 11219172SmckusickDo not complain about structures that are never defined (e.g. 11319172Smckusickusing a structure pointer without knowing its contents.). 114*50837Scael.El 11543705Scael.Pp 11643705Scael.Xr Exit 2 11719171Smckusickand other functions which do not return 11819171Smckusickare not understood; this causes various lies. 11943705Scael.Pp 12019171SmckusickCertain conventional comments in the C source 12119171Smckusickwill change the behavior of 12243705Scael.Nm lint : 123*50837Scael.Bl -tag -width Ds 124*50837Scael.It Li /*NOTREACHED*/ 12519171Smckusickat appropriate points 12619171Smckusickstops comments about unreachable code. 127*50837Scael.It Li /*VARARGS n */ 12819171Smckusicksuppresses 12919171Smckusickthe usual checking for variable numbers of arguments 13019171Smckusickin the following function declaration. 13119171SmckusickThe data types of the first 13243705Scael.Ar n 13319171Smckusickarguments are checked; 13419171Smckusicka missing 13543705Scael.Ar n 13619171Smckusickis taken to be 0. 137*50837Scael.It Li /*NOSTRICT*/ 13819171Smckusickshuts off strict type checking in the next expression. 139*50837Scael.It Li /*ARGSUSED*/ 14019171Smckusickturns on the 14143705Scael.Fl v 14219171Smckusickoption for the next function. 143*50837Scael.It Li /*LINTLIBRARY*/ 14419171Smckusickat the beginning of a file shuts off complaints about 14519171Smckusickunused functions in this file. 14643705Scael.Sh AUTHOR 14719172SmckusickS.C. Johnson. Lint library construction implemented by Edward Wang. 14843705Scael.Sh FILES 149*50837Scael.Bl -tag -width /usr/libdata/lint/llib-port.ln -compact 150*50837Scael.It Pa /usr/libdata/lint/llib-lc.ln 151*50837ScaelDeclarations for standard functions. 152*50837Scael.It Pa /usr/libdata/lint/llib-lc 153*50837ScaelHuman readable version of above. 154*50837Scael.It Pa /usr/lib/lintdata/llib-port.ln 155*50837ScaelDeclarations for portable functions. 156*50837Scael.It Pa /usr/lib/lintdata/llib-port 157*50837ScaelHuman readable. 158*50837Scael.It Pa llib-l*.ln 159*50837ScaelLibrary created with 160*50837Scael.Fl C . 161*50837Scael.El 16243705Scael.Sh SEE ALSO 16343705Scael.Xr cc 1 164*50837Scael.Rs 165*50837Scael.%A S. C. Johnson, 166*50837Scael.%T "Lint, a C Program Checker" 167*50837Scael.Re 16843705Scael.Sh HISTORY 169*50837ScaelThe 170*50837Scael.Nm lint 171*50837Scaelprogram appeared in 172*50837Scael.At v7 . 17343705Scael.Sh BUGS 17419171SmckusickThere are some things you just 17543705Scaelcan't 17619171Smckusickget lint to shut up about. 17743705Scael.Pp 178*50837Scael.Li /*NOSTRICT*/ 17926901Sdonnis not implemented in the current version (alas). 180