WARNING - OLD ARCHIVES

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/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

On Tue, Mar 22, 2005 at 11:05:03AM -0600, Anthony Liguori wrote:
> Christian Limpach wrote:
> 
> >You mean like using `%m' in your format string to syslog(3)?
> > 
> >
> '%m' is a GNU extension.

It exists in the BSD's implementations and it is documented in SUS V3.
In any case, the point was that while you can argue that management
applications might not use perror, warn or err, you can't really
argue that there won't be at least one library usable for developing
management applications which supports printing error messages depending
on the value of errno.

> >While most other people's test code would look like this:
> >
> >domid = dom_create_domain(3000, 0);
> >if (domid < 0)
> > err(1, "dom_create_domain");
> >
> >I claim that this is what more people are used to since most libraries
> >support this interface, i.e. return _value_ with documented specific
> >error values, failure condition in errno and error reporting using one
> >of the various standard functions.
> > 
> >
> There seems to be wide consensus on this one though and I don't seem to 
> have the popular opinion.  So perhaps we can comprimise.  What about:
> 
> 1) Have most functions return an integer.  An error is indicated if the 
> return is < 0.  In the event of an error, the function will return 
> -errno but make sure to set errno properly.
> 
> 2) For functions that want to return addresses, they can do so and 
> return NULL on error.  Since all functions set errno properly, errno 
> will have to be used for extended error conditions on these functions.
> 
> This should make everyone happy.   Your code will work just fine and an 
> application developer can avoid using errno.  Thoughts?

It's inconsistent.  Why would anybody examine errno for the 2nd type
of functions and then not do so for the 1st type?

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?

    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
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-devel

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