From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anthony Liguori Subject: Re: [PATCH] libxen-3.0 (libxc rewrite) Date: Tue, 22 Mar 2005 11:53:54 -0600 Message-ID: <42405BB2.8040604@us.ibm.com> References: <423F3BB5.3020600@us.ibm.com> <3d8eece2050322030245ed31b@mail.gmail.com> <4240340F.8080600@us.ibm.com> <20050322160146.GQ31328@cl.cam.ac.uk> <42404294.6000101@us.ibm.com> <20050322161350.GR31328@cl.cam.ac.uk> <424045FF.5000908@us.ibm.com> <20050322164154.GS31328@cl.cam.ac.uk> <4240503F.5000607@us.ibm.com> <20050322174739.GT31328@cl.cam.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit In-Reply-To: <20050322174739.GT31328@cl.cam.ac.uk> Sender: xen-devel-admin@lists.sourceforge.net Errors-To: xen-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: Christian Limpach Cc: Ian Pratt , xen-devel List-Id: xen-devel@lists.xenproject.org Christian Limpach wrote: >So far your only point for not using errno has been that the programmer >can inadvertently overwrite it by calling a function which resets it before >using its value. But even that now seems a moot point since it can still >happen with the 2nd type of functions. What's your problem with errno? > > It's too easy to overwrite. Error paths are rarely invoked so if you're overwriting errno in your error path the chances of you realizing you're doing that is low. This is a real problem. If you don't believe me, look at libxc. In fact, the first file I opened, xc_private.c, has that problem exact problem in the first function (xc_map_foreign_batch()). If the function fails for any reason, it does cleanup (while also calling perror). The cleanup function (munmap) will squash errno. This function would have to save errno after the ioctl, then restore it after the cleanup was done. That's ugly and most programmers don't think to do it. Regards, Anthony Liguori > christian > > > > ------------------------------------------------------- This SF.net email is sponsored by: 2005 Windows Mobile Application Contest Submit applications for Windows Mobile(tm)-based Pocket PCs or Smartphones for the chance to win $25,000 and application distribution. Enter today at http://ads.osdn.com/?ad_id=6882&alloc_id=15148&op=click