From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JOtLn-0008Dd-RJ for mharc-grub-devel@gnu.org; Tue, 12 Feb 2008 06:30:59 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JOtLm-0008Bm-0N for grub-devel@gnu.org; Tue, 12 Feb 2008 06:30:58 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JOtLk-0008AN-0b for grub-devel@gnu.org; Tue, 12 Feb 2008 06:30:57 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JOtLj-0008AK-Rj for grub-devel@gnu.org; Tue, 12 Feb 2008 06:30:55 -0500 Received: from aybabtu.com ([69.60.117.155]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JOtLj-00034g-Dg for grub-devel@gnu.org; Tue, 12 Feb 2008 06:30:55 -0500 Received: from [192.168.10.6] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1JOtLb-0002RM-Cg for grub-devel@gnu.org; Tue, 12 Feb 2008 12:30:49 +0100 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1JOtJr-00052d-3M for grub-devel@gnu.org; Tue, 12 Feb 2008 12:28:59 +0100 Date: Tue, 12 Feb 2008 12:28:59 +0100 From: Robert Millan To: The development of GRUB 2 Message-ID: <20080212112859.GA19144@thorin> References: <47B16BB1.2000006@leat.rub.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <47B16BB1.2000006@leat.rub.de> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: Re: [PATCH] Add option to grub-probe to accept system devices as arguments 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: Tue, 12 Feb 2008 11:30:58 -0000 On Tue, Feb 12, 2008 at 10:49:37AM +0100, Fabian Greffrath wrote: > >You put that function in a separate file, which indicates it is meant to be > >a general-purpose function, but its spec is constrained by the code in > >grub-probe (i.e. you strdup() not because it is needed for the purpose of > >this function, but because grub-probe already calls free()). > > That's right. Consequently there are two alternatives left: > > - grub_util_check_block_device() returns the pointer instead of strdup() > and the > call to free() in grub-probe is conditional upon if argument_is_device is > true > or false; which I consider an ugly hack. > > - I keep getroot.{c,h} untouched and include these four lines in grub-probe; > which is a pity because I consider the function quite usefull, though still > not > perfect (see above). That's why I proposed to pass both path and device, and let either of them be NULL. When you do this: - You can determine whether `device' is provided (hence you can skip converting from `path') simply with "if (device)". - You can make the free() part independant of any other indications by issuing: if (device) free (device); if (path) free (path); -- Robert Millan I know my rights; I want my phone call! What use is a phone call… if you are unable to speak? (as seen on /.)