1 // have to duplicate a lot of rules because T E only matches if E has a known
2 // type, even if T is not used elsewhere.
4 // originally, the whens were when != x, but that doesn't work because x
5 // only binds to the outermost expression, not all possible expressions, and
6 // the value returned by kmalloc is usually used as a subexpression.
7 // so we have considered the typical uses that may cause problems; a function
10 //\(x->fld\|f(...,x,...)\|x=E\)
18 expression e1,e2,e3,y;
22 - x = (T)kmalloc(E1,E2)
24 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
34 expression e1,e2,e3,y;
38 - x = (T)kmalloc(sizeof(T1),E2)
39 + x = kzalloc(sizeof(T1),E2)
40 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
41 - memset((T2)x,0,sizeof(*x));
50 expression e1,e2,e3,y;
54 - x = (T)kmalloc(sizeof(*x),E2)
55 + x = kzalloc(sizeof(*x),E2)
56 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
57 - memset((T2)x,0,sizeof(T1));
59 // ---------------------------------------------------------------------
60 // ---------------------------------------------------------------------
67 expression e1,e2,e3,y;
71 - x = (T)kmalloc(E1,E2)
73 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
75 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
87 expression e1,e2,e3,y;
91 - x = (T)kmalloc(sizeof(T1),E2)
92 + x = kzalloc(sizeof(T1),E2)
93 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
95 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
96 - memset((T2)x,0,sizeof(*x));
107 expression e1,e2,e3,y;
111 - x = (T)kmalloc(sizeof(*x),E2)
112 + x = kzalloc(sizeof(*x),E2)
113 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
115 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
116 - memset((T2)x,0,sizeof(T1));
120 // ---------------------------------------------------------------------
121 // ---------------------------------------------------------------------
129 expression e1,e2,e3,y;
133 - T1 x = (T)kmalloc(E1,E2);
134 + T1 x = kzalloc(E1,E2);
135 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
136 - memset((T2)x,0,E1);
145 expression e1,e2,e3,y;
149 - T1 x = (T)kmalloc(sizeof(T1),E2);
150 + T1 x = kzalloc(sizeof(T1),E2);
151 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
152 - memset((T2)x,0,sizeof(*x));
161 expression e1,e2,e3,y;
165 - T1 x = (T)kmalloc(sizeof(*x),E2);
166 + T1 x = kzalloc(sizeof(*x),E2);
167 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
168 - memset((T2)x,0,sizeof(T1));
170 // ---------------------------------------------------------------------
171 // ---------------------------------------------------------------------
179 expression e1,e2,e3,y;
183 - T1 x = (T)kmalloc(E1,E2);
184 + T1 x = kzalloc(E1,E2);
185 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
187 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
188 - memset((T2)x,0,E1);
199 expression e1,e2,e3,y;
203 - T1 x = (T)kmalloc(sizeof(T1),E2);
204 + T1 x = kzalloc(sizeof(T1),E2);
205 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
207 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
208 - memset((T2)x,0,sizeof(*x));
219 expression e1,e2,e3,y;
223 - T1 x = (T)kmalloc(sizeof(*x),E2);
224 + T1 x = kzalloc(sizeof(*x),E2);
225 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
227 ... when != \(x->fld=E;\|y=f(...,x,...);\|f(...,x,...);\|x=E;\|while(...) S\|for(e1;e2;e3) S\)
228 - memset((T2)x,0,sizeof(T1));
232 // ---------------------------------------------------------------------
233 // ---------------------------------------------------------------------
238 - kzalloc(E1 * E2,E3)