home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.sgi:18320 comp.sys.sgi.bugs:40 comp.unix.ultrix:9068
- Newsgroups: comp.sys.sgi,comp.sys.sgi.bugs,comp.unix.ultrix
- Path: sparky!uunet!psinntp!pixar!aaa
- From: aaa@pixar.com (Tony Apodaca)
- Subject: Re: tempnam(3S) bug, possibly on all MIPS
- Message-ID: <1992Dec24.011451.497@pixar.com>
- Sender: news@pixar.com (Usenet Newsmaster)
- Nntp-Posting-Host: monstro.pixar.com
- Organization: Pixar - Pt. Richmond, CA USA
- References: <1gu849INNp6k@menudo.uh.edu> <tqcnepk@zuni.esd.sgi.com>
- Date: Thu, 24 Dec 1992 01:14:51 GMT
- Lines: 38
-
- In an article, svec5@menudo.uh.edu (T.C. Zhao) writes:
- >| It appears that tempnam(3S) is broken on three MIPS machines I have
- >| access to: IRIX 3.3, Ultrix 4.1, UMIPS 4.52:
-
- In an article, olson@anchor.esd.sgi.com (Dave Olson) writes:
- >Since tempnam() needs to make sure the file it is existing doesn't
- >exist, it isn't surprising that errno is set (but you shouldn't
- >count on it either way!).
-
- In an article, murphy@ufp.dco.dec.com (Rick Murphy) writes:
- >Looking at errno after calling a library routine that hasn't failed isn't
- >a useful thing to do. The call succeeded - you've got no reason to go looking
- >at errno.
-
- This is not really the point. The point is that a smart programmer
- checks errno after every system call. So, at some point in your program,
- after returning from a system call, you notice that errno is set, and you
- probably perror() and go to some error correcting code. Of course, what
- you don't realize (for several days of debugging! I know, I was there!!)
- is that the system call you issued had nothing to do with it. errno had
- been set as a side-effect of tmpnam() in a different module in a different
- file hundreds of lines of code ago. This is totally unexpected (and
- I might add totally undocumented) behavior, and it is a pain in the butt.
- It makes you go into defensive programming mode, setting errno to 0 before
- every system call because you don't know if there are any *other* library
- routines which break the rules and have unexpected unfriendly side effects
- like this.
-
- Okay, maybe I'm exaggerating to make a point, but I don't think
- it's fair to insinuate that Mr. Zhao is wrong. It *is* a bug, in the
- following sense: the man pages explicitly state that errno is set if a
- system call gets an error, but is untouched otherwise. I think library
- utility functions fall into the "otherwise" category, don't you?
-
- --
- UUCP: {uupsi,ucbvax}!pixar!aaa Tony Apodaca
- Internet: aaa@pixar.com Pixar, Richmond, CA, USA
- "And in the end, the love you take is equal to the love you make."
-