This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
Home Products Support Community News


Re: [Xen-devel] [PATCH] libxen-3.0 (libxc rewrite)

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.

Anthony Liguori


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
Xen-devel mailing list

<Prev in Thread] Current Thread [Next in Thread>