Bug Summary

File:obj-scan-build/libshouldbeinlibc/../../libshouldbeinlibc/maptime.c
Location:line 53, 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 <device/device.h>
24
25#include "maptime.h"
26
27/* Return the mach mapped time page in MTIME. If USE_MACH_DEV is false, then
28 the hurd time device DEV_NAME, or "/dev/time" if DEV_NAME is 0, is
29 used. If USE_MACH_DEV is true, the mach device DEV_NAME, or "time" if
30 DEV_NAME is 0, is used; this is a privileged operation. The mapped time
31 may be converted to a struct timeval at any time using maptime_read. */
32error_t
33maptime_map (int use_mach_dev, char *dev_name,
34 volatile struct mapped_time_value **mtime)
35{
36 error_t err;
37 mach_port_t memobj;
38
39 if (use_mach_dev)
1
Assuming 'use_mach_dev' is not equal to 0
2
Taking true branch
40 {
41 device_t device;
3
Variable 'device' declared without an initial value
42 mach_port_t device_master;
43
44 err = get_privileged_ports (0, &device_master);
45 if (! err)
4
Assuming 'err' is not equal to 0
5
Taking false branch
46 {
47 err = device_open (device_master, 0, dev_name ?: "time", &device);
48 mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), device_master);
49 if (err)
50 return err;
51 }
52
53 err = device_map (device, VM_PROT_READ((vm_prot_t) 0x01), 0, sizeof *mtime, &memobj, 0);
6
Function call argument is an uninitialized value
54 }
55 else
56 {
57 mach_port_t wr_memobj;
58 file_t node = file_name_lookup (dev_name ?: "/dev/time", O_RDONLY0x0001, 0);
59
60 if (node == MACH_PORT_NULL((mach_port_t) 0))
61 return errno(*__errno_location ());
62
63 err = io_map (node, &memobj, &wr_memobj);
64 if (!err && wr_memobj != MACH_PORT_NULL((mach_port_t) 0))
65 mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), wr_memobj);
66
67 mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), node);
68 }
69
70 if (! err)
71 {
72 *mtime = 0;
73 err =
74 vm_map (mach_task_self ()((__mach_task_self_ + 0)), (vm_address_t *)mtime, sizeof *mtime, 0, 1,
75 memobj, 0, 0, VM_PROT_READ((vm_prot_t) 0x01), VM_PROT_READ((vm_prot_t) 0x01), VM_INHERIT_NONE((vm_inherit_t) 2));
76 mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), memobj);
77 }
78
79 return err;
80}