Bug Summary

File:obj-scan-build/exec/exec_startupServer.c
Location:line 97, column 12
Description:Value stored to 'msgh_simple' during its initialization is never read

Annotated Source Code

1/* Module exec_startup */
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 TypeCheck1
27#define TypeCheck1 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 <hurd/ports.h>
43#include <mach/std_types.h>
44#include <mach/mach_types.h>
45#include <device/device_types.h>
46#include <device/net_status.h>
47#include <sys/types.h>
48#include <sys/stat.h>
49#include <sys/statfs.h>
50#include <sys/resource.h>
51#include <sys/utsname.h>
52#include <hurd/hurd_types.h>
53#include "priv.h"
54#include "mig-decls.h"
55
56/* Routine exec_startup_get_info */
57mig_internalstatic void _Xexec_startup_get_info
58 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
59{
60 typedef struct {
61 mach_msg_header_t Head;
62 } Request;
63
64 typedef struct {
65 mach_msg_header_t Head;
66 mach_msg_type_t RetCodeType;
67 kern_return_t RetCode;
68 mach_msg_type_t user_entryType;
69 vm_address_t user_entry;
70 mach_msg_type_t phdr_dataType;
71 vm_address_t phdr_data;
72 mach_msg_type_t phdr_sizeType;
73 vm_size_t phdr_size;
74 mach_msg_type_t stack_baseType;
75 vm_address_t stack_base;
76 mach_msg_type_t stack_sizeType;
77 vm_size_t stack_size;
78 mach_msg_type_t flagsType;
79 int flags;
80 mach_msg_type_long_t argvType;
81 char argv[2048];
82 mach_msg_type_long_t envpType;
83 char envp[2048];
84 mach_msg_type_long_t dtableType;
85 mach_port_t dtable[512];
86 mach_msg_type_long_t portarrayType;
87 mach_port_t portarray[512];
88 mach_msg_type_long_t intarrayType;
89 int intarray[512];
90 } Reply;
91
92 Request *In0P = (Request *) InHeadP;
93 Reply *OutP = (Reply *) OutHeadP;
94 mig_external kern_return_t S_exec_startup_get_info
95 (bootinfo_t bootstrap, vm_address_t *user_entry, vm_address_t *phdr_data, vm_size_t *phdr_size, vm_address_t *stack_base, vm_size_t *stack_size, int *flags, data_t *argv, mach_msg_type_number_t *argvCnt, data_t *envp, mach_msg_type_number_t *envpCnt, portarray_t *dtable, mach_msg_type_name_t *dtablePoly, mach_msg_type_number_t *dtableCnt, portarray_t *portarray, mach_msg_type_name_t *portarrayPoly, mach_msg_type_number_t *portarrayCnt, intarray_t *intarray, mach_msg_type_number_t *intarrayCnt);
96
97 boolean_t msgh_simple = msgh_simple;
Value stored to 'msgh_simple' during its initialization is never read
98 unsigned int msgh_size;
99 unsigned int msgh_size_delta;
100
101 const mach_msg_type_t user_entryType = {
102 /* msgt_name = */ 2,
103 /* msgt_size = */ 32,
104 /* msgt_number = */ 1,
105 /* msgt_inline = */ TRUE((boolean_t) 1),
106 /* msgt_longform = */ FALSE((boolean_t) 0),
107 /* msgt_deallocate = */ FALSE((boolean_t) 0),
108 /* msgt_unused = */ 0
109 };
110
111 const mach_msg_type_t phdr_dataType = {
112 /* msgt_name = */ 2,
113 /* msgt_size = */ 32,
114 /* msgt_number = */ 1,
115 /* msgt_inline = */ TRUE((boolean_t) 1),
116 /* msgt_longform = */ FALSE((boolean_t) 0),
117 /* msgt_deallocate = */ FALSE((boolean_t) 0),
118 /* msgt_unused = */ 0
119 };
120
121 const mach_msg_type_t phdr_sizeType = {
122 /* msgt_name = */ 2,
123 /* msgt_size = */ 32,
124 /* msgt_number = */ 1,
125 /* msgt_inline = */ TRUE((boolean_t) 1),
126 /* msgt_longform = */ FALSE((boolean_t) 0),
127 /* msgt_deallocate = */ FALSE((boolean_t) 0),
128 /* msgt_unused = */ 0
129 };
130
131 const mach_msg_type_t stack_baseType = {
132 /* msgt_name = */ 2,
133 /* msgt_size = */ 32,
134 /* msgt_number = */ 1,
135 /* msgt_inline = */ TRUE((boolean_t) 1),
136 /* msgt_longform = */ FALSE((boolean_t) 0),
137 /* msgt_deallocate = */ FALSE((boolean_t) 0),
138 /* msgt_unused = */ 0
139 };
140
141 const mach_msg_type_t stack_sizeType = {
142 /* msgt_name = */ 2,
143 /* msgt_size = */ 32,
144 /* msgt_number = */ 1,
145 /* msgt_inline = */ TRUE((boolean_t) 1),
146 /* msgt_longform = */ FALSE((boolean_t) 0),
147 /* msgt_deallocate = */ FALSE((boolean_t) 0),
148 /* msgt_unused = */ 0
149 };
150
151 const mach_msg_type_t flagsType = {
152 /* msgt_name = */ 2,
153 /* msgt_size = */ 32,
154 /* msgt_number = */ 1,
155 /* msgt_inline = */ TRUE((boolean_t) 1),
156 /* msgt_longform = */ FALSE((boolean_t) 0),
157 /* msgt_deallocate = */ FALSE((boolean_t) 0),
158 /* msgt_unused = */ 0
159 };
160
161 const mach_msg_type_long_t argvType = {
162 {
163 /* msgt_name = */ 0,
164 /* msgt_size = */ 0,
165 /* msgt_number = */ 0,
166 /* msgt_inline = */ TRUE((boolean_t) 1),
167 /* msgt_longform = */ TRUE((boolean_t) 1),
168 /* msgt_deallocate = */ FALSE((boolean_t) 0),
169 /* msgt_unused = */ 0
170 },
171 /* msgtl_name = */ 8,
172 /* msgtl_size = */ 8,
173 /* msgtl_number = */ 2048,
174 };
175
176 const mach_msg_type_long_t envpType = {
177 {
178 /* msgt_name = */ 0,
179 /* msgt_size = */ 0,
180 /* msgt_number = */ 0,
181 /* msgt_inline = */ TRUE((boolean_t) 1),
182 /* msgt_longform = */ TRUE((boolean_t) 1),
183 /* msgt_deallocate = */ FALSE((boolean_t) 0),
184 /* msgt_unused = */ 0
185 },
186 /* msgtl_name = */ 8,
187 /* msgtl_size = */ 8,
188 /* msgtl_number = */ 2048,
189 };
190
191 const mach_msg_type_long_t dtableType = {
192 {
193 /* msgt_name = */ 0,
194 /* msgt_size = */ 0,
195 /* msgt_number = */ 0,
196 /* msgt_inline = */ TRUE((boolean_t) 1),
197 /* msgt_longform = */ TRUE((boolean_t) 1),
198 /* msgt_deallocate = */ FALSE((boolean_t) 0),
199 /* msgt_unused = */ 0
200 },
201 /* msgtl_name = */ -1,
202 /* msgtl_size = */ 32,
203 /* msgtl_number = */ 512,
204 };
205
206 const mach_msg_type_long_t portarrayType = {
207 {
208 /* msgt_name = */ 0,
209 /* msgt_size = */ 0,
210 /* msgt_number = */ 0,
211 /* msgt_inline = */ TRUE((boolean_t) 1),
212 /* msgt_longform = */ TRUE((boolean_t) 1),
213 /* msgt_deallocate = */ FALSE((boolean_t) 0),
214 /* msgt_unused = */ 0
215 },
216 /* msgtl_name = */ -1,
217 /* msgtl_size = */ 32,
218 /* msgtl_number = */ 512,
219 };
220
221 const mach_msg_type_long_t intarrayType = {
222 {
223 /* msgt_name = */ 0,
224 /* msgt_size = */ 0,
225 /* msgt_number = */ 0,
226 /* msgt_inline = */ TRUE((boolean_t) 1),
227 /* msgt_longform = */ TRUE((boolean_t) 1),
228 /* msgt_deallocate = */ FALSE((boolean_t) 0),
229 /* msgt_unused = */ 0
230 },
231 /* msgtl_name = */ 2,
232 /* msgtl_size = */ 32,
233 /* msgtl_number = */ 512,
234 };
235
236 bootinfo_t bootstrap;
237 mach_msg_type_number_t argvCnt;
238 char envp[2048];
239 mach_msg_type_number_t envpCnt;
240 mach_port_t dtable[512];
241 mach_msg_type_name_t dtablePoly;
242 mach_msg_type_number_t dtableCnt;
243 mach_port_t portarray[512];
244 mach_msg_type_name_t portarrayPoly;
245 mach_msg_type_number_t portarrayCnt;
246 int intarray[512];
247 mach_msg_type_number_t intarrayCnt;
248
249 char *argvP;
250 char *envpP;
251 mach_port_t *dtableP;
252 mach_port_t *portarrayP;
253 int *intarrayP;
254
255#if TypeCheck1
256 if (mig_unlikely ((In0P->Head.msgh_size != 24) ||__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
257 (In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX))__builtin_expect (!! ((In0P->Head.msgh_size != 24) || (In0P
->Head.msgh_bits & 0x80000000U)), 0)
)
258 { OutP->RetCode = MIG_BAD_ARGUMENTS-304; return; }
259#endif /* TypeCheck */
260
261 if (MACH_MSGH_BITS_LOCAL (In0P->Head.msgh_bits)(((In0P->Head.msgh_bits) & 0x0000ff00) >> 8) == MACH_MSG_TYPE_PROTECTED_PAYLOAD23)
262 bootstrap = begin_using_bootinfo_payload(In0P->Head.msgh_protected_payload);
263 else
264 bootstrap = begin_using_bootinfo_port(In0P->Head.msgh_request_portmsgh_local_port);
265
266 argvP = OutP->argv;
267 argvCnt = 2048;
268
269 envpP = envp;
270 envpCnt = 2048;
271
272 dtableP = dtable;
273 dtableCnt = 512;
274
275 portarrayP = portarray;
276 portarrayCnt = 512;
277
278 intarrayP = intarray;
279 intarrayCnt = 512;
280
281 OutP->RetCode = S_exec_startup_get_info(bootstrap, &OutP->user_entry, &OutP->phdr_data, &OutP->phdr_size, &OutP->stack_base, &OutP->stack_size, &OutP->flags, &argvP, &argvCnt, &envpP, &envpCnt, &dtableP, &dtablePoly, &dtableCnt, &portarrayP, &portarrayPoly, &portarrayCnt, &intarrayP, &intarrayCnt);
282 end_using_bootinfo(bootstrap);
283 if (OutP->RetCode != KERN_SUCCESS0)
284 return;
285
286 msgh_simple = TRUE((boolean_t) 1);
287
288 OutP->user_entryType = user_entryType;
289
290 OutP->phdr_dataType = phdr_dataType;
291
292 OutP->phdr_sizeType = phdr_sizeType;
293
294 OutP->stack_baseType = stack_baseType;
295
296 OutP->stack_sizeType = stack_sizeType;
297
298 OutP->flagsType = flagsType;
299
300 OutP->argvType = argvType;
301 if (argvP != OutP->argv) {
302 OutP->argvType.msgtl_header.msgt_inline = FALSE((boolean_t) 0);
303 OutP->argvType.msgtl_header.msgt_deallocate = TRUE((boolean_t) 1);
304 *((char **)OutP->argv) = argvP;
305 msgh_simple = FALSE((boolean_t) 0);
306 }
307
308 OutP->argvType.msgtl_number = argvCnt;
309 msgh_size_delta = (OutP->argvType.msgtl_header.msgt_inline) ? (argvCnt + 3) & ~3 : sizeof(char *);
310 msgh_size = 140 + msgh_size_delta;
311 OutP = (Reply *) ((char *) OutP + msgh_size_delta - 2048);
312
313 OutP->envpType = envpType;
314
315 if (envpP != envp) {
316 OutP->envpType.msgtl_header.msgt_inline = FALSE((boolean_t) 0);
317 OutP->envpType.msgtl_header.msgt_deallocate = TRUE((boolean_t) 1);
318 *((char **)OutP->envp) = envpP;
319 msgh_simple = FALSE((boolean_t) 0);
320 }
321 else {
322 memcpy(OutP->envp, envp, envpCnt);
323 }
324
325 OutP->envpType.msgtl_number = envpCnt;
326 msgh_size_delta = (OutP->envpType.msgtl_header.msgt_inline) ? (envpCnt + 3) & ~3 : sizeof(char *);
327 msgh_size += msgh_size_delta;
328 OutP = (Reply *) ((char *) OutP + msgh_size_delta - 2048);
329
330 OutP->dtableType = dtableType;
331
332 if (dtableP != dtable) {
333 OutP->dtableType.msgtl_header.msgt_inline = FALSE((boolean_t) 0);
334 OutP->dtableType.msgtl_header.msgt_deallocate = TRUE((boolean_t) 1);
335 *((mach_port_t **)OutP->dtable) = dtableP;
336 msgh_simple = FALSE((boolean_t) 0);
337 }
338 else {
339 memcpy(OutP->dtable, dtable, 4 * dtableCnt);
340 }
341
342 if (MACH_MSG_TYPE_PORT_ANY(dtablePoly)(((dtablePoly) >= 16) && ((dtablePoly) <= 21)))
343 msgh_simple = FALSE((boolean_t) 0);
344
345 OutP->dtableType.msgtl_name = dtablePoly;
346
347 OutP->dtableType.msgtl_number = dtableCnt;
348 msgh_size_delta = (OutP->dtableType.msgtl_header.msgt_inline) ? 4 * dtableCnt : sizeof(mach_port_t *);
349 msgh_size += msgh_size_delta;
350 OutP = (Reply *) ((char *) OutP + msgh_size_delta - 2048);
351
352 OutP->portarrayType = portarrayType;
353
354 if (portarrayP != portarray) {
355 OutP->portarrayType.msgtl_header.msgt_inline = FALSE((boolean_t) 0);
356 OutP->portarrayType.msgtl_header.msgt_deallocate = TRUE((boolean_t) 1);
357 *((mach_port_t **)OutP->portarray) = portarrayP;
358 msgh_simple = FALSE((boolean_t) 0);
359 }
360 else {
361 memcpy(OutP->portarray, portarray, 4 * portarrayCnt);
362 }
363
364 if (MACH_MSG_TYPE_PORT_ANY(portarrayPoly)(((portarrayPoly) >= 16) && ((portarrayPoly) <=
21))
)
365 msgh_simple = FALSE((boolean_t) 0);
366
367 OutP->portarrayType.msgtl_name = portarrayPoly;
368
369 OutP->portarrayType.msgtl_number = portarrayCnt;
370 msgh_size_delta = (OutP->portarrayType.msgtl_header.msgt_inline) ? 4 * portarrayCnt : sizeof(mach_port_t *);
371 msgh_size += msgh_size_delta;
372 OutP = (Reply *) ((char *) OutP + msgh_size_delta - 2048);
373
374 OutP->intarrayType = intarrayType;
375
376 if (intarrayP != intarray) {
377 OutP->intarrayType.msgtl_header.msgt_inline = FALSE((boolean_t) 0);
378 OutP->intarrayType.msgtl_header.msgt_deallocate = TRUE((boolean_t) 1);
379 *((int **)OutP->intarray) = intarrayP;
380 msgh_simple = FALSE((boolean_t) 0);
381 }
382 else {
383 memcpy(OutP->intarray, intarray, 4 * intarrayCnt);
384 }
385
386 OutP->intarrayType.msgtl_number = intarrayCnt;
387 msgh_size += (OutP->intarrayType.msgtl_header.msgt_inline) ? 4 * intarrayCnt : sizeof(int *);
388
389 OutP = (Reply *) OutHeadP;
390 if (!msgh_simple)
391 OutP->Head.msgh_bits |= MACH_MSGH_BITS_COMPLEX0x80000000U;
392 OutP->Head.msgh_size = msgh_size;
393}
394
395/* Default implementation of S_exec_startup_get_info */
396#ifdef MIG_EOPNOTSUPP
397kern_return_t __attribute__ ((weak))
398S_exec_startup_get_info
399(
400 bootinfo_t bootstrap,
401 vm_address_t *user_entry,
402 vm_address_t *phdr_data,
403 vm_size_t *phdr_size,
404 vm_address_t *stack_base,
405 vm_size_t *stack_size,
406 int *flags,
407 data_t *argv,
408 mach_msg_type_number_t *argvCnt,
409 data_t *envp,
410 mach_msg_type_number_t *envpCnt,
411 portarray_t *dtable,
412 mach_msg_type_name_t *dtablePoly,
413 mach_msg_type_number_t *dtableCnt,
414 portarray_t *portarray,
415 mach_msg_type_name_t *portarrayPoly,
416 mach_msg_type_number_t *portarrayCnt,
417 intarray_t *intarray,
418 mach_msg_type_number_t *intarrayCnt
419) { return MIG_EOPNOTSUPP; }
420#endif /* MIG_EOPNOTSUPP */
421
422mig_routine_t exec_startup_server_routines[] = {
423 _Xexec_startup_get_info,
424};
425
426mig_external boolean_t exec_startup_server
427 (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP)
428{
429 mach_msg_header_t *InP = InHeadP;
430 mig_reply_header_t *OutP = (mig_reply_header_t *) OutHeadP;
431
432 const mach_msg_type_t RetCodeType = {
433 /* msgt_name = */ MACH_MSG_TYPE_INTEGER_322,
434 /* msgt_size = */ 32,
435 /* msgt_number = */ 1,
436 /* msgt_inline = */ TRUE((boolean_t) 1),
437 /* msgt_longform = */ FALSE((boolean_t) 0),
438 /* msgt_deallocate = */ FALSE((boolean_t) 0),
439 /* msgt_unused = */ 0
440 };
441
442 mig_routine_t routine;
443
444 OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InP->msgh_bits), 0)((((InP->msgh_bits) & 0x000000ff)) | ((0) << 8));
445 OutP->Head.msgh_size = sizeof *OutP;
446 OutP->Head.msgh_remote_port = InP->msgh_reply_portmsgh_remote_port;
447 OutP->Head.msgh_local_port = MACH_PORT_NULL((mach_port_t) 0);
448 OutP->Head.msgh_seqno = 0;
449 OutP->Head.msgh_id = InP->msgh_id + 100;
450
451 OutP->RetCodeType = RetCodeType;
452
453 if ((InP->msgh_id > 30500) || (InP->msgh_id < 30500) ||
454 ((routine = exec_startup_server_routines[InP->msgh_id - 30500]) == 0)) {
455 OutP->RetCode = MIG_BAD_ID-303;
456 return FALSE((boolean_t) 0);
457 }
458 (*routine) (InP, &OutP->Head);
459 return TRUE((boolean_t) 1);
460}
461
462mig_external mig_routine_t exec_startup_server_routine
463 (const mach_msg_header_t *InHeadP)
464{
465 int msgh_id;
466
467 msgh_id = InHeadP->msgh_id - 30500;
468
469 if ((msgh_id > 0) || (msgh_id < 0))
470 return 0;
471
472 return exec_startup_server_routines[msgh_id];
473}
474