From: NeilBrown Date: Tue, 8 Jun 2010 08:15:54 +0000 (+1000) Subject: walk_extent: don't keep walking past the end of the list of addresses X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=4ce6d5adfb95ef7ec43a078eeec2012fb38223b5;p=LaFS.git walk_extent: don't keep walking past the end of the list of addresses Once we find a len of 0, there is nothing more worth finding. Signed-off-by: NeilBrown --- diff --git a/modify.c b/modify.c index 2d88024..0508e61 100644 --- a/modify.c +++ b/modify.c @@ -878,22 +878,30 @@ static u32 walk_extent(char **bufp, int len, struct uninc *ui, u64 ephys = 0; u32 eaddr = 0; int elen = 0; + int found_end = 0; int handled; char *buf = *bufp; handle(data, 0, 0, len); /* initialise */ - while (len >= 12 || uinum < ui->pending_cnt || elen) { + while (uinum < ui->pending_cnt || ! found_end) { - if (elen == 0) { + if (elen == 0 && !found_end) { if (len >= 12) { ephys = decode48(buf); elen = decode16(buf); eaddr = decode32(buf); len -= 12; BUG_ON(ephys == 0 && elen != 0); // FIXME fail gracefully - } else + if (ephys == 0) { + eaddr = 0xFFFFFFFFUL; + found_end = 1; + } + } else { eaddr = 0xFFFFFFFFUL; + elen = 0; + found_end = 1; + } } /* Handle all pending extents that start before (or at) here */