Subject: Uninitialized variable fallout
To: None <tech-kern@netbsd.org>
From: Charles M. Hannum <abuse@spamalicious.com>
List: tech-kern
Date: 10/27/2003 16:52:37
--Boundary-00=_V1Un/O9DZqvhOTc
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Is there any reason the following isn't correct? It gets rid of the variable
which generates the warning, rather than initializing it to something bogus.
Rationale:
"fudge" is only set on the first pass through the loop, and only in the case
where we didn't clip, so we know that oldstart is always the same value as
entry->start on line 1729, where "fudge" was calculated the first time.
Therefore the recalculation of "fudge" is:
fudge = fudge - (entry->start[new] - oldstart)
= (start - entry->start[old]) - (entry->start[new] - entry->start[old])
= start - entry->start[new]
--Boundary-00=_V1Un/O9DZqvhOTc
Content-Type: text/x-diff;
charset="us-ascii";
name="uvm-diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="uvm-diff"
Index: uvm_map.c
===================================================================
RCS file: /cvsroot/src/sys/uvm/uvm_map.c,v
retrieving revision 1.142
diff -u -r1.142 uvm_map.c
--- uvm_map.c 9 Oct 2003 03:12:29 -0000 1.142
+++ uvm_map.c 27 Oct 2003 16:47:37 -0000
@@ -1670,8 +1670,7 @@
uvm_map_extract(struct vm_map *srcmap, vaddr_t start, vsize_t len,
struct vm_map *dstmap, vaddr_t *dstaddrp, int flags)
{
- vaddr_t dstaddr, end, newend, oldoffset, fudge, orig_fudge,
- oldstart;
+ vaddr_t dstaddr, end, newend, oldoffset, fudge, orig_fudge;
struct vm_map_entry *chain, *endchain, *entry, *orig_entry, *newentry,
*deadentry, *oldentry;
vsize_t elen;
@@ -1768,10 +1767,6 @@
/* clear needs_copy (allow chunking) */
if (UVM_ET_ISNEEDSCOPY(entry)) {
- if (fudge)
- oldstart = entry->start;
- else
- oldstart = 0; /* XXX: gcc */
amap_copy(srcmap, entry, M_NOWAIT, TRUE, start, end);
if (UVM_ET_ISNEEDSCOPY(entry)) { /* failed? */
error = ENOMEM;
@@ -1780,7 +1775,7 @@
/* amap_copy could clip (during chunk)! update fudge */
if (fudge) {
- fudge = fudge - (entry->start - oldstart);
+ fudge = start - entry->start;
orig_fudge = fudge;
}
}
--Boundary-00=_V1Un/O9DZqvhOTc--