From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JvIiz-0003Vs-FX for mharc-grub-devel@gnu.org; Sun, 11 May 2008 17:04:53 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JvIiy-0003Vn-Hd for grub-devel@gnu.org; Sun, 11 May 2008 17:04:52 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JvIix-0003VT-Sf for grub-devel@gnu.org; Sun, 11 May 2008 17:04:52 -0400 Received: from [199.232.76.173] (port=44688 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JvIix-0003VQ-MW for grub-devel@gnu.org; Sun, 11 May 2008 17:04:51 -0400 Received: from mailout06.t-online.de ([194.25.134.19]:33535) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JvIix-0000Xf-5s for grub-devel@gnu.org; Sun, 11 May 2008 17:04:51 -0400 Received: from fwd35.aul.t-online.de by mailout06.sul.t-online.de with smtp id 1JvIis-0002dY-00; Sun, 11 May 2008 23:04:46 +0200 Received: from [10.3.2.2] (S+CuI4ZHwhkSXN7NRgbtW5TMrKBbBconEPAeBKMplqttMCUayRu9XQfEascNOUEQmb@[217.235.254.246]) by fwd35.aul.t-online.de with esmtp id 1JvIik-0yVaF60; Sun, 11 May 2008 23:04:38 +0200 Message-ID: <48275F67.8050408@t-online.de> Date: Sun, 11 May 2008 23:04:39 +0200 From: Christian Franke User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071128 SeaMonkey/1.1.7 MIME-Version: 1.0 To: The development of GRUB 2 References: <47473879.1020004@t-online.de> <4822142F.1040505@t-online.de> <20080509124506.GA3705@thorin> <48248ABA.5010704@t-online.de> In-Reply-To: <48248ABA.5010704@t-online.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ID: S+CuI4ZHwhkSXN7NRgbtW5TMrKBbBconEPAeBKMplqttMCUayRu9XQfEascNOUEQmb X-TOI-MSGID: 328c5d06-28b2-4af6-a9d2-8c1fb0989ecf X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Subject: Re: [PATCH] biosdisk, getroot for Cygwin X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 May 2008 21:04:52 -0000 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