From cbc69de20a19cbac90372fd7cbdaac00d1bbfa11 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 15 Jun 2010 16:24:57 -0700 Subject: [PATCH] syslinux: synchronize generate_extents() with extlinux Synchronize the code for generate_extents() from extlinux to syslinux. Signed-off-by: H. Peter Anvin --- libinstaller/syslxmod.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libinstaller/syslxmod.c b/libinstaller/syslxmod.c index c9eddec..6df753f 100644 --- a/libinstaller/syslxmod.c +++ b/libinstaller/syslxmod.c @@ -244,46 +244,45 @@ static __noinline void set_64_sl(uint64_t * p, uint64_t v) * Generate sector extents */ static void generate_extents(struct syslinux_extent *ex, int nptrs, - const sector_t *sectp, int nsect) + sector_t *sectp, int nsect) { - struct syslinux_extent thisex; uint32_t addr = 0x7c00 + 2*SECTOR_SIZE; uint32_t base; - sector_t sect; + sector_t sect, lba; + unsigned int len; - thisex.len = base = 0; + len = lba = base = 0; memset(ex, 0, nptrs * sizeof *ex); while (nsect) { sect = *sectp++; - if (thisex.len && - sect == thisex.lba + thisex.len && - ((addr ^ (base + thisex.len * SECTOR_SIZE)) & 0xffff0000) == 0) { + if (len && sect == lba + len && + ((addr ^ (base + len * SECTOR_SIZE)) & 0xffff0000) == 0) { /* We can add to the current extent */ - thisex.len++; + len++; goto next; } - if (thisex.len) { - set_64_sl(&ex->lba, thisex.lba); - set_16_sl(&ex->len, thisex.len); + if (len) { + set_64_sl(&ex->lba, lba); + set_16_sl(&ex->len, len); ex++; } base = addr; - thisex.lba = sect; - thisex.len = 1; + lba = sect; + len = 1; next: addr += SECTOR_SIZE; nsect--; } - if (thisex.len) { - set_64_sl(&ex->lba, thisex.lba); - set_16_sl(&ex->len, thisex.len); + if (len) { + set_64_sl(&ex->lba, lba); + set_16_sl(&ex->len, len); ex++; } } -- 2.7.4