syslinux: synchronize generate_extents() with extlinux
authorH. Peter Anvin <hpa@linux.intel.com>
Tue, 15 Jun 2010 23:24:57 +0000 (16:24 -0700)
committerH. Peter Anvin <hpa@linux.intel.com>
Tue, 15 Jun 2010 23:24:57 +0000 (16:24 -0700)
Synchronize the code for generate_extents() from extlinux to syslinux.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
libinstaller/syslxmod.c

index c9eddec..6df753f 100644 (file)
@@ -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++;
     }
 }