Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1NCLn0-0004Ky-3t for mharc-grub-devel@gnu.org; Sun, 22 Nov 2009 18:24:18 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NCLmx-0004KS-P3 for grub-devel@gnu.org; Sun, 22 Nov 2009 18:24:15 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NCLms-0004IW-TD for grub-devel@gnu.org; Sun, 22 Nov 2009 18:24:14 -0500 Received: from [199.232.76.173] (port=37308 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NCLms-0004IR-Pa for grub-devel@gnu.org; Sun, 22 Nov 2009 18:24:10 -0500 Received: from 197.red-80-32-81.staticip.rima-tde.net ([80.32.81.197]:56637 helo=mail.pina.cat) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NCLms-0008VI-6Y for grub-devel@gnu.org; Sun, 22 Nov 2009 18:24:10 -0500 Received: from pinux (82-45-164-87.cable.ubr06.hari.blueyonder.co.uk [82.45.164.87]) by mail.pina.cat (Postfix) with ESMTP id 2C0BC288FBA2F for ; Mon, 23 Nov 2009 00:24:09 +0100 (CET) Received: by pinux (Postfix, from userid 1000) id A3AEE8045; Sun, 22 Nov 2009 23:24:14 +0000 (GMT) Date: Sun, 22 Nov 2009 23:24:14 +0000 From: Carles Pina i Estany To: The development of GNU GRUB Message-ID: <20091122232414.GA19685@pina.cat> References: <20091122171919.GD11942@pina.cat> <20091122213240.GA13203@thorin> <20091122224203.GC5440@pina.cat> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20091122224203.GC5440@pina.cat> User-Agent: Mutt/1.5.20 (2009-06-14) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: errno handling X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Nov 2009 23:24:16 -0000 Hi, On Nov/22/2009, Carles Pina i Estany wrote: > > Hello, > > On Nov/22/2009, Robert Millan wrote: > > On Sun, Nov 22, 2009 at 05:19:19PM +0000, Carles Pina i Estany wrote: > > > > > > Hello, > > > > > > Last night I spent some time with a confussion that maybe it can be > > > avoided (or maybe not). > > > > > > Let's say that a module calls grub_file_open and it fails (file doesn't > > > exist or whatever). grub_errno is setted up. > > > > > > This module is not resetting grub_errno and makes another call to > > > grub_file_open with a valid file. But grub_file_open does: > > > > In theory, each layer should check errno after a call that may be > > setting it. It's up to the layer whether errno has to be ignored > > (and reset), handled or passed to the upper layer. > > In my opinion grub_file_open should reset grub_errno because > grub_file_open behaviour is different up to the grub_errno when it > enters in the function (if grub_errno != GRUB_ERRNO then grub_file_open > will not open any file). And this for more functions. discussed in irc with phcoder: no changes here because would be a caller bug. Some day I will take a look on a possible callers that are not resetting grub_errno after functions that are setting up (so can lead to problems later) The discussion: cpina: there is nothing wrong with red herring on bugs for the sake of kernel size phcoder: so you would not touch grub_file_open to keep the size as small as possible in the kernel and move this code to the users of grub_file_open? to keep the kernel size as you can understand :-) cpina: it's not what I said. Caller has to handle error return. If it doesn't it's a bug. If caller bugs core is allowed to do anything it wants phcoder: i understand, but when i design api's i try to make it hard for the users to miss-use the api. And in this case it's easy to miss-use the api. cpina: with grub we have other requirements. If it really bothers you so much you can add assertions which would be enabled with ./configure --debug-mode ... Cheers, -- Carles Pina i Estany http://pinux.info