home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / sgi / 18320 < prev    next >
Encoding:
Internet Message Format  |  1992-12-23  |  2.5 KB

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