[syslinux:elflink] com32/chain: use anonymous and unnamed aggregates

syslinux-bot for Michal Soltys soltys at ziu.info
Sat Feb 16 01:48:08 PST 2013


Commit-ID:  e0f464b253260e668d6602b07857c75a560b0616
Gitweb:     http://www.syslinux.org/commit/e0f464b253260e668d6602b07857c75a560b0616
Author:     Michal Soltys <soltys at ziu.info>
AuthorDate: Thu, 14 Feb 2013 16:51:45 +0100
Committer:  Michal Soltys <soltys at ziu.info>
CommitDate: Thu, 14 Feb 2013 16:53:04 +0100

com32/chain: use anonymous and unnamed aggregates

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

---
 com32/chain/chain.c    | 12 ++++----
 com32/chain/mangle.c   | 12 ++++----
 com32/chain/partiter.c | 84 +++++++++++++++++++++++++-------------------------
 com32/chain/partiter.h |  8 ++---
 4 files changed, 58 insertions(+), 58 deletions(-)

diff --git a/com32/chain/chain.c b/com32/chain/chain.c
index 617e9e3..d76c669 100644
--- a/com32/chain/chain.c
+++ b/com32/chain/chain.c
@@ -79,7 +79,7 @@ static int find_by_sig(uint32_t mbr_sig,
 	    pi_del(&boot_part);
 	    continue;
 	}
-	if (boot_part->sub.dos.disk_sig == mbr_sig) {
+	if (boot_part->dos.disk_sig == mbr_sig) {
 	    goto ok;
 	}
     }
@@ -111,12 +111,12 @@ static int find_by_guid(const struct guid *gpt_guid,
 	    continue;
 	}
 	/* Check for a matching GPT disk guid */
-	if (!memcmp(&boot_part->sub.gpt.disk_guid, gpt_guid, sizeof(*gpt_guid))) {
+	if (!memcmp(&boot_part->gpt.disk_guid, gpt_guid, sizeof(*gpt_guid))) {
 	    goto ok;
 	}
 	/* disk guid doesn't match, maybe partition guid will */
 	while (!pi_next(&boot_part)) {
-	    if (!memcmp(&boot_part->sub.gpt.part_guid, gpt_guid, sizeof(*gpt_guid)))
+	    if (!memcmp(&boot_part->gpt.part_guid, gpt_guid, sizeof(*gpt_guid)))
 		goto ok;
 	}
     }
@@ -148,7 +148,7 @@ static int find_by_label(const char *label, struct part_iter **_boot_part)
 	}
 	/* Check for a matching partition */
 	while (!pi_next(&boot_part)) {
-	    if (!strcmp(label, boot_part->sub.gpt.part_label))
+	    if (!strcmp(label, boot_part->gpt.part_label))
 		goto ok;
 	}
     }
@@ -427,7 +427,7 @@ static int setup_handover(const struct part_iter *iter,
     } else if (iter->type == typegpt) {
 	uint32_t *plen;
 	/* GPT handover protocol */
-	synth_size += sizeof *plen + iter->sub.gpt.pe_size;
+	synth_size += sizeof *plen + iter->gpt.pe_size;
 	ha = malloc(synth_size);
 	if (!ha) {
 	    error("Could not build GPT hand-over record!\n");
@@ -447,7 +447,7 @@ static int setup_handover(const struct part_iter *iter,
 	    ha->length = iter->length;
 	/* Next comes the GPT partition record length */
 	plen = (uint32_t *)(ha + 1);
-	plen[0] = iter->sub.gpt.pe_size;
+	plen[0] = iter->gpt.pe_size;
 	/* Next comes the GPT partition record copy */
 	memcpy(plen + 1, iter->record, plen[0]);
 #ifdef DEBUG
diff --git a/com32/chain/mangle.c b/com32/chain/mangle.c
index 69004b8..8185a17 100644
--- a/com32/chain/mangle.c
+++ b/com32/chain/mangle.c
@@ -481,7 +481,7 @@ int mangler_grldr(const struct part_iter *iter)
  */
 static void push_embr(struct part_iter *diter, struct part_iter *siter)
 {
-    if (diter->sub.dos.cebr_lba == siter->sub.dos.cebr_lba &&
+    if (diter->dos.cebr_lba == siter->dos.cebr_lba &&
 	    diter->di.disk == siter->di.disk) {
 	memcpy(diter->data, siter->data, sizeof(struct disk_dos_mbr));
     }
@@ -554,7 +554,7 @@ int manglepe_hide(struct part_iter *miter)
 
 	if (ridx >= 4 && wb && !werr) {
 	    push_embr(miter, iter);
-	    werr |= disk_write_sectors(&iter->di, iter->sub.dos.cebr_lba, iter->data, 1);
+	    werr |= disk_write_sectors(&iter->di, iter->dos.cebr_lba, iter->data, 1);
 	    wb = 0;
 	}
     }
@@ -565,7 +565,7 @@ int manglepe_hide(struct part_iter *miter)
     /* last write */
     if (wb && !werr) {
 	push_embr(miter, iter);
-	werr |= disk_write_sectors(&iter->di, iter->sub.dos.cebr_lba, iter->data, 1);
+	werr |= disk_write_sectors(&iter->di, iter->dos.cebr_lba, iter->data, 1);
     }
     if (werr)
 	error("WARNING: failed to write E/MBR during '*hide*'\n");
@@ -619,11 +619,11 @@ int manglepe_fixchs(struct part_iter *miter)
 
 	wb |= mpe_setchs(&iter->di, dp, iter->start_lba);
 	if (ridx > 4)
-		wb |= mpe_setchs(&iter->di, dp + 1, iter->sub.dos.nebr_lba);
+		wb |= mpe_setchs(&iter->di, dp + 1, iter->dos.nebr_lba);
 
 	if (ridx >= 4 && wb && !werr) {
 	    push_embr(miter, iter);
-	    werr |= disk_write_sectors(&iter->di, iter->sub.dos.cebr_lba, iter->data, 1);
+	    werr |= disk_write_sectors(&iter->di, iter->dos.cebr_lba, iter->data, 1);
 	    wb = 0;
 	}
     }
@@ -634,7 +634,7 @@ int manglepe_fixchs(struct part_iter *miter)
     /* last write */
     if (wb && !werr) {
 	push_embr(miter, iter);
-	werr |= disk_write_sectors(&iter->di, iter->sub.dos.cebr_lba, iter->data, 1);
+	werr |= disk_write_sectors(&iter->di, iter->dos.cebr_lba, iter->data, 1);
     }
     if (werr)
 	error("WARNING: failed to write E/MBR during 'fixchs'\n");
diff --git a/com32/chain/partiter.c b/com32/chain/partiter.c
index 092cca2..9352fcc 100644
--- a/com32/chain/partiter.c
+++ b/com32/chain/partiter.c
@@ -155,8 +155,8 @@ static int iter_dos_ctor(struct part_iter *iter, va_list *args)
 
     memcpy(iter->data, mbr, sizeof(struct disk_dos_mbr));
 
-    iter->sub.dos.bebr_index0 = -1;
-    iter->sub.dos.disk_sig = mbr->disk_sig;
+    iter->dos.bebr_index0 = -1;
+    iter->dos.disk_sig = mbr->disk_sig;
 
     return 0;
 bail:
@@ -207,12 +207,12 @@ static int iter_gpt_ctor(struct part_iter *iter, va_list *args)
 
     memcpy(iter->data, gptl, (size_t)siz);
 
-    iter->sub.gpt.pe_count = (int)gpth->part_count;
-    iter->sub.gpt.pe_size = (int)gpth->part_size;
-    iter->sub.gpt.ufirst = gpth->lba_first_usable;
-    iter->sub.gpt.ulast = gpth->lba_last_usable;
+    iter->gpt.pe_count = (int)gpth->part_count;
+    iter->gpt.pe_size = (int)gpth->part_size;
+    iter->gpt.ufirst = gpth->lba_first_usable;
+    iter->gpt.ulast = gpth->lba_last_usable;
 
-    memcpy(&iter->sub.gpt.disk_guid, &gpth->disk_guid, sizeof(struct guid));
+    memcpy(&iter->gpt.disk_guid, &gpth->disk_guid, sizeof(struct guid));
 
     return 0;
 bail:
@@ -247,7 +247,7 @@ static int notsane_logical(const struct part_iter *iter)
     if (!dp[0].start_lba ||
 	!dp[0].length ||
 	!sane(dp[0].start_lba, dp[0].length) ||
-	end_log > iter->sub.dos.ebr_size) {
+	end_log > iter->dos.ebr_size) {
 
 	error("Insane logical partition.\n");
 	return -1;
@@ -283,7 +283,7 @@ static int notsane_extended(const struct part_iter *iter)
     if (!dp[1].start_lba ||
 	!dp[1].length ||
 	!sane(dp[1].start_lba, dp[1].length) ||
-	end_ebr > iter->sub.dos.bebr_size) {
+	end_ebr > iter->dos.bebr_size) {
 
 	error("Insane extended partition.\n");
 	return -1;
@@ -320,13 +320,13 @@ static int notsane_gpt(const struct part_iter *iter)
 {
     const struct disk_gpt_part_entry *gp;
     gp = (const struct disk_gpt_part_entry *)
-	(iter->data + iter->index0 * iter->sub.gpt.pe_size);
+	(iter->data + iter->index0 * iter->gpt.pe_size);
 
     if (guid_is0(&gp->type))
 	return 0;
 
-    if (gp->lba_first < iter->sub.gpt.ufirst ||
-	gp->lba_last > iter->sub.gpt.ulast) {
+    if (gp->lba_first < iter->gpt.ufirst ||
+	gp->lba_last > iter->gpt.ulast) {
 	error("Insane GPT partition.\n");
 	return -1;
     }
@@ -348,13 +348,13 @@ static int pi_dos_next_mbr(struct part_iter *iter, uint32_t *lba,
 	}
 
 	if (ost_is_ext(dp->ostype)) {
-	    if (iter->sub.dos.bebr_index0 >= 0) {
+	    if (iter->dos.bebr_index0 >= 0) {
 		error("You have more than 1 extended partition.\n");
 		iter->status = PI_INSANE;
 		goto bail;
 	    }
 	    /* record base EBR index */
-	    iter->sub.dos.bebr_index0 = iter->index0;
+	    iter->dos.bebr_index0 = iter->index0;
 	}
 	if (!ost_is_nondata(dp->ostype) || iter->stepall) {
 	    *lba = dp->start_lba;
@@ -372,19 +372,19 @@ static int prep_base_ebr(struct part_iter *iter)
 {
     struct disk_dos_part_entry *dp;
 
-    if (iter->sub.dos.bebr_index0 < 0)	/* if we don't have base extended partition at all */
+    if (iter->dos.bebr_index0 < 0)	/* if we don't have base extended partition at all */
 	return -1;
-    else if (!iter->sub.dos.bebr_start) { /* if not initialized yet */
-	dp = ((struct disk_dos_mbr *)iter->data)->table + iter->sub.dos.bebr_index0;
+    else if (!iter->dos.bebr_start) { /* if not initialized yet */
+	dp = ((struct disk_dos_mbr *)iter->data)->table + iter->dos.bebr_index0;
 
-	iter->sub.dos.bebr_start = dp->start_lba;
-	iter->sub.dos.bebr_size = dp->length;
+	iter->dos.bebr_start = dp->start_lba;
+	iter->dos.bebr_size = dp->length;
 
-	iter->sub.dos.ebr_start = 0;
-	iter->sub.dos.ebr_size = iter->sub.dos.bebr_size;
+	iter->dos.ebr_start = 0;
+	iter->dos.ebr_size = iter->dos.bebr_size;
 
-	iter->sub.dos.cebr_lba = 0;
-	iter->sub.dos.nebr_lba = iter->sub.dos.bebr_start;
+	iter->dos.cebr_lba = 0;
+	iter->dos.nebr_lba = iter->dos.bebr_start;
 
 	iter->index0--;
     }
@@ -401,10 +401,10 @@ static int pi_dos_next_ebr(struct part_iter *iter, uint32_t *lba,
 	return -1;
     }
 
-    while (++iter->index0 < 1024 && iter->sub.dos.nebr_lba) {
+    while (++iter->index0 < 1024 && iter->dos.nebr_lba) {
 	free(iter->data);
 	if (!(iter->data =
-		    disk_read_sectors(&iter->di, iter->sub.dos.nebr_lba, 1))) {
+		    disk_read_sectors(&iter->di, iter->dos.nebr_lba, 1))) {
 	    error("Couldn't load EBR.\n");
 	    iter->status = PI_ERRLOAD;
 	    return -1;
@@ -417,24 +417,24 @@ static int pi_dos_next_ebr(struct part_iter *iter, uint32_t *lba,
 
 	dp = ((struct disk_dos_mbr *)iter->data)->table;
 
-	iter->sub.dos.cebr_lba = iter->sub.dos.nebr_lba;
+	iter->dos.cebr_lba = iter->dos.nebr_lba;
 
 	/* setup next frame values */
 	if (dp[1].ostype) {
-	    iter->sub.dos.ebr_start = dp[1].start_lba;
-	    iter->sub.dos.ebr_size = dp[1].length;
-	    iter->sub.dos.nebr_lba = iter->sub.dos.bebr_start + dp[1].start_lba;
+	    iter->dos.ebr_start = dp[1].start_lba;
+	    iter->dos.ebr_size = dp[1].length;
+	    iter->dos.nebr_lba = iter->dos.bebr_start + dp[1].start_lba;
 	} else {
-	    iter->sub.dos.ebr_start = 0;
-	    iter->sub.dos.ebr_size = 0;
-	    iter->sub.dos.nebr_lba = 0;
+	    iter->dos.ebr_start = 0;
+	    iter->dos.ebr_size = 0;
+	    iter->dos.nebr_lba = 0;
 	}
 
 	if (!dp[0].ostype)
-	    iter->sub.dos.skipcnt++;
+	    iter->dos.skipcnt++;
 
 	if (dp[0].ostype || iter->stepall) {
-	    *lba = iter->sub.dos.cebr_lba + dp[0].start_lba;
+	    *lba = iter->dos.cebr_lba + dp[0].start_lba;
 	    *_dp = dp;
 	    return 0;
 	}
@@ -477,7 +477,7 @@ static struct part_iter *pi_dos_next(struct part_iter *iter)
     if (iter->index0 >= 4 && !dos_part->ostype)
 	iter->index = -1;
     else
-	iter->index = iter->index0 - iter->sub.dos.skipcnt + 1;
+	iter->index = iter->index0 - iter->dos.skipcnt + 1;
     iter->rawindex = iter->index0 + 1;
     iter->start_lba = start_lba;
     iter->length = dos_part->length;
@@ -498,14 +498,14 @@ static void gpt_conv_label(struct part_iter *iter)
     const int16_t *orig_lab;
 
     gp = (const struct disk_gpt_part_entry *)
-	(iter->data + iter->index0 * iter->sub.gpt.pe_size);
+	(iter->data + iter->index0 * iter->gpt.pe_size);
     orig_lab = (const int16_t *)gp->name;
 
     /* caveat: this is very crude conversion */
     for (int i = 0; i < PI_GPTLABSIZE/2; i++) {
-	iter->sub.gpt.part_label[i] = (char)orig_lab[i];
+	iter->gpt.part_label[i] = (char)orig_lab[i];
     }
-    iter->sub.gpt.part_label[PI_GPTLABSIZE/2] = 0;
+    iter->gpt.part_label[PI_GPTLABSIZE/2] = 0;
 }
 
 static struct part_iter *pi_gpt_next(struct part_iter *iter)
@@ -515,9 +515,9 @@ static struct part_iter *pi_gpt_next(struct part_iter *iter)
     if (iter->status)
 	goto bail;
 
-    while (++iter->index0 < iter->sub.gpt.pe_count) {
+    while (++iter->index0 < iter->gpt.pe_count) {
 	gpt_part = (const struct disk_gpt_part_entry *)
-	    (iter->data + iter->index0 * iter->sub.gpt.pe_size);
+	    (iter->data + iter->index0 * iter->gpt.pe_size);
 
 	if (notsane_gpt(iter)) {
 	    iter->status = PI_INSANE;
@@ -528,7 +528,7 @@ static struct part_iter *pi_gpt_next(struct part_iter *iter)
 	    break;
     }
     /* no more partitions ? */
-    if (iter->index0 == iter->sub.gpt.pe_count) {
+    if (iter->index0 == iter->gpt.pe_count) {
 	iter->status = PI_DONE;
 	goto bail;
     }
@@ -538,7 +538,7 @@ static struct part_iter *pi_gpt_next(struct part_iter *iter)
     iter->start_lba = gpt_part->lba_first;
     iter->length = gpt_part->lba_last - gpt_part->lba_first + 1;
     iter->record = (char *)gpt_part;
-    memcpy(&iter->sub.gpt.part_guid, &gpt_part->uid, sizeof(struct guid));
+    memcpy(&iter->gpt.part_guid, &gpt_part->uid, sizeof(struct guid));
     gpt_conv_label(iter);
 
 #ifdef DEBUG
diff --git a/com32/chain/partiter.h b/com32/chain/partiter.h
index 8b47822..4f5a23d 100644
--- a/com32/chain/partiter.h
+++ b/com32/chain/partiter.h
@@ -69,8 +69,8 @@ struct part_iter {
     int status;
     /* internal */
     int index0;
-    union _sub {
-	struct _dos {
+    union {
+	struct {
 	    uint32_t disk_sig;
 	    uint32_t nebr_lba;
 	    uint32_t cebr_lba;
@@ -82,7 +82,7 @@ struct part_iter {
 	    int bebr_index0;
 	    int skipcnt;
 	} dos;
-	struct _gpt {
+	struct {
 	    struct guid disk_guid;
 	    struct guid part_guid;
 	    char part_label[PI_GPTLABSIZE/2+1];
@@ -91,7 +91,7 @@ struct part_iter {
 	    uint64_t ufirst;
 	    uint64_t ulast;
 	} gpt;
-    } sub;
+    };
 };
 
 extern const struct itertype * const typedos;


More information about the Syslinux-commits mailing list