mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 01/12] partitions: dos: save indention level
Date: Mon, 19 Feb 2024 09:31:29 +0100	[thread overview]
Message-ID: <20240219083140.2713047-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20240219083140.2713047-1-s.hauer@pengutronix.de>

Save an indention level by continuing early in the loop.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/partitions/dos.c | 52 +++++++++++++++++++++--------------------
 1 file 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");
 		}
 	}
 
-- 
2.39.2




  reply	other threads:[~2024-02-19  8:32 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-19  8:31 [PATCH 00/12] Partition table manipulation support Sascha Hauer
2024-02-19  8:31 ` Sascha Hauer [this message]
2024-02-19  8:31 ` [PATCH 02/12] partition: allocate struct partition_desc in parser Sascha Hauer
2024-02-19  8:31 ` [PATCH 03/12] partition: allocate struct partition " Sascha Hauer
2024-02-19  8:31 ` [PATCH 04/12] partition: efi: keep raw data Sascha Hauer
2024-02-19  8:31 ` [PATCH 05/12] uuid: implement random uuid/guid Sascha Hauer
2024-02-19  8:31 ` [PATCH 06/12] linux/sizes.h: add more defines Sascha Hauer
2024-02-19  8:31 ` [PATCH 07/12] partition: add PARTITION_LINUX_DATA_GUID define Sascha Hauer
2024-02-19  8:31 ` [PATCH 08/12] partitions: move parser.h to include/partitions.h Sascha Hauer
2024-02-19  8:31 ` [PATCH 09/12] partitions: implement partition manipulation support Sascha Hauer
2024-02-19  8:31 ` [PATCH 10/12] partitions: dos: " Sascha Hauer
2024-02-28 17:37   ` Ahmad Fatoum
2024-02-29  7:16     ` Sascha Hauer
2024-02-19  8:31 ` [PATCH 11/12] partitions: efi: " Sascha Hauer
2024-02-28 17:36   ` Ahmad Fatoum
2024-02-19  8:31 ` [PATCH 12/12] commands: add parted Sascha Hauer
2024-02-19  9:38   ` Ulrich Ölmann
2024-02-20 10:47 ` [PATCH 00/12] Partition table manipulation support Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240219083140.2713047-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox