diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-19 09:31:29 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-20 11:46:30 +0100 |
commit | 4accc68d2d5155074455109f5889f8c00b30eafc (patch) | |
tree | cdb22eb299240facf7ed712105404d183c272a38 | |
parent | 6a191155be4e2a91003488fd8c2e4725ac92294d (diff) | |
download | barebox-4accc68d2d51.tar.gz barebox-4accc68d2d51.tar.xz |
partitions: dos: save indention level
Save an indention level by continuing early in the loop.
Link: https://lore.barebox.org/20240219083140.2713047-2-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | common/partitions/dos.c | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/common/partitions/dos.c b/common/partitions/dos.c index 7472824b00..56ec1e3f48 100644 --- a/common/partitions/dos.c +++ b/common/partitions/dos.c @@ -190,36 +190,38 @@ static void dos_partition(void *buf, struct block_device *blk, table = (struct partition_entry *)&buffer[446]; for (i = 0; i < 4; i++) { + int n; + pentry.first_sec = get_unaligned_le32(&table[i].partition_start); pentry.size = get_unaligned_le32(&table[i].partition_size); pentry.dos_partition_type = table[i].type; - if (pentry.first_sec != 0) { - int n = pd->used_entries; - pd->parts[n].first_sec = pentry.first_sec; - pd->parts[n].size = pentry.size; - pd->parts[n].dos_partition_type = pentry.dos_partition_type; - if (signature) - sprintf(pd->parts[n].partuuid, "%08x-%02d", - signature, i + 1); - pd->used_entries++; - - if (is_extended_partition(&pentry)) { - pd->parts[n].size = 2; - - if (!extended_partition) - extended_partition = &pd->parts[n]; - else - /* - * An DOS MBR must only contain a single - * extended partition. Just ignore all - * but the first. - */ - dev_warn(blk->dev, "Skipping additional extended partition\n"); - } - - } else { + if (pentry.first_sec == 0) { dev_dbg(blk->dev, "Skipping empty partition %d\n", i); + continue; + } + + n = pd->used_entries; + pd->parts[n].first_sec = pentry.first_sec; + pd->parts[n].size = pentry.size; + pd->parts[n].dos_partition_type = pentry.dos_partition_type; + if (signature) + sprintf(pd->parts[n].partuuid, "%08x-%02d", + signature, i + 1); + pd->used_entries++; + + if (is_extended_partition(&pentry)) { + pd->parts[n].size = 2; + + if (!extended_partition) + extended_partition = &pd->parts[n]; + else + /* + * An DOS MBR must only contain a single + * extended partition. Just ignore all + * but the first. + */ + dev_warn(blk->dev, "Skipping additional extended partition\n"); } } |