Bug Summary

File:obj-scan-build/term/device_replyServer.c
Location:line 306, column 24
Description:Value stored to 'return_codeCheck' during its initialization is never read

Annotated Source Code

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 mig_unlikely
23#define mig_unlikely(X)__builtin_expect (!! (X), 0) __builtin_expect (!! (X), 0)
24#endif
25
26#ifndef TypeCheck0
27#define TypeCheck0 1
28#endif
29
30#ifndef UseExternRCSId1
31#define UseExternRCSId1 1
32#endif
33
34#define BAD_TYPECHECK(type, check)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
mig_unlikely (({\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
35 union { mach_msg_type_t t; unsigned32_t w; } _t, _c;\__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
36 _t.t = *(type); _c.t = *(check);_t.w != _c.w; }))__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(type); _c.t = *(check);_t.w != _c.w; }
)), 0)
37#define msgh_request_portmsgh_local_port msgh_local_port
38#define MACH_MSGH_BITS_REQUEST(bits)(((bits) & 0x0000ff00) >> 8) MACH_MSGH_BITS_LOCAL(bits)(((bits) & 0x0000ff00) >> 8)
39#define msgh_reply_portmsgh_remote_port msgh_remote_port
40#define MACH_MSGH_BITS_REPLY(bits)((bits) & 0x000000ff) MACH_MSGH_BITS_REMOTE(bits)((bits) & 0x000000ff)
41
42#include <mach/std_types.h>
43#include <device/device_types.h>
44#include <device/net_status.h>
45
46/* SimpleRoutine device_open_reply */
47mig_internalstatic void _Xdevice_open_reply
48 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
49{
50 typedef struct {
51 mach_msg_header_t Head;
52 mach_msg_type_t return_codeType;
53 kern_return_t return_code;
54 mach_msg_type_t device_portType;
55 mach_port_t device_port;
56 } Request;
57
58 typedef struct {
59 mach_msg_header_t Head;
60 mach_msg_type_t RetCodeType;
61 kern_return_t RetCode;
62 } Reply;
63
64 Request *In0P = (Request *) InHeadP;
65 Reply *OutP = (Reply *) OutHeadP;
66 mig_external kern_return_t device_open_reply
67 (mach_port_t reply_port, kern_return_t return_code, mach_port_t device_port);
68
69 const mach_msg_type_t return_codeCheck = {
70 /* msgt_name = */ 2,
71 /* msgt_size = */ 32,
72 /* msgt_number = */ 1,
73 /* msgt_inline = */ TRUE((boolean_t) 1),
74 /* msgt_longform = */ FALSE((boolean_t) 0),
75 /* msgt_deallocate = */ FALSE((boolean_t) 0),
76 /* msgt_unused = */ 0
77 };
78
79 const mach_msg_type_t device_portCheck = {
80 /* msgt_name = */ 17,
81 /* msgt_size = */ 32,
82 /* msgt_number = */ 1,
83 /* msgt_inline = */ TRUE((boolean_t) 1),
84 /* msgt_longform = */ FALSE((boolean_t) 0),
85 /* msgt_deallocate = */ FALSE((boolean_t) 0),
86 /* msgt_unused = */ 0
87 };
88
89 mach_port_t reply_port;
90
91#if TypeCheck0
92 if (mig_unlikely ((In0P->Head.msgh_size != 40) ||__builtin_expect (!! ((In0P->Head.msgh_size != 40) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
93 !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 40) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
94 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
95#endif /* TypeCheck */
96
97#if TypeCheck0
98 if (BAD_TYPECHECK(&In0P->return_codeType, &return_codeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->return_codeType); _c.t =
*(&return_codeCheck);_t.w != _c.w; })), 0)
)
99 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
100#endif /* TypeCheck */
101
102#if TypeCheck0
103 if (BAD_TYPECHECK(&In0P->device_portType, &device_portCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->device_portType); _c.t =
*(&device_portCheck);_t.w != _c.w; })), 0)
)
104 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
105#endif /* TypeCheck */
106
107 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
108 reply_port = ports_payload_get_name(In0P->Head.msgh_protected_payload);
109 else
110 reply_port = In0P->Head.msgh_request_portmsgh_local_port;
111 OutP->RetCode = device_open_reply(reply_port, In0P->return_code, In0P->device_port);
112}
113
114/* Default implementation of device_open_reply */
115#ifdef MIG_EOPNOTSUPP
116kern_return_t __attribute__ ((weak))
117device_open_reply
118(
119 mach_port_t reply_port,
120 kern_return_t return_code,
121 mach_port_t device_port
122) { return MIG_EOPNOTSUPP; }
123#endif /* MIG_EOPNOTSUPP */
124
125/* SimpleRoutine device_write_reply */
126mig_internalstatic void _Xdevice_write_reply
127 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
128{
129 typedef struct {
130 mach_msg_header_t Head;
131 mach_msg_type_t return_codeType;
132 kern_return_t return_code;
133 mach_msg_type_t bytes_writtenType;
134 int bytes_written;
135 } Request;
136
137 typedef struct {
138 mach_msg_header_t Head;
139 mach_msg_type_t RetCodeType;
140 kern_return_t RetCode;
141 } Reply;
142
143 Request *In0P = (Request *) InHeadP;
144 Reply *OutP = (Reply *) OutHeadP;
145 mig_external kern_return_t device_write_reply
146 (mach_port_t reply_port, kern_return_t return_code, int bytes_written);
147
148 const mach_msg_type_t return_codeCheck = {
149 /* msgt_name = */ 2,
150 /* msgt_size = */ 32,
151 /* msgt_number = */ 1,
152 /* msgt_inline = */ TRUE((boolean_t) 1),
153 /* msgt_longform = */ FALSE((boolean_t) 0),
154 /* msgt_deallocate = */ FALSE((boolean_t) 0),
155 /* msgt_unused = */ 0
156 };
157
158 const mach_msg_type_t bytes_writtenCheck = {
159 /* msgt_name = */ 2,
160 /* msgt_size = */ 32,
161 /* msgt_number = */ 1,
162 /* msgt_inline = */ TRUE((boolean_t) 1),
163 /* msgt_longform = */ FALSE((boolean_t) 0),
164 /* msgt_deallocate = */ FALSE((boolean_t) 0),
165 /* msgt_unused = */ 0
166 };
167
168 mach_port_t reply_port;
169
170#if TypeCheck0
171 if (mig_unlikely ((In0P->Head.msgh_size != 40) ||__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
172 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
173 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
174#endif /* TypeCheck */
175
176#if TypeCheck0
177 if (BAD_TYPECHECK(&In0P->return_codeType, &return_codeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->return_codeType); _c.t =
*(&return_codeCheck);_t.w != _c.w; })), 0)
)
178 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
179#endif /* TypeCheck */
180
181#if TypeCheck0
182 if (BAD_TYPECHECK(&In0P->bytes_writtenType, &bytes_writtenCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->bytes_writtenType); _c.t
= *(&bytes_writtenCheck);_t.w != _c.w; })), 0)
)
183 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
184#endif /* TypeCheck */
185
186 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
187 reply_port = ports_payload_get_name(In0P->Head.msgh_protected_payload);
188 else
189 reply_port = In0P->Head.msgh_request_portmsgh_local_port;
190 OutP->RetCode = device_write_reply(reply_port, In0P->return_code, In0P->bytes_written);
191}
192
193/* Default implementation of device_write_reply */
194#ifdef MIG_EOPNOTSUPP
195kern_return_t __attribute__ ((weak))
196device_write_reply
197(
198 mach_port_t reply_port,
199 kern_return_t return_code,
200 int bytes_written
201) { return MIG_EOPNOTSUPP; }
202#endif /* MIG_EOPNOTSUPP */
203
204/* SimpleRoutine device_write_reply_inband */
205mig_internalstatic void _Xdevice_write_reply_inband
206 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
207{
208 typedef struct {
209 mach_msg_header_t Head;
210 mach_msg_type_t return_codeType;
211 kern_return_t return_code;
212 mach_msg_type_t bytes_writtenType;
213 int bytes_written;
214 } Request;
215
216 typedef struct {
217 mach_msg_header_t Head;
218 mach_msg_type_t RetCodeType;
219 kern_return_t RetCode;
220 } Reply;
221
222 Request *In0P = (Request *) InHeadP;
223 Reply *OutP = (Reply *) OutHeadP;
224 mig_external kern_return_t device_write_reply_inband
225 (mach_port_t reply_port, kern_return_t return_code, int bytes_written);
226
227 const mach_msg_type_t return_codeCheck = {
228 /* msgt_name = */ 2,
229 /* msgt_size = */ 32,
230 /* msgt_number = */ 1,
231 /* msgt_inline = */ TRUE((boolean_t) 1),
232 /* msgt_longform = */ FALSE((boolean_t) 0),
233 /* msgt_deallocate = */ FALSE((boolean_t) 0),
234 /* msgt_unused = */ 0
235 };
236
237 const mach_msg_type_t bytes_writtenCheck = {
238 /* msgt_name = */ 2,
239 /* msgt_size = */ 32,
240 /* msgt_number = */ 1,
241 /* msgt_inline = */ TRUE((boolean_t) 1),
242 /* msgt_longform = */ FALSE((boolean_t) 0),
243 /* msgt_deallocate = */ FALSE((boolean_t) 0),
244 /* msgt_unused = */ 0
245 };
246
247 mach_port_t reply_port;
248
249#if TypeCheck0
250 if (mig_unlikely ((In0P->Head.msgh_size != 40) ||__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
251 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 40) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
252 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
253#endif /* TypeCheck */
254
255#if TypeCheck0
256 if (BAD_TYPECHECK(&In0P->return_codeType, &return_codeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->return_codeType); _c.t =
*(&return_codeCheck);_t.w != _c.w; })), 0)
)
257 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
258#endif /* TypeCheck */
259
260#if TypeCheck0
261 if (BAD_TYPECHECK(&In0P->bytes_writtenType, &bytes_writtenCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->bytes_writtenType); _c.t
= *(&bytes_writtenCheck);_t.w != _c.w; })), 0)
)
262 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
263#endif /* TypeCheck */
264
265 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
266 reply_port = ports_payload_get_name(In0P->Head.msgh_protected_payload);
267 else
268 reply_port = In0P->Head.msgh_request_portmsgh_local_port;
269 OutP->RetCode = device_write_reply_inband(reply_port, In0P->return_code, In0P->bytes_written);
270}
271
272/* Default implementation of device_write_reply_inband */
273#ifdef MIG_EOPNOTSUPP
274kern_return_t __attribute__ ((weak))
275device_write_reply_inband
276(
277 mach_port_t reply_port,
278 kern_return_t return_code,
279 int bytes_written
280) { return MIG_EOPNOTSUPP; }
281#endif /* MIG_EOPNOTSUPP */
282
283/* SimpleRoutine device_read_reply */
284mig_internalstatic void _Xdevice_read_reply
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_long_t dataType;
292 io_buf_ptr_t data;
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
304 (mach_port_t reply_port, kern_return_t return_code, io_buf_ptr_t data, mach_msg_type_number_t dataCnt);
305
306 const mach_msg_type_t return_codeCheck = {
Value stored to 'return_codeCheck' during its initialization is never read
307 /* msgt_name = */ 2,
308 /* msgt_size = */ 32,
309 /* msgt_number = */ 1,
310 /* msgt_inline = */ TRUE((boolean_t) 1),
311 /* msgt_longform = */ FALSE((boolean_t) 0),
312 /* msgt_deallocate = */ FALSE((boolean_t) 0),
313 /* msgt_unused = */ 0
314 };
315
316 mach_port_t reply_port;
317
318#if TypeCheck0
319 if (mig_unlikely ((In0P->Head.msgh_size != 48) ||__builtin_expect (!! ((In0P->Head.msgh_size != 48) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
320 !(In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 48) || !(In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
321 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
322#endif /* TypeCheck */
323
324#if TypeCheck0
325 if (BAD_TYPECHECK(&In0P->return_codeType, &return_codeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->return_codeType); _c.t =
*(&return_codeCheck);_t.w != _c.w; })), 0)
)
326 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
327#endif /* TypeCheck */
328
329#if TypeCheck0
330 if (mig_unlikely ((In0P->dataType.msgtl_header.msgt_inline != FALSE) ||__builtin_expect (!! ((In0P->dataType.msgtl_header.msgt_inline
!= ((boolean_t) 0)) || (In0P->dataType.msgtl_header.msgt_longform
!= ((boolean_t) 1)) || (In0P->dataType.msgtl_name != 9) ||
(In0P->dataType.msgtl_size != 8)), 0)
331 (In0P->dataType.msgtl_header.msgt_longform != TRUE) ||__builtin_expect (!! ((In0P->dataType.msgtl_header.msgt_inline
!= ((boolean_t) 0)) || (In0P->dataType.msgtl_header.msgt_longform
!= ((boolean_t) 1)) || (In0P->dataType.msgtl_name != 9) ||
(In0P->dataType.msgtl_size != 8)), 0)
332 (In0P->dataType.msgtl_name != 9) ||__builtin_expect (!! ((In0P->dataType.msgtl_header.msgt_inline
!= ((boolean_t) 0)) || (In0P->dataType.msgtl_header.msgt_longform
!= ((boolean_t) 1)) || (In0P->dataType.msgtl_name != 9) ||
(In0P->dataType.msgtl_size != 8)), 0)
333 (In0P->dataType.msgtl_size != 8))__builtin_expect (!! ((In0P->dataType.msgtl_header.msgt_inline
!= ((boolean_t) 0)) || (In0P->dataType.msgtl_header.msgt_longform
!= ((boolean_t) 1)) || (In0P->dataType.msgtl_name != 9) ||
(In0P->dataType.msgtl_size != 8)), 0)
)
334 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
335#endif /* TypeCheck */
336
337 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
338 reply_port = ports_payload_get_name(In0P->Head.msgh_protected_payload);
339 else
340 reply_port = In0P->Head.msgh_request_portmsgh_local_port;
341 OutP->RetCode = device_read_reply(reply_port, In0P->return_code, In0P->data, In0P->dataType.msgtl_number);
342}
343
344/* Default implementation of device_read_reply */
345#ifdef MIG_EOPNOTSUPP
346kern_return_t __attribute__ ((weak))
347device_read_reply
348(
349 mach_port_t reply_port,
350 kern_return_t return_code,
351 io_buf_ptr_t data,
352 mach_msg_type_number_t dataCnt
353) { return MIG_EOPNOTSUPP; }
354#endif /* MIG_EOPNOTSUPP */
355
356/* SimpleRoutine device_read_reply_inband */
357mig_internalstatic void _Xdevice_read_reply_inband
358 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
359{
360 typedef struct {
361 mach_msg_header_t Head;
362 mach_msg_type_t return_codeType;
363 kern_return_t return_code;
364 mach_msg_type_t dataType;
365 char data[128];
366 } Request;
367
368 typedef struct {
369 mach_msg_header_t Head;
370 mach_msg_type_t RetCodeType;
371 kern_return_t RetCode;
372 } Reply;
373
374 Request *In0P = (Request *) InHeadP;
375 Reply *OutP = (Reply *) OutHeadP;
376 mig_external kern_return_t device_read_reply_inband
377 (mach_port_t reply_port, kern_return_t return_code, io_buf_ptr_inband_t data, mach_msg_type_number_t dataCnt);
378
379 unsigned int msgh_size;
380
381 const mach_msg_type_t return_codeCheck = {
382 /* msgt_name = */ 2,
383 /* msgt_size = */ 32,
384 /* msgt_number = */ 1,
385 /* msgt_inline = */ TRUE((boolean_t) 1),
386 /* msgt_longform = */ FALSE((boolean_t) 0),
387 /* msgt_deallocate = */ FALSE((boolean_t) 0),
388 /* msgt_unused = */ 0
389 };
390
391 mach_port_t reply_port;
392
393#if TypeCheck0
394 msgh_size = In0P->Head.msgh_size;
395 if (mig_unlikely ((msgh_size < 36) ||__builtin_expect (!! ((msgh_size < 36) || (In0P->Head.msgh_bits
& 0x80000000U)), 0)
396 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((msgh_size < 36) || (In0P->Head.msgh_bits
& 0x80000000U)), 0)
)
397 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
398#endif /* TypeCheck */
399
400#if TypeCheck0
401 if (BAD_TYPECHECK(&In0P->return_codeType, &return_codeCheck)__builtin_expect (!! (({ union { mach_msg_type_t t; unsigned32_t
w; } _t, _c; _t.t = *(&In0P->return_codeType); _c.t =
*(&return_codeCheck);_t.w != _c.w; })), 0)
)
402 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
403#endif /* TypeCheck */
404
405#if TypeCheck0
406 if (mig_unlikely ((In0P->dataType.msgt_inline != TRUE) ||__builtin_expect (!! ((In0P->dataType.msgt_inline != ((boolean_t
) 1)) || (In0P->dataType.msgt_longform != ((boolean_t) 0))
|| (In0P->dataType.msgt_name != 8) || (In0P->dataType.
msgt_size != 8)), 0)
407 (In0P->dataType.msgt_longform != FALSE) ||__builtin_expect (!! ((In0P->dataType.msgt_inline != ((boolean_t
) 1)) || (In0P->dataType.msgt_longform != ((boolean_t) 0))
|| (In0P->dataType.msgt_name != 8) || (In0P->dataType.
msgt_size != 8)), 0)
408 (In0P->dataType.msgt_name != 8) ||__builtin_expect (!! ((In0P->dataType.msgt_inline != ((boolean_t
) 1)) || (In0P->dataType.msgt_longform != ((boolean_t) 0))
|| (In0P->dataType.msgt_name != 8) || (In0P->dataType.
msgt_size != 8)), 0)
409 (In0P->dataType.msgt_size != 8))__builtin_expect (!! ((In0P->dataType.msgt_inline != ((boolean_t
) 1)) || (In0P->dataType.msgt_longform != ((boolean_t) 0))
|| (In0P->dataType.msgt_name != 8) || (In0P->dataType.
msgt_size != 8)), 0)
)
410 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
411#endif /* TypeCheck */
412
413#if TypeCheck0
414 if (mig_unlikely (msgh_size != 36 + ((In0P->dataType.msgt_number + 3) & ~3))__builtin_expect (!! (msgh_size != 36 + ((In0P->dataType.msgt_number
+ 3) & ~3)), 0)
)
415 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
416#endif /* TypeCheck */
417
418 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
419 reply_port = ports_payload_get_name(In0P->Head.msgh_protected_payload);
420 else
421 reply_port = In0P->Head.msgh_request_portmsgh_local_port;
422 OutP->RetCode = device_read_reply_inband(reply_port, In0P->return_code, In0P->data, In0P->dataType.msgt_number);
423}
424
425/* Default implementation of device_read_reply_inband */
426#ifdef MIG_EOPNOTSUPP
427kern_return_t __attribute__ ((weak))
428device_read_reply_inband
429(
430 mach_port_t reply_port,
431 kern_return_t return_code,
432 io_buf_ptr_inband_t data,
433 mach_msg_type_number_t dataCnt
434) { return MIG_EOPNOTSUPP; }
435#endif /* MIG_EOPNOTSUPP */
436
437mig_routine_t device_reply_server_routines[] = {
438 _Xdevice_open_reply,
439 0,
440 _Xdevice_write_reply,
441 _Xdevice_write_reply_inband,
442 _Xdevice_read_reply,
443 _Xdevice_read_reply_inband,
444};
445
446mig_external boolean_t device_reply_server
447 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
448{
449 mach_msg_header_t *InP = InHeadP;
450 mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP;
451
452 const mach_msg_type_t RetCodeType = {
453 /* msgt_name = */ MACH_MSG_TYPE_INTEGER_322,
454 /* msgt_size = */ 32,
455 /* msgt_number = */ 1,
456 /* msgt_inline = */ TRUE((boolean_t) 1),
457 /* msgt_longform = */ FALSE((boolean_t) 0),
458 /* msgt_deallocate = */ FALSE((boolean_t) 0),
459 /* msgt_unused = */ 0
460 };
461
462 mig_routine_t routine;
463
464 OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0)((((InP->msgh_bits) & 0x000000ff)) | ((0) << 8));
465 OutP->Head.msgh_size = sizeof *OutP;
466 OutP->Head.msgh_remote_port = InP->msgh_reply_portmsgh_remote_port;
467 OutP->Head.msgh_local_port = MACH_PORT_NULL((mach_port_t) 0);
468 OutP->Head.msgh_seqno = 0;
469 OutP->Head.msgh_id = InP->msgh_id + 100;
470
471 OutP->RetCodeType = RetCodeType;
472
473 if ((InP->msgh_id > 2905) || (InP->msgh_id < 2900) ||
474 ((routine = device_reply_server_routines[InP->msgh_id - 2900]) == 0)) {
475 OutP->RetCode = MIG_BAD_ID-303;
476 return FALSE((boolean_t) 0);
477 }
478 (*routine) (InP, &OutP->Head);
479 return TRUE((boolean_t) 1);
480}
481
482mig_external mig_routine_t device_reply_server_routine
483 (const mach_msg_header_t *InHeadP)
484{
485 int msgh_id;
486
487 msgh_id = InHeadP->msgh_id - 2900;
488
489 if ((msgh_id > 5) || (msgh_id < 0))
490 return 0;
491
492 return device_reply_server_routines[msgh_id];
493}
494