File: | obj-scan-build/term/device_replyServer.c |
Location: | line 137, column 24 |
Description: | Value stored to 'bytes_writtenCheck' during its initialization is never read |
1 | /* Module device_reply */ |
2 | |
3 | #ifndef _GNU_SOURCE1 |
4 | #define _GNU_SOURCE1 1 |
5 | #endif |
6 | |
7 | #define EXPORT_BOOLEAN |
8 | #include <mach/boolean.h> |
9 | #include <mach/kern_return.h> |
10 | #include <mach/message.h> |
11 | #include <mach/mig_errors.h> |
12 | #include <mach/mig_support.h> |
13 | |
14 | #ifndef mig_internalstatic |
15 | #define mig_internalstatic static |
16 | #endif |
17 | |
18 | #ifndef mig_external |
19 | #define mig_external |
20 | #endif |
21 | |
22 | #ifndef TypeCheck0 |
23 | #define TypeCheck0 1 |
24 | #endif |
25 | |
26 | #ifndef UseExternRCSId1 |
27 | #define UseExternRCSId1 1 |
28 | #endif |
29 | |
30 | #define BAD_TYPECHECK(type, check)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) ({\ |
31 | union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\ |
32 | _t.t = *(type); _c.t = *(check); _t.w != _c.w; }) |
33 | #define msgh_request_portmsgh_local_port msgh_local_port |
34 | #define MACH_MSGH_BITS_REQUEST(bits)(((bits) & 0x0000ff00) >> 8) MACH_MSGH_BITS_LOCAL(bits)(((bits) & 0x0000ff00) >> 8) |
35 | #define msgh_reply_portmsgh_remote_port msgh_remote_port |
36 | #define MACH_MSGH_BITS_REPLY(bits)((bits) & 0x000000ff) MACH_MSGH_BITS_REMOTE(bits)((bits) & 0x000000ff) |
37 | |
38 | #include <mach/std_types.h> |
39 | #include <device/device_types.h> |
40 | #include <device/net_status.h> |
41 | |
42 | /* SimpleRoutine device_open_reply */ |
43 | mig_internalstatic void _Xdevice_open_reply |
44 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
45 | { |
46 | typedef struct { |
47 | mach_msg_header_t Head; |
48 | mach_msg_type_t return_codeType; |
49 | kern_return_t return_code; |
50 | mach_msg_type_t device_portType; |
51 | mach_port_t device_port; |
52 | } Request; |
53 | |
54 | typedef struct { |
55 | mach_msg_header_t Head; |
56 | mach_msg_type_t RetCodeType; |
57 | kern_return_t RetCode; |
58 | } Reply; |
59 | |
60 | Request *In0P = (Request *) InHeadP; |
61 | Reply *OutP = (Reply *) OutHeadP; |
62 | mig_external kern_return_t device_open_reply |
63 | (mach_port_t reply_port, kern_return_t return_code, mach_port_t device_port); |
64 | |
65 | const mach_msg_type_t return_codeCheck = { |
66 | /* msgt_name = */ 2, |
67 | /* msgt_size = */ 32, |
68 | /* msgt_number = */ 1, |
69 | /* msgt_inline = */ TRUE((boolean_t) 1), |
70 | /* msgt_longform = */ FALSE((boolean_t) 0), |
71 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
72 | /* msgt_unused = */ 0 |
73 | }; |
74 | |
75 | const mach_msg_type_t device_portCheck = { |
76 | /* msgt_name = */ 17, |
77 | /* msgt_size = */ 32, |
78 | /* msgt_number = */ 1, |
79 | /* msgt_inline = */ TRUE((boolean_t) 1), |
80 | /* msgt_longform = */ FALSE((boolean_t) 0), |
81 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
82 | /* msgt_unused = */ 0 |
83 | }; |
84 | |
85 | #if TypeCheck0 |
86 | if ((In0P->Head.msgh_size != 40) || |
87 | !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U)) |
88 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
89 | #endif /* TypeCheck */ |
90 | |
91 | #if TypeCheck0 |
92 | if (BAD_TYPECHECK(&In0P->return_codeType, &return_codeCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->return_codeType); _c.t = *(&return_codeCheck ); _t.w != _c.w; })) |
93 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
94 | #endif /* TypeCheck */ |
95 | |
96 | #if TypeCheck0 |
97 | if (BAD_TYPECHECK(&In0P->device_portType, &device_portCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->device_portType); _c.t = *(&device_portCheck ); _t.w != _c.w; })) |
98 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
99 | #endif /* TypeCheck */ |
100 | |
101 | OutP->RetCode = device_open_reply(In0P->Head.msgh_request_portmsgh_local_port, In0P->return_code, In0P->device_port); |
102 | } |
103 | |
104 | /* SimpleRoutine device_write_reply */ |
105 | mig_internalstatic void _Xdevice_write_reply |
106 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
107 | { |
108 | typedef struct { |
109 | mach_msg_header_t Head; |
110 | mach_msg_type_t return_codeType; |
111 | kern_return_t return_code; |
112 | mach_msg_type_t bytes_writtenType; |
113 | int bytes_written; |
114 | } Request; |
115 | |
116 | typedef struct { |
117 | mach_msg_header_t Head; |
118 | mach_msg_type_t RetCodeType; |
119 | kern_return_t RetCode; |
120 | } Reply; |
121 | |
122 | Request *In0P = (Request *) InHeadP; |
123 | Reply *OutP = (Reply *) OutHeadP; |
124 | mig_external kern_return_t device_write_reply |
125 | (mach_port_t reply_port, kern_return_t return_code, int bytes_written); |
126 | |
127 | const mach_msg_type_t return_codeCheck = { |
128 | /* msgt_name = */ 2, |
129 | /* msgt_size = */ 32, |
130 | /* msgt_number = */ 1, |
131 | /* msgt_inline = */ TRUE((boolean_t) 1), |
132 | /* msgt_longform = */ FALSE((boolean_t) 0), |
133 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
134 | /* msgt_unused = */ 0 |
135 | }; |
136 | |
137 | const mach_msg_type_t bytes_writtenCheck = { |
Value stored to 'bytes_writtenCheck' during its initialization is never read | |
138 | /* msgt_name = */ 2, |
139 | /* msgt_size = */ 32, |
140 | /* msgt_number = */ 1, |
141 | /* msgt_inline = */ TRUE((boolean_t) 1), |
142 | /* msgt_longform = */ FALSE((boolean_t) 0), |
143 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
144 | /* msgt_unused = */ 0 |
145 | }; |
146 | |
147 | #if TypeCheck0 |
148 | if ((In0P->Head.msgh_size != 40) || |
149 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U)) |
150 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
151 | #endif /* TypeCheck */ |
152 | |
153 | #if TypeCheck0 |
154 | if (BAD_TYPECHECK(&In0P->return_codeType, &return_codeCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->return_codeType); _c.t = *(&return_codeCheck ); _t.w != _c.w; })) |
155 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
156 | #endif /* TypeCheck */ |
157 | |
158 | #if TypeCheck0 |
159 | if (BAD_TYPECHECK(&In0P->bytes_writtenType, &bytes_writtenCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->bytes_writtenType); _c.t = *(&bytes_writtenCheck ); _t.w != _c.w; })) |
160 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
161 | #endif /* TypeCheck */ |
162 | |
163 | OutP->RetCode = device_write_reply(In0P->Head.msgh_request_portmsgh_local_port, In0P->return_code, In0P->bytes_written); |
164 | } |
165 | |
166 | /* SimpleRoutine device_write_reply_inband */ |
167 | mig_internalstatic void _Xdevice_write_reply_inband |
168 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
169 | { |
170 | typedef struct { |
171 | mach_msg_header_t Head; |
172 | mach_msg_type_t return_codeType; |
173 | kern_return_t return_code; |
174 | mach_msg_type_t bytes_writtenType; |
175 | int bytes_written; |
176 | } Request; |
177 | |
178 | typedef struct { |
179 | mach_msg_header_t Head; |
180 | mach_msg_type_t RetCodeType; |
181 | kern_return_t RetCode; |
182 | } Reply; |
183 | |
184 | Request *In0P = (Request *) InHeadP; |
185 | Reply *OutP = (Reply *) OutHeadP; |
186 | mig_external kern_return_t device_write_reply_inband |
187 | (mach_port_t reply_port, kern_return_t return_code, int bytes_written); |
188 | |
189 | const mach_msg_type_t return_codeCheck = { |
190 | /* msgt_name = */ 2, |
191 | /* msgt_size = */ 32, |
192 | /* msgt_number = */ 1, |
193 | /* msgt_inline = */ TRUE((boolean_t) 1), |
194 | /* msgt_longform = */ FALSE((boolean_t) 0), |
195 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
196 | /* msgt_unused = */ 0 |
197 | }; |
198 | |
199 | const mach_msg_type_t bytes_writtenCheck = { |
200 | /* msgt_name = */ 2, |
201 | /* msgt_size = */ 32, |
202 | /* msgt_number = */ 1, |
203 | /* msgt_inline = */ TRUE((boolean_t) 1), |
204 | /* msgt_longform = */ FALSE((boolean_t) 0), |
205 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
206 | /* msgt_unused = */ 0 |
207 | }; |
208 | |
209 | #if TypeCheck0 |
210 | if ((In0P->Head.msgh_size != 40) || |
211 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U)) |
212 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
213 | #endif /* TypeCheck */ |
214 | |
215 | #if TypeCheck0 |
216 | if (BAD_TYPECHECK(&In0P->return_codeType, &return_codeCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->return_codeType); _c.t = *(&return_codeCheck ); _t.w != _c.w; })) |
217 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
218 | #endif /* TypeCheck */ |
219 | |
220 | #if TypeCheck0 |
221 | if (BAD_TYPECHECK(&In0P->bytes_writtenType, &bytes_writtenCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->bytes_writtenType); _c.t = *(&bytes_writtenCheck ); _t.w != _c.w; })) |
222 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
223 | #endif /* TypeCheck */ |
224 | |
225 | OutP->RetCode = device_write_reply_inband(In0P->Head.msgh_request_portmsgh_local_port, In0P->return_code, In0P->bytes_written); |
226 | } |
227 | |
228 | /* SimpleRoutine device_read_reply */ |
229 | mig_internalstatic void _Xdevice_read_reply |
230 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
231 | { |
232 | typedef struct { |
233 | mach_msg_header_t Head; |
234 | mach_msg_type_t return_codeType; |
235 | kern_return_t return_code; |
236 | mach_msg_type_long_t dataType; |
237 | io_buf_ptr_t data; |
238 | } Request; |
239 | |
240 | typedef struct { |
241 | mach_msg_header_t Head; |
242 | mach_msg_type_t RetCodeType; |
243 | kern_return_t RetCode; |
244 | } Reply; |
245 | |
246 | Request *In0P = (Request *) InHeadP; |
247 | Reply *OutP = (Reply *) OutHeadP; |
248 | mig_external kern_return_t device_read_reply |
249 | (mach_port_t reply_port, kern_return_t return_code, io_buf_ptr_t data, mach_msg_type_number_t dataCnt); |
250 | |
251 | const mach_msg_type_t return_codeCheck = { |
252 | /* msgt_name = */ 2, |
253 | /* msgt_size = */ 32, |
254 | /* msgt_number = */ 1, |
255 | /* msgt_inline = */ TRUE((boolean_t) 1), |
256 | /* msgt_longform = */ FALSE((boolean_t) 0), |
257 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
258 | /* msgt_unused = */ 0 |
259 | }; |
260 | |
261 | #if TypeCheck0 |
262 | if ((In0P->Head.msgh_size != 48) || |
263 | !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U)) |
264 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
265 | #endif /* TypeCheck */ |
266 | |
267 | #if TypeCheck0 |
268 | if (BAD_TYPECHECK(&In0P->return_codeType, &return_codeCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->return_codeType); _c.t = *(&return_codeCheck ); _t.w != _c.w; })) |
269 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
270 | #endif /* TypeCheck */ |
271 | |
272 | #if TypeCheck0 |
273 | if ((In0P->dataType.msgtl_header.msgt_inline != FALSE((boolean_t) 0)) || |
274 | (In0P->dataType.msgtl_header.msgt_longform != TRUE((boolean_t) 1)) || |
275 | (In0P->dataType.msgtl_name != 9) || |
276 | (In0P->dataType.msgtl_size != 8)) |
277 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
278 | #endif /* TypeCheck */ |
279 | |
280 | OutP->RetCode = device_read_reply(In0P->Head.msgh_request_portmsgh_local_port, In0P->return_code, In0P->data, In0P->dataType.msgtl_number); |
281 | } |
282 | |
283 | /* SimpleRoutine device_read_reply_inband */ |
284 | mig_internalstatic void _Xdevice_read_reply_inband |
285 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
286 | { |
287 | typedef struct { |
288 | mach_msg_header_t Head; |
289 | mach_msg_type_t return_codeType; |
290 | kern_return_t return_code; |
291 | mach_msg_type_t dataType; |
292 | char data[128]; |
293 | } Request; |
294 | |
295 | typedef struct { |
296 | mach_msg_header_t Head; |
297 | mach_msg_type_t RetCodeType; |
298 | kern_return_t RetCode; |
299 | } Reply; |
300 | |
301 | Request *In0P = (Request *) InHeadP; |
302 | Reply *OutP = (Reply *) OutHeadP; |
303 | mig_external kern_return_t device_read_reply_inband |
304 | (mach_port_t reply_port, kern_return_t return_code, io_buf_ptr_inband_t data, mach_msg_type_number_t dataCnt); |
305 | |
306 | unsigned int msgh_size; |
307 | |
308 | const mach_msg_type_t return_codeCheck = { |
309 | /* msgt_name = */ 2, |
310 | /* msgt_size = */ 32, |
311 | /* msgt_number = */ 1, |
312 | /* msgt_inline = */ TRUE((boolean_t) 1), |
313 | /* msgt_longform = */ FALSE((boolean_t) 0), |
314 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
315 | /* msgt_unused = */ 0 |
316 | }; |
317 | |
318 | #if TypeCheck0 |
319 | msgh_size = In0P->Head.msgh_size; |
320 | if ((msgh_size < 36) || |
321 | (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX0x80000000U)) |
322 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
323 | #endif /* TypeCheck */ |
324 | |
325 | #if TypeCheck0 |
326 | if (BAD_TYPECHECK(&In0P->return_codeType, &return_codeCheck)({ union { mach_msg_type_t t; unsigned32_t w; } _t, _c; _t.t = *(&In0P->return_codeType); _c.t = *(&return_codeCheck ); _t.w != _c.w; })) |
327 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
328 | #endif /* TypeCheck */ |
329 | |
330 | #if TypeCheck0 |
331 | if ((In0P->dataType.msgt_inline != TRUE((boolean_t) 1)) || |
332 | (In0P->dataType.msgt_longform != FALSE((boolean_t) 0)) || |
333 | (In0P->dataType.msgt_name != 8) || |
334 | (In0P->dataType.msgt_size != 8)) |
335 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
336 | #endif /* TypeCheck */ |
337 | |
338 | #if TypeCheck0 |
339 | if (msgh_size != 36 + ((In0P->dataType.msgt_number + 3) & ~3)) |
340 | { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; } |
341 | #endif /* TypeCheck */ |
342 | |
343 | OutP->RetCode = device_read_reply_inband(In0P->Head.msgh_request_portmsgh_local_port, In0P->return_code, In0P->data, In0P->dataType.msgt_number); |
344 | } |
345 | |
346 | mig_routine_t device_reply_server_routines[] = { |
347 | _Xdevice_open_reply, |
348 | 0, |
349 | _Xdevice_write_reply, |
350 | _Xdevice_write_reply_inband, |
351 | _Xdevice_read_reply, |
352 | _Xdevice_read_reply_inband, |
353 | }; |
354 | |
355 | mig_external boolean_t device_reply_server |
356 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) |
357 | { |
358 | mach_msg_header_t *InP = InHeadP; |
359 | mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP; |
360 | |
361 | const mach_msg_type_t RetCodeType = { |
362 | /* msgt_name = */ MACH_MSG_TYPE_INTEGER_322, |
363 | /* msgt_size = */ 32, |
364 | /* msgt_number = */ 1, |
365 | /* msgt_inline = */ TRUE((boolean_t) 1), |
366 | /* msgt_longform = */ FALSE((boolean_t) 0), |
367 | /* msgt_deallocate = */ FALSE((boolean_t) 0), |
368 | /* msgt_unused = */ 0 |
369 | }; |
370 | |
371 | mig_routine_t routine; |
372 | |
373 | OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0)((((InP->msgh_bits) & 0x000000ff)) | ((0) << 8)); |
374 | OutP->Head.msgh_size = sizeof *OutP; |
375 | OutP->Head.msgh_remote_port = InP->msgh_reply_portmsgh_remote_port; |
376 | OutP->Head.msgh_local_port = MACH_PORT_NULL((mach_port_t) 0); |
377 | OutP->Head.msgh_seqno = 0; |
378 | OutP->Head.msgh_id = InP->msgh_id + 100; |
379 | |
380 | OutP->RetCodeType = RetCodeType; |
381 | |
382 | if ((InP->msgh_id > 2905) || (InP->msgh_id < 2900) || |
383 | ((routine = device_reply_server_routines[InP->msgh_id - 2900]) == 0)) { |
384 | OutP->RetCode = MIG_BAD_ID-303; |
385 | return FALSE((boolean_t) 0); |
386 | } |
387 | (*routine) (InP, &OutP->Head); |
388 | return TRUE((boolean_t) 1); |
389 | } |
390 | |
391 | mig_external mig_routine_t device_reply_server_routine |
392 | (const mach_msg_header_t *InHeadP) |
393 | { |
394 | int msgh_id; |
395 | |
396 | msgh_id = InHeadP->msgh_id - 2900; |
397 | |
398 | if ((msgh_id > 5) || (msgh_id < 0)) |
399 | return 0; |
400 | |
401 | return device_reply_server_routines[msgh_id]; |
402 | } |
403 |