Bug Summary

File:obj-scan-build/../i386/i386/phys.c
Location:line 102, column 3
Description:Function call argument is an uninitialized value

Annotated Source Code

1/*
2 * Mach Operating System
3 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26
27#include <string.h>
28
29#include <mach/boolean.h>
30#include <mach/xen.h>
31#include <kern/task.h>
32#include <kern/thread.h>
33#include <vm/vm_map.h>
34#include "vm_param.h"
35#include <mach/vm_prot.h>
36#include <vm/vm_kern.h>
37#include <vm/vm_page.h>
38
39#include <i3861/pmap.h>
40#include <i3861/model_dep.h>
41#include <mach/machine/vm_param.h>
42
43#define INTEL_PTE_W(p)(0x00000001 | 0x00000002 | 0x00000020 | 0x00000040 | ((p) &
0xfffff000))
(INTEL_PTE_VALID0x00000001 | INTEL_PTE_WRITE0x00000002 | INTEL_PTE_REF0x00000020 | INTEL_PTE_MOD0x00000040 | pa_to_pte(p)((p) & 0xfffff000))
44#define INTEL_PTE_R(p)(0x00000001 | 0x00000020 | ((p) & 0xfffff000)) (INTEL_PTE_VALID0x00000001 | INTEL_PTE_REF0x00000020 | pa_to_pte(p)((p) & 0xfffff000))
45
46/*
47 * pmap_zero_page zeros the specified (machine independent) page.
48 */
49void
50pmap_zero_page(vm_offset_t p)
51{
52 assert(p != vm_page_fictitious_addr)({ if (!(p != vm_page_fictitious_addr)) Assert("p != vm_page_fictitious_addr"
, "../i386/i386/phys.c", 52); })
;
53 vm_offset_t v;
54 pmap_mapwindow_t *map;
55
56 if (p >= phys_last_addr)
57 {
58 map = pmap_get_mapwindow(INTEL_PTE_W(p)(0x00000001 | 0x00000002 | 0x00000020 | 0x00000040 | ((p) &
0xfffff000))
);
59 v = map->vaddr;
60 }
61 else
62 v = phystokv(p)((vm_offset_t)(p) + 0xC0000000UL);
63
64 memset((void*) v, 0, PAGE_SIZE(1 << 12));
65
66 if (p >= phys_last_addr)
67 pmap_put_mapwindow(map);
68}
69
70/*
71 * pmap_copy_page copies the specified (machine independent) pages.
72 */
73void
74pmap_copy_page(
75 vm_offset_t src,
76 vm_offset_t dst)
77{
78 vm_offset_t src_addr_v, dst_addr_v;
79 pmap_mapwindow_t *src_map, *dst_map;
1
Variable 'src_map' declared without an initial value
80 assert(src != vm_page_fictitious_addr)({ if (!(src != vm_page_fictitious_addr)) Assert("src != vm_page_fictitious_addr"
, "../i386/i386/phys.c", 80); })
;
81 assert(dst != vm_page_fictitious_addr)({ if (!(dst != vm_page_fictitious_addr)) Assert("dst != vm_page_fictitious_addr"
, "../i386/i386/phys.c", 81); })
;
82
83 if (src >= phys_last_addr)
2
Taking false branch
84 {
85 src_map = pmap_get_mapwindow(INTEL_PTE_R(src)(0x00000001 | 0x00000020 | ((src) & 0xfffff000)));
86 src_addr_v = src_map->vaddr;
87 }
88 else
89 src_addr_v = phystokv(src)((vm_offset_t)(src) + 0xC0000000UL);
90
91 if (dst >= phys_last_addr)
3
Taking false branch
92 {
93 dst_map = pmap_get_mapwindow(INTEL_PTE_W(dst)(0x00000001 | 0x00000002 | 0x00000020 | 0x00000040 | ((dst) &
0xfffff000))
);
94 dst_addr_v = dst_map->vaddr;
95 }
96 else
97 dst_addr_v = phystokv(dst)((vm_offset_t)(dst) + 0xC0000000UL);
98
99 memcpy((void *) dst_addr_v, (void *) src_addr_v, PAGE_SIZE(1 << 12));
100
101 if (src >= phys_last_addr)
4
Taking true branch
102 pmap_put_mapwindow(src_map);
5
Function call argument is an uninitialized value
103 if (dst >= phys_last_addr)
104 pmap_put_mapwindow(dst_map);
105}
106
107/*
108 * copy_to_phys(src_addr_v, dst_addr_p, count)
109 *
110 * Copy virtual memory to physical memory
111 */
112void
113copy_to_phys(
114 vm_offset_t src_addr_v,
115 vm_offset_t dst_addr_p,
116 int count)
117{
118 vm_offset_t dst_addr_v;
119 pmap_mapwindow_t *dst_map;
120 assert(dst_addr_p != vm_page_fictitious_addr)({ if (!(dst_addr_p != vm_page_fictitious_addr)) Assert("dst_addr_p != vm_page_fictitious_addr"
, "../i386/i386/phys.c", 120); })
;
121 assert(pa_to_pte(dst_addr_p + count-1) == pa_to_pte(dst_addr_p))({ if (!(((dst_addr_p + count-1) & 0xfffff000) == ((dst_addr_p
) & 0xfffff000))) Assert("pa_to_pte(dst_addr_p + count-1) == pa_to_pte(dst_addr_p)"
, "../i386/i386/phys.c", 121); })
;
122
123 if (dst_addr_p >= phys_last_addr)
124 {
125 dst_map = pmap_get_mapwindow(INTEL_PTE_W(dst_addr_p)(0x00000001 | 0x00000002 | 0x00000020 | 0x00000040 | ((dst_addr_p
) & 0xfffff000))
);
126 dst_addr_v = dst_map->vaddr;
127 }
128 else
129 dst_addr_v = phystokv(dst_addr_p)((vm_offset_t)(dst_addr_p) + 0xC0000000UL);
130
131 memcpy((void *)dst_addr_v, (void *)src_addr_v, count);
132
133 if (dst_addr_p >= phys_last_addr)
134 pmap_put_mapwindow(dst_map);
135}
136
137/*
138 * copy_from_phys(src_addr_p, dst_addr_v, count)
139 *
140 * Copy physical memory to virtual memory. The virtual memory
141 * is assumed to be present (e.g. the buffer pool).
142 */
143void
144copy_from_phys(
145 vm_offset_t src_addr_p,
146 vm_offset_t dst_addr_v,
147 int count)
148{
149 vm_offset_t src_addr_v;
150 pmap_mapwindow_t *src_map;
151 assert(src_addr_p != vm_page_fictitious_addr)({ if (!(src_addr_p != vm_page_fictitious_addr)) Assert("src_addr_p != vm_page_fictitious_addr"
, "../i386/i386/phys.c", 151); })
;
152 assert(pa_to_pte(src_addr_p + count-1) == pa_to_pte(src_addr_p))({ if (!(((src_addr_p + count-1) & 0xfffff000) == ((src_addr_p
) & 0xfffff000))) Assert("pa_to_pte(src_addr_p + count-1) == pa_to_pte(src_addr_p)"
, "../i386/i386/phys.c", 152); })
;
153
154 if (src_addr_p >= phys_last_addr)
155 {
156 src_map = pmap_get_mapwindow(INTEL_PTE_R(src_addr_p)(0x00000001 | 0x00000020 | ((src_addr_p) & 0xfffff000)));
157 src_addr_v = src_map->vaddr;
158 }
159 else
160 src_addr_v = phystokv(src_addr_p)((vm_offset_t)(src_addr_p) + 0xC0000000UL);
161
162 memcpy((void *)dst_addr_v, (void *)src_addr_v, count);
163
164 if (src_addr_p >= phys_last_addr)
165 pmap_put_mapwindow(src_map);
166}
167
168/*
169 * kvtophys(addr)
170 *
171 * Convert a kernel virtual address to a physical address
172 */
173vm_offset_t
174kvtophys(vm_offset_t addr)
175{
176 pt_entry_t *pte;
177
178 if ((pte = pmap_pte(kernel_pmap, addr)) == PT_ENTRY_NULL((pt_entry_t *) 0))
179 return 0;
180 return pte_to_pa(*pte)((*pte) & 0xfffff000) | (addr & INTEL_OFFMASK0xfff);
181}