From: Johan Rydberg <jrydberg@night.trouble.net>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH 3/3] grub EFI disk device enumberating
Date: Tue, 24 Oct 2006 15:11:19 +0200 [thread overview]
Message-ID: <87fydd3ll4.fsf@night.trouble.net> (raw)
In-Reply-To: <453DBE9A.7040300@intel.com> (mao bibo's message of "Tue, 24 Oct 2006 15:19:54 +0800")
[-- Attachment #1: Type: text/plain, Size: 1892 bytes --]
"bibo,mao" <bibo.mao@intel.com> writes:
> Previously I posted this patch, now I repost again.
> Any suggestion is welcome.
I will just give a comment here. Please do not treat it as a full
review, I'll leave that to Okuji.
> +static int compare_ancestor_path(const grub_efi_device_path_t *parent,
> + const grub_efi_device_path_t *dp2)
> +{
> [...]
> + while (1)
> + {
> + grub_efi_uint8_t type1, type2;
> + grub_efi_uint8_t subtype1, subtype2;
> + grub_efi_uint16_t len1, len2;
> + int ret;
> +
> + if (GRUB_EFI_END_ENTIRE_DEVICE_PATH(parent))
> + break;
> +
> + type1 = GRUB_EFI_DEVICE_PATH_TYPE (parent);
> + type2 = GRUB_EFI_DEVICE_PATH_TYPE (dp2);
> +
> + if (type1 != type2)
> + return (int) type2 - (int) type1;
> +
> + subtype1 = GRUB_EFI_DEVICE_PATH_SUBTYPE (parent);
> + subtype2 = GRUB_EFI_DEVICE_PATH_SUBTYPE (dp2);
> +
> + if (subtype1 != subtype2)
> + return (int) subtype1 - (int) subtype2;
> +
> + len1 = GRUB_EFI_DEVICE_PATH_LENGTH (parent);
> + len2 = GRUB_EFI_DEVICE_PATH_LENGTH (dp2);
> +
> + if (len1 != len2)
> + return (int) len1 - (int) len2;
> +
> + ret = grub_memcmp (parent, dp2, len1);
> + if (ret != 0)
> + return ret;
> +
> + parent = (grub_efi_device_path_t *) ((char *) parent + len1);
> + dp2 = (grub_efi_device_path_t *) ((char *) dp2 + len2);
This code can be shorter; you only have to compare the lengths. If
they match, you can do a memcmp on the whole device path.
Also, can you guarantee that the child path "dp2" is longer than the
parent path? What it does is that it checks if "parent" is a subpath
of "dp2", so a function name reflecting that probably fits better.
Name functions after what they do, not what they are used to. Better
argument names are also welcome.
~j
[-- Attachment #2: Type: application/pgp-signature, Size: 190 bytes --]
next prev parent reply other threads:[~2006-10-24 12:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-24 7:19 [PATCH 3/3] grub EFI disk device enumberating bibo,mao
2006-10-24 13:11 ` Johan Rydberg [this message]
2006-10-24 14:05 ` Johan Rydberg
2006-10-25 5:43 ` bibo,mao
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=87fydd3ll4.fsf@night.trouble.net \
--to=jrydberg@night.trouble.net \
--cc=grub-devel@gnu.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.