Intel XENIX 286 Programmers Guide (86) - Tenox.tc
Intel XENIX 286 Programmers Guide (86) - Tenox.tc Intel XENIX 286 Programmers Guide (86) - Tenox.tc
XENIX Programming lint: C Program Checker Checking for Infin ite Loops The lint program checks for infinite loops and for loops that are never executed. For example, the statements and while (1) {} for (;;) {} are both considered infinite loops. While the statements and while (0) {} for (;0;) {} are never executed. Although some valid programs have such loops, they are generally considered errors. Checking Function Return Values The lint program checks that a function returns a meaningful value if necessary. Some functions return values that are never used; some programs incorrectly use function values that have never been returned. lint addresses these problems in a number of ways. Within a function definition, the appearance of both and return ( expr) ; return; statements is cause for alarm. In this case, lint produces the following error message: function name contains return(e) and return 3-5
lint: C Program Checker XENIX Programming It is difficult to detect when a function return is implied by the flow of control reaching the end of the given function. This is demonstrated with a simple example: f (a) { } if (a) g(); return (3); Note that if the variable a tests false, f will call the function g and then return with no defined return value. This will trigger a report from lint. If g, like exit, never returns, the message will still be produced when in fact nothing is wrong. In practice, potentially serious bugs can be discovered with this feature. It also accounts for a substantial fraction of the noise messages produced by lint. Checking for Unused Return Values The lint program checks for cases where a function returns a value, but the value is rarely if ever used. lint considers functions that return unused values to be inefficient and functions that return rarely used values to be a result of bad programming style. lint also checks for cases where a function does not return a value but the value is used anyway. This is considered a serious error. Checking Types lint enforces the type checking rules of C more strictly than the C compiler. The additional checking occurs in four major areas: • Across certain binary operators and implied assignments • At the structure selection operators • Between the definit ion and uses of functions • In the use of enumerations A number of operators, including the assignment, conditional, and relational operators, have an implied balancing between types of operands. The argument of a return statement and expressions used in initialization also suffer similar conversions. In these operations, char, short, int, long, unsigned, float, and double types can be freely intermixed. The types of pointers must agree exactly, except that arrays of x's can be intermixed with pointers to x's. 3-6
- Page 1 and 2: 0 • • •
- Page 3 and 4: The information in this document is
- Page 5 and 6: Table of Contents CONTENTS Compiler
- Page 7 and 8: Table of Contents CONTENTS Using Ot
- Page 9 and 10: Table of Contents CONTENTS Assemble
- Page 11 and 12: Table of Contents CONTENTS CHAPTER
- Page 13 and 14: Table of Contents TABLES TABLE TITL
- Page 15 and 16: Introduction XENIX Programming 10.
- Page 17 and 18: cc: C Compiler XENIX Programming Cr
- Page 19 and 20: cc: C Compiler XENIX Programming Th
- Page 21 and 22: cc: C Compiler XENIX Programming Th
- Page 23 and 24: cc: C Compiler XENIX Programming Cr
- Page 25 and 26: cc: C Compiler XENIX Programming Th
- Page 27 and 28: cc: C Compiler XENIX Programming Co
- Page 29 and 30: cc: C Compiler XENIX Programming Sa
- Page 31 and 32: cc: C Compiler XENIX Programming Us
- Page 33 and 34: cc: C Compiler XENIX Programming Wh
- Page 35 and 36: cc: C Compiler XENIX Programming Co
- Page 37 and 38: cc: C Compiler XENIX Programming d
- Page 39 and 40: cc: C Compiler XENIX Programming Se
- Page 41 and 42: lint: C Program Checker XENIX Progr
- Page 43: lint: C Program Checker XENIX Progr
- Page 47 and 48: lint: C Program Checker XENIX Progr
- Page 49 and 50: lint: C Program Checker XENIX Progr
- Page 51 and 52: lint: C Program Checker XENIX Progr
- Page 53 and 54: make: Program Maintainer XENIX Prog
- Page 55 and 56: make: Program Maintainer XENIX Prog
- Page 57 and 58: make: Program Maintainer XENIX Prog
- Page 59 and 60: make: Program Maintainer XENIX Prog
- Page 61 and 62: make: Program Maintainer XENIX Prog
- Page 63 and 64: make: Program Maintainer XENIX Prog
- Page 65 and 66: make: Program Maintainer print: $(F
- Page 67 and 68: SCCS: Source Code Control System XE
- Page 69 and 70: SCCS: Source Code Control System XE
- Page 71 and 72: SCCS: Source Code Control System XE
- Page 73 and 74: SCCS: Source Code Control System XE
- Page 75 and 76: SCCS: Source Code Control System XE
- Page 77 and 78: SCCS: Source Code Control System XE
- Page 79 and 80: SCCS: Source Code Control System XE
- Page 81 and 82: SCCS: Source Code Control System XE
- Page 83 and 84: SCCS: Source Code Control System XE
- Page 85 and 86: SCCS: Source Code Control System XE
- Page 87 and 88: SCCS: Source Code Control System XE
- Page 89 and 90: SCCS: Source Code Control System XE
- Page 91 and 92: SCCS: Source Code Control System XE
- Page 93 and 94: SCCS: Source Code Control System XE
<strong>XENIX</strong> Programming lint: C Program Checker<br />
Checking for Infin ite Loops<br />
The lint program checks for infinite loops and for loops that are never executed. For<br />
example, the statements<br />
and<br />
while (1) {}<br />
for (;;) {}<br />
are both considered infinite loops. While the statements<br />
and<br />
while (0) {}<br />
for (;0;) {}<br />
are never executed.<br />
Although some valid programs have such loops, they are generally considered errors.<br />
Checking Function Return Values<br />
The lint program checks that a function returns a meaningful value if necessary. Some<br />
functions return values that are never used; some programs incorrectly use function<br />
values that have never been returned. lint addresses these problems in a number of<br />
ways.<br />
Within a function definition, the appearance of both<br />
and<br />
return ( expr) ;<br />
return;<br />
statements is cause for alarm. In this case, lint produces the following error message:<br />
function name contains return(e) and return<br />
3-5