Bug Summary

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