Pristine Ack-5.5
[Ack-5.5.git] / doc / lint / chap7
1 .NH
2 Ideas for further development
3 .PP
4 Although the program in its current state is a useful program,
5 there are still a lot of features that should be implemented
6 in following versions.
7 I'll summarize them in this section.
8 .IP \(bu
9 Actually the program consists of three passes.
10 The filter
11 .I sort
12 is a complete pass, just as the first and the second pass.
13 I think we speed up the program by removing the filter and making
14 the second pass accept an unsorted file.
15 The sorting process can be done in parallel to the first pass if
16 both processes communicate through a pipe.
17 In addition to this sorting, the second pass can generate already
18 some warnings.
19 (Warnings like \f(CW%s defined but never used\fP can only be
20 generated after having processed all the input.)
21 These warnings generated in parallel to the warnings of the first pass,
22 should be sent to an intermediate file, otherwise the warnings would
23 get messed up.
24 Such an improvement will have best effect on a multi processing
25 machine, but even on single processing machines this will give a better
26 performance. (On a single processing machine the pipe should be
27 replaced by an intermediate file.)
28 .IP \(bu
29 Expressions could be classified so
30 .I lint
31 can warn for some classes of expressions in strange contexts.
32 Suppose as class <boolean>.
33 \f(CWb\fP Will be of class <boolean> if e.g. \f(CWb\fP is assigned to
34 the expression \f(CW<ex1> || <ex2>\fP.
35 The following expression should then give a warning
36 .DS B
37 .ft CW
38 b + i;    /* weird expression */
39 .R
40 .DE
41 .IP \(bu
42 A mechanism to check printf like routines.
43 This mechanism should verify the format string against the following
44 arguments.
45 There is a public domain program that can be used to do this job.
46 It is called printfck and should be used as a filter between the
47 source files and
48 .I lint.
49 .IP \(bu
50 Raise warnings for incomplete initializer lists like
51 .DS B
52 .ft CW
53 int a[10] = {0, 1, 2};
54 /* initializer list not complete */
55 .R
56 .DE
57 .IP \(bu
58 Warnings for constructs like
59 .DS B
60 .ft CW
61 for (i = 0; i < 10; i++) {
62         . . . .
63         i--;
64         /* loop control variable affected */
65         . . . .
66 }
67 .R
68 .DE
69 and
70 .DS B
71 .ft CW
72 while (var) {
73         /* statements in which the value
74          * of var is never changed
75          */
76 }
77 /* loop control variable not updated */
78 .R
79 .DE
80 .IP \(bu
81 A warning \f(CWbad layout\fP for program fragments like
82 .DS B
83 .ft CW
84 if (cond1)
85         if (cond2)
86                 statement();
87 else  /* bad layout */
88         statement();
89 .R
90 .DE
91 .IP \(bu
92 A warning \f(CWassignment in conditional context\fP in case of
93 .DS B
94 .ft CW
95 if (a = b)
96 .R
97 .DE
98 .IP
99 The programmer probably meant \f(CWif (a == b)\fP.
100 No warning should be given for \f(CWif ((a = b) != c)\fP,
101 nor for \f(CWif ((a = b))\fP.
102 .IP \(bu
103 Warnings for empty statements in strange contexts, like
104 .DS B
105 .ft CW
106 if (cond);  /* mistake */
107         statement();
108 .R
109 .DE
110 .IP
111 (This mistake would also be detected by a warning \f(CWbad layout\fP.)
112 .IP \(bu
113 A mechanism to prevent the warning \f(CWpossible pointer alignment
114 problem\fP for functions of which the programmer already knows that
115 no problem will arise.
116 E.g. for functions like malloc and family.
117 .IP \(bu
118 The current version of
119 .I lint
120 warns for conversions from long to int (if -a flag is
121 on).
122 It even warns if the programmer used the proper cast, as e.g.
123 .DS B
124 .ft CW
125 int i;
126 long l = 0L;
127
128 i = (int)l;
129 .R
130 .DE
131 .IP
132 In this case I think
133 .I lint
134 need not warn.
135 The explicit cast indicates that the programmer knows what he is
136 doing.
137 This feature is not implemented because the expression tree doesn't
138 show if the cast was implicit or explicit.
139 .bp