All of lore.kernel.org
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: Eugene Korenevsky <ekorenevsky@gmail.com>,
	linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: Re: [PATCH v3] efi: take size of partition entry from GPT header
Date: Wed, 12 Sep 2018 11:55:17 -0700	[thread overview]
Message-ID: <20180912185517.GE3902@linux-r8p5> (raw)
In-Reply-To: <20180912183519.GA31506@vnote>

On Wed, 12 Sep 2018, Eugene Korenevsky wrote:
> /**
>  * efi_partition(struct parsed_partitions *state)
>  * @state: disk parsed partitions
>@@ -704,32 +710,36 @@ int efi_partition(struct parsed_partitions *state)
>
> 	pr_debug("GUID Partition Table is valid!  Yea!\n");
>
>-	for (i = 0; i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1; i++) {
>+	for (i = 0;
>+	     i < le32_to_cpu(gpt->num_partition_entries) && i < state->limit-1;
>+	     i++) {

Please rearrange this like:

       for (i = 0;  < le32_to_cpu(gpt->num_partition_entries) &&
       	      	      i < state->limit-1; i++)

>+		gpt_entry *pte = get_gpt_entry(gpt, ptes, i);
> 		struct partition_meta_info *info;
> 		unsigned label_count = 0;
> 		unsigned label_max;
>-		u64 start = le64_to_cpu(ptes[i].starting_lba);
>-		u64 size = le64_to_cpu(ptes[i].ending_lba) -
>-			   le64_to_cpu(ptes[i].starting_lba) + 1ULL;
>+		u64 start = le64_to_cpu(pte->starting_lba);
>+		u64 size = le64_to_cpu(pte->ending_lba) -
>+			   le64_to_cpu(pte->starting_lba) + 1ULL;
>
>-		if (!is_pte_valid(&ptes[i], last_lba(state->bdev)))
>+		if (!is_pte_valid(pte, last_lba(state->bdev)))
> 			continue;
>
> 		put_partition(state, i+1, start * ssz, size * ssz);
>
> 		/* If this is a RAID volume, tell md */
>-		if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_RAID_GUID))
>+		if (!efi_guidcmp(
>+		    pte->partition_type_guid, PARTITION_LINUX_RAID_GUID))

This is ugly. If you are worried about 80-chars, please do:

     	      	 if (!efi_guidcmp(pte->partition_type_guid,
				PARTITION_LINUX_RAID_GUID))

Thanks,
Davidlohr

  reply	other threads:[~2018-09-12 18:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-12 18:35 [PATCH v3] efi: take size of partition entry from GPT header Eugene Korenevsky
2018-09-12 18:55 ` Davidlohr Bueso [this message]
2018-09-13 13:25   ` David Laight
2018-09-13 19:44     ` Eugene Korenevsky

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=20180912185517.GE3902@linux-r8p5 \
    --to=dave@stgolabs.net \
    --cc=ard.biesheuvel@linaro.org \
    --cc=ekorenevsky@gmail.com \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.