lint.1 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. .\" (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  2. .\" See the copyright notice in the ACK home directory, in the file "Copyright".
  3. .\"
  4. .\" $Header$
  5. .TH LINT 1 "$Revision$"
  6. .SH NAME
  7. lint \- a C program checker
  8. .SH SYNOPSIS
  9. .B lint
  10. [ \-abhuvx \-KR -ansi ] [file | libname | \-l\fIxxx\fP ] ...
  11. .br
  12. .B lint
  13. \-L\fIlibname\fP [ file | libname2 | \-l\fIxxx\fP ] ...
  14. .br
  15. .SH DESCRIPTION
  16. .I Lint
  17. does an extensive consistency and plausibility check on a set of C
  18. program files.
  19. When it detects a doubtful construction
  20. (which need not be an error) it gives a warning.
  21. .PP
  22. It does a full flow-of-control check, except that
  23. .BR goto s
  24. are not followed and that the fact that a function never returns
  25. is not propagated.
  26. If, however, no
  27. .BR goto s
  28. are used, each call of a non-returning function is followed by
  29. /*NOTREACHED*/ and each switch has a default clause (possibly consisting
  30. of /*NOTREACHED*/), the initialization state of all local variables will
  31. be checked correctly.
  32. .PP
  33. .I Lint
  34. checks the types of the arguments implied by the format in a call of
  35. .IR printf() ,
  36. .IR scanf()
  37. and family, if the format string is a direct argument in the call.
  38. Formats of user functions can be indicated using a FORMAT pseudo-comment; see
  39. below.
  40. .PP
  41. .I Libraries
  42. .PP
  43. The second command (using the
  44. .BR \-L -option)
  45. is used to maintain lint libraries; these are ASCII files
  46. that contain the output of the first pass.
  47. A library name ends in
  48. .BR .llb .
  49. A lint user library can be created and updated by using the
  50. .B \-L
  51. option. The
  52. .I libname
  53. end in
  54. .BR .llb ,
  55. and can be passed to
  56. .I lint
  57. again as a normal argument.
  58. .PP
  59. Standard libraries are searched by default or by explicitly giving the
  60. .B \-l
  61. option; their format is identical to that of the user library files.
  62. Possibilities are
  63. .BR \-lm ,
  64. .B \-ltermcap
  65. and
  66. .BR \-lcurses .
  67. .B \-lc
  68. is default; a single
  69. .B \-l
  70. tells
  71. .I lint
  72. not to use the standard C library.
  73. The standard libraries are searched for in the standard lint directory or
  74. in the directory given in the environment variable LINTLIB, if present.
  75. .PP
  76. .I Options
  77. .PP
  78. The
  79. .BR \-D ,
  80. .B \-U
  81. and
  82. .B \-I
  83. options are recognized as separate arguments and conform to those of
  84. .IR cc .
  85. The
  86. .B \-KR
  87. option tells
  88. .I lint
  89. to check strictly according to Kernighan & Ritchie; since
  90. .I lint
  91. is trying to be helpful rather than obnoxious, this is not the default.
  92. The
  93. .B \-ansi
  94. option tells lint to check according to ANSI C.
  95. .PP
  96. .I Lint
  97. understands the following additional options:
  98. .TP
  99. .B a
  100. Warn about conversions that may cause a loss of precision.
  101. .TP
  102. .B b
  103. Do not report not-reachable
  104. .I break
  105. statements.
  106. This flag may be useful when
  107. .I lint
  108. is run on a generated source file.
  109. .TP
  110. .B h
  111. Apply several heuristics:
  112. signal "null effects", possible pointer alignment problems and odd
  113. constructs; report definitions of variables that have a scope wider than
  114. necessary: extern variables that are used in one file only, automatic
  115. variables that could be more local.
  116. .TP
  117. .B u
  118. Do not complain about unused and undefined functions and global variables.
  119. .TP
  120. .B v
  121. Do not warn about unused arguments of functions.
  122. .TP
  123. .B x
  124. Complain about unused external variables.
  125. .PP
  126. .I Pseudo-comments
  127. .PP
  128. The following pseudo-comments can be used to influence the behaviour of
  129. .IR lint:
  130. .TP
  131. /*\ ARGSUSED\ */
  132. Do not warn about arguments not used in the next function
  133. (see also the \-\fBv\fR option).
  134. .TP
  135. /*\ NOTREACHED\ */
  136. This tells
  137. .I lint
  138. that the flow of control "cannot reach" this comment.
  139. This is a way to tell
  140. .I lint
  141. that a statement never "returns".
  142. .TP
  143. /*\ LINTLIBRARY\ */
  144. The definitions following this pseudo-comment are assumed to be part of a
  145. library.
  146. It suppresses complaints about unused functions and variables
  147. and is used in the creation of lint libraries.
  148. It implies /*\ ARGSUSED\ */.
  149. .TP
  150. /*\ VARARGS\fIn\fR\ */
  151. The next function can be called with a variable number of
  152. arguments.
  153. Only check the types of the first \fIn\fR arguments.
  154. The \fIn\fR must follow the word VARARGS immediately.
  155. /*\ VARARGS0\ */ may be abbreviated to /*\ VARARGS\ */.
  156. .TP
  157. /*\ FORMAT\fIn\fR $ ... $\ */
  158. The \fIn\fP-th argument (counting from 0) of the next function declaration
  159. corresponds to a
  160. .IR printf -like
  161. format string. Details about the format are given between the $$; see below.
  162. A missing $$ repeats the latest format.
  163. The \fIn\fR must follow the word FORMAT immediately.
  164. /*\ FORMAT\fIn\fR $ ... $\ */ implies /*\ VARARGS\fIn+1\fP\ */; if the format
  165. is followed by more required arguments, a separate /*\ VARARGS\fIm\fP\ */
  166. must be given after the FORMAT pseudo-comment.
  167. .IP
  168. If the printf-like heading also has to conform to some varargs.h convention,
  169. error messages may result; these can be suppressed by appending the letter v
  170. to the word FORMAT\fIn\fR without intervening space.
  171. .PP
  172. .I Formats
  173. .PP
  174. The $$-part of the FORMAT pseudo-comment consists of a list of format
  175. specifications, each of the form
  176. .IR %T = type ,
  177. where
  178. .I T
  179. is an arbitrary (short) string and
  180. .I type
  181. is the expected type in "C normal form" (like in a cast, with no superfluous
  182. parentheses and without the use of typedefs). E.g., %ld=long indicates that
  183. the format string ld corresponds to a parameter of type long. For a shorter
  184. notation see the example below.
  185. .I Lint
  186. recognizes conversion specifications of the form %[N|*|][.[N|*]]T where N is
  187. a number, the * is itself and T is a string as defined above. For the above
  188. example this would include %ld, %5.2ld, %.*ld, etc.
  189. .PP
  190. Example: the FORMAT pseudo-comment for
  191. .I printf()
  192. is:
  193. .br
  194. /*\ FORMAT0 $
  195. .br
  196. %[dox] = int %l[dox] = long %[DOX] = long
  197. .br
  198. %u = unsigned int %lu = unsigned long %U = unsigned long
  199. .br
  200. %[feg] = double
  201. .br
  202. %c = int %s = char *
  203. .br
  204. $\ */
  205. .PP
  206. .I Output
  207. .PP
  208. Some users feel it is a good idea to pipe the output of
  209. .I lint
  210. through the command
  211. .br
  212. sort \-t' ' +0d \-1 +2n \-3
  213. .br
  214. where the character between the apostrophes is a space.
  215. .SH "ENVIRONMENT VARIABLES"
  216. LINTFLAGS additional flag arguments (e.g. LINTFLAGS=\-h)
  217. .br
  218. LINTLIB directory in which the standard libraries are looked up
  219. .SH FILES
  220. .IP ???/lnt 24
  221. first pass
  222. .IP ???/lpass2/lpass2
  223. second pass
  224. .IP ???/llib/*.llb
  225. lint libraries
  226. .SH SEE ALSO
  227. cem(1)
  228. .br
  229. Frans Kunst,
  230. .I Lint, a C Program Checker
  231. .SH BUGS
  232. Conflicting options in the command line are not detected.
  233. .br
  234. After a label, all automatic variables are assumed initialized.
  235. .SH AUTHOR
  236. Frans Kunst, Vrije Universiteit, Amsterdam.
  237. .br
  238. Dick Grune, Vrije Universiteit, Amsterdam.
  239. .br