From: Christian Franke <Christian.Franke@t-online.de>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] biosdisk, getroot for Cygwin
Date: Sun, 11 May 2008 23:04:39 +0200 [thread overview]
Message-ID: <48275F67.8050408@t-online.de> (raw)
In-Reply-To: <48248ABA.5010704@t-online.de>
Christian Franke wrote:
> Robert Millan wrote:
>> On Wed, May 07, 2008 at 10:42:23PM +0200, Christian Franke wrote:
>>> +#ifndef __CYGWIN__
>>> #ifdef __linux__
>>> /* We first try to find the device in the /dev/mapper directory. If
>>> we don't do this, we get useless device names like /dev/dm-0 for
>>> @@ -242,12 +373,19 @@ grub_guess_root_device (const char *dir)
>>> os_dev = find_root_device ("/dev", st.st_dev);
>>> }
>>>
>>> +#else
>>> + /* Cygwin specific function. */
>>> + os_dev = find_cygwin_root_device (dir, st.st_dev);
>>> +
>>> +#endif /* __CYGWIN__ */
>>>
>>
>> The logic here seems a bit over-complicated. Surely whenever you
>> have __linux__
>> you don't have __CYGWIN__. Are you sure it can't be simplified?
>>
>>
>
> An alternative would be to move the #ifndef __CYGWIN__ behind the
> #ifdef __linux__ block:
>
> #ifdef __linux__
> ...
> os_dev = find_root_device ("/dev/mapper", st.st_dev);
> ...
> if (! os_dev)
> #endif
> #ifndef __CYGWIN__
> {
> /* This might be truly slow, but is there any better way? */
> os_dev = find_root_device ("/dev", st.st_dev);
> }
>
> #else /* __CYGWIN__ */
> /* Cygwin specific function. */
> os_dev = find_cygwin_root_device (dir, st.st_dev);
>
> #endif /* __CYGWIN__ */
>
>
> I'm not sure whether this would be more readable.
>
Probably more readable and extensible - Use early returns:
#ifdef __linux__
/* We first try to find the device in the /dev/mapper directory. If
we don't do this, we get useless device names like /dev/dm-0 for
LVM. */
os_dev = find_root_device ("/dev/mapper", st.st_dev);
if (os_dev)
return os_dev;
/* The same applies to /dev/evms directory (for EVMS volumes). */
os_dev = find_root_device ("/dev/evms", st.st_dev);
if (os_dev)
return os_dev;
#endif /* __linux__ */
#ifndef __CYGWIN__
/* This might be truly slow, but is there any better way? */
os_dev = find_root_device ("/dev", st.st_dev);
#else /* __CYGWIN__ */
/* Cygwin specific function. */
os_dev = find_cygwin_root_device (dir, st.st_dev);
#endif /* __CYGWIN__ */
return os_dev;
}
Christian
next prev parent reply other threads:[~2008-05-11 21:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-23 20:30 [PATCH] biosdisk, getroot for Cygwin Christian Franke
2008-05-07 20:42 ` Christian Franke
2008-05-09 12:45 ` Robert Millan
2008-05-09 17:32 ` Christian Franke
2008-05-11 21:04 ` Christian Franke [this message]
2008-05-12 15:25 ` Robert Millan
2008-05-13 21:17 ` Christian Franke
2008-05-16 21:43 ` Christian Franke
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=48275F67.8050408@t-online.de \
--to=christian.franke@t-online.de \
--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.