Consistency checks
Inconsistent use of variables, arguments, and functions
is checked within files as well as across them.
Generally speaking, the same checks are performed for
prototype uses, declarations, and parameters as
for old-style functions.
(If your program does not use function prototypes, lint
will check the number and types of parameters in each call
to a function more strictly than the compiler.)
lint also identifies mismatches of conversion
specifications and arguments in [fs]printf()
and [fs]scanf() control strings.
Examples:
-
Within files, lint flags non void functions
that ``fall off the bottom'' without returning
a value to the invoking function.
In the past, programmers often indicated that a
function was not meant to return a value by
omitting the return type: fun() {}.
That convention means nothing to the compiler,
which regards fun() as having the return
type int.
Declare the function with the return type void
to eliminate the problem.
-
Across files, lint detects cases where a
non void function does not return a value,
yet is used for its value in an expression,
and the opposite problem,
a function returning a value that is sometimes
or always ignored in subsequent calls.
When the value is always ignored, it may indicate
an inefficiency in the function definition.
When it is sometimes ignored, it's probably
bad style (typically, not testing for error conditions).
If you do not need to check the return values of string functions
like strcat(), strcpy(), and sprintf(),
or output
functions like printf() and putchar(),
cast the offending
call(s) to void.
-
lint identifies variables or functions that are declared
but not used or defined; used but not defined;
or defined but not used.
That means that when lint is applied
to some, but not all files of a collection
to be loaded together, it will complain about
functions and variables declared in those
files but defined or used elsewhere; used
there but defined elsewhere; or defined there
and used elsewhere.
Invoke the -x option to suppress the former
complaint, -u to suppress the latter two.
Next topic:
Portability checks
Previous topic:
What lint does
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003