[syslinux:master] chain, partiter: bugfixes

syslinux-bot for Michal Soltys soltys at ziu.info
Mon Mar 26 15:03:10 PDT 2012


Commit-ID:  2b3522cb5f3aa32e0377510f029c23e16ae68328
Gitweb:     http://www.syslinux.org/commit/2b3522cb5f3aa32e0377510f029c23e16ae68328
Author:     Michal Soltys <soltys at ziu.info>
AuthorDate: Tue, 17 Aug 2010 11:09:45 +0200
Committer:  Michal Soltys <soltys at ziu.info>
CommitDate: Sun, 22 Aug 2010 23:45:15 +0200

chain, partiter: bugfixes

Signed-off-by: Michal Soltys <soltys at ziu.info>

---
 com32/chain/Makefile   |    4 ++--
 com32/chain/chain.c    |   12 ++++++++++++
 com32/chain/partiter.c |   10 ++++++----
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/com32/chain/Makefile b/com32/chain/Makefile
index 1c2b188..337775c 100644
--- a/com32/chain/Makefile
+++ b/com32/chain/Makefile
@@ -16,7 +16,7 @@ topdir = ../..
 include ../MCONFIG
 
 OBJS = chain.o partiter.o
-GCCWARN2 = -Wextra -Wconversion -pedantic -Wno-error
+GCCEXTRA = -Wextra -Wconversion -pedantic -Wno-error -DDEBUG
 
 all: chain.c32
 
@@ -24,7 +24,7 @@ chain.elf: $(OBJS) $(LIBS) $(C_LIBS)
 	$(LD) $(LDFLAGS) -o $@ $^
 
 %.o: %.c
-	$(CC) $(MAKEDEPS) $(CFLAGS) $(GCCWARN2) -c -o $@ $<
+	$(CC) $(MAKEDEPS) $(CFLAGS) $(GCCEXTRA) -c -o $@ $<
 
 tidy dist:
 	rm -f *.o *.lo *.a *.lst *.elf .*.d *.tmp
diff --git a/com32/chain/chain.c b/com32/chain/chain.c
index 6c11a4d..9c73291 100644
--- a/com32/chain/chain.c
+++ b/com32/chain/chain.c
@@ -697,6 +697,10 @@ int find_dp(struct part_iter **_iter)
 	    if (iter->index == partition)
 		break;
 	} while (pi_next(&iter));
+	if (!iter) {
+	    error("Requested disk / partition combination not found.\n");
+	    goto bail;
+	}
     }
 
     if (!(iter->di.disk & 0x80) && iter->index) {
@@ -1118,6 +1122,7 @@ int main(int argc, char *argv[])
 	    data[ndata].data = (void *)hand_area;
 	    ndata++;
 	    opt.regs.esi.w[0] = 0x7be;
+
 #ifdef DEBUG
 	    dprintf("MBR handover:\n");
 	    disk_dos_part_dump(hand_area);
@@ -1125,6 +1130,13 @@ int main(int argc, char *argv[])
 	}
     }
 
+#ifdef DEBUG
+    printf("iter dsk: %d\n", iter->di.disk);
+    printf("iter idx: %d\n", iter->index);
+    printf("iter lba: %llu\n", iter->start_lba);
+    if (hand_area)
+	printf("hand lba: %u\n", hand_area->start_lba);
+#endif
     do_boot(data, ndata);
 
 bail:
diff --git a/com32/chain/partiter.c b/com32/chain/partiter.c
index 9de72f7..43ea415 100644
--- a/com32/chain/partiter.c
+++ b/com32/chain/partiter.c
@@ -355,8 +355,10 @@ static int pi_dos_next_mbr(struct part_iter *iter, uint32_t *lba,
 	break;
     }
 
+    /* safe */
     *lba = dp->start_lba;
     *_dp = dp;
+
     return 0;
 }
 
@@ -722,12 +724,12 @@ struct part_iter *pi_begin(const struct disk_info *di)
 	    goto raw;
 	}
 	/* allocate iterator and exit */
-	if (!(iter = pi_new(typegpt, di, gpth, gptl)))
-	    goto out;
+	iter = pi_new(typegpt, di, gpth, gptl);
+	goto out;
     } else {
 	/* looks like MBR */
-	if (!(iter = pi_new(typedos, di, mbr)))
-	    goto out;
+	iter = pi_new(typedos, di, mbr);
+	goto out;
     }
 
 raw:


More information about the Syslinux-commits mailing list