*BSD News Article 56141


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.mel.connect.com.au!yarrina.connect.com.au!munnari.OZ.AU!spool.mu.edu!howland.reston.ans.net!gatech2!swrinde!elroy.jpl.nasa.gov!lll-winken.llnl.gov!taco.cc.ncsu.edu!crazytrain.eos.ncsu.edu!not-for-mail
From: kpneal@eos.ncsu.edu (Kevin P. Neal)
Newsgroups: comp.unix.bsd.netbsd.misc
Subject: Re: Thread safe errno-clone?
Date: 29 Nov 1995 22:24:08 GMT
Organization: North Carolina State University
Lines: 42
Message-ID: <49imi8$1u2@taco.cc.ncsu.edu>
References: <49bqi3$4du@taco.cc.ncsu.edu> <30BCA91B.41C67EA6@FreeBSD.org>
NNTP-Posting-Host: crazytrain.eos.ncsu.edu
X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]

Jordan K. Hubbard (jkh@FreeBSD.org) wrote:
: I wouldn't follow in the footsteps of the errno botch if I could help
: it.  Are you sure you can't simply incorporate the concept of some sort
: of error return into your RCS library API?  Then the thread safety
: question becomes moot.

1) Why is errno a botch?

2) There are cases where a function can fail for more than one reason.
If it is returning, for example, a NULL pointer, why did it?

Or is this a better idea:
int function(int &data2return, int arg...)
{
        int errorcode=0; /* 0 for no error */

        ...
        return(errorcode);
}

then call the function with if (!(function(blahblah)) { /* it worked!*/

Is that a better way?

Because it will take very large changes to the RCS source to get RCS
to propagate the error codes back. It's not written very well after 
all of these years (some of it goes back to '82).

There are cases where functions can fail for more than one reason,
how do I get that back through the innards of the library back to the
user app? Also, if a function deep in the innards of the library fails,
it will take lots of work to the library to return the deep dark
error code to the user app. 

An errno clone seemed like a quick and easy way to bypass all of this mess,
otherwise, there is ALOT of tossing of code that I get to do.

-- 
XCOMM --------------------------------------------------------
XCOMM Kevin P. Neal, Sophomore CSC/CPE     kpneal@eos.ncsu.edu 
XCOMM North Carolina State University      kevinneal@bix.com
XCOMM --------------------------------------------------------