Bug Summary

File:obj-scan-build/libshouldbeinlibc/../../libshouldbeinlibc/maptime.c
Location:line 54, column 13
Description:Function call argument is an uninitialized value

Annotated Source Code

1/* Support for mach's mapped time
2
3 Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4
5 Written by Miles Bader <miles@gnu.ai.mit.edu>
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
11
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21#include <fcntl.h>
22#include <hurd.h>
23#include <mach.h>
24#include <device/device.h>
25
26#include "maptime.h"
27
28/* Return the mach mapped time page in MTIME. If USE_MACH_DEV is false, then
29 the hurd time device DEV_NAME, or "/dev/time" if DEV_NAME is 0, is
30 used. If USE_MACH_DEV is true, the mach device DEV_NAME, or "time" if
31 DEV_NAME is 0, is used; this is a privileged operation. The mapped time
32 may be converted to a struct timeval at any time using maptime_read. */
33error_t
34maptime_map (int use_mach_dev, char *dev_name,
35 volatile struct mapped_time_value **mtime)
36{
37 error_t err;
38 mach_port_t memobj;
39
40 if (use_mach_dev)
1
Assuming 'use_mach_dev' is not equal to 0
2
Taking true branch
41 {
42 device_t device;
3
Variable 'device' declared without an initial value
43 mach_port_t device_master;
44
45 err = get_privileged_ports (0, &device_master);
46 if (! err)
4
Assuming 'err' is not equal to 0
5
Taking false branch
47 {
48 err = device_open (device_master, 0, dev_name ?: "time", &device);
49 mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), device_master);
50 if (err)
51 return err;
52 }
53
54 err = device_map (device, VM_PROT_READ((vm_prot_t) 0x01), 0, sizeof *mtime, &memobj, 0);
6
Function call argument is an uninitialized value
55 }
56 else
57 {
58 mach_port_t wr_memobj;
59 file_t node = file_name_lookup (dev_name ?: "/dev/time", O_RDONLY0x0001, 0);
60
61 if (node == MACH_PORT_NULL((mach_port_t) 0))
62 return errno(*__errno_location ());
63
64 err = io_map (node, &memobj, &wr_memobj);
65 if (!err && wr_memobj != MACH_PORT_NULL((mach_port_t) 0))
66 mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), wr_memobj);
67
68 mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), node);
69 }
70
71 if (! err)
72 {
73 *mtime = 0;
74 err =
75 vm_map (mach_task_self ()((__mach_task_self_ + 0)), (vm_address_t *)mtime, sizeof *mtime, 0, 1,
76 memobj, 0, 0, VM_PROT_READ((vm_prot_t) 0x01), VM_PROT_READ((vm_prot_t) 0x01), VM_INHERIT_NONE((vm_inherit_t) 2));
77 mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), memobj);
78 }
79
80 return err;
81}