Once we find a len of 0, there is nothing more worth finding.
Signed-off-by: NeilBrown <neilb@suse.de>
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 */