home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / sgi / 18225 < prev    next >
Encoding:
Internet Message Format  |  1992-12-21  |  1.6 KB

  1. Xref: sparky comp.sys.sgi:18225 comp.sys.sgi.bugs:23 comp.unix.ultrix:8985
  2. Newsgroups: comp.sys.sgi,comp.sys.sgi.bugs,comp.unix.ultrix
  3. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!saimiri.primate.wisc.edu!ames!sgi!fido!zola!zuni!anchor!olson
  4. From: olson@anchor.esd.sgi.com (Dave Olson)
  5. Subject: Re: tempnam(3S) bug, possibly on all MIPS
  6. Message-ID: <tqcnepk@zuni.esd.sgi.com>
  7. Sender: news@zuni.esd.sgi.com (Net News)
  8. Organization:  Silicon Graphics, Inc.  Mountain View, CA
  9. References: <1gu849INNp6k@menudo.uh.edu>
  10. Date: Sat, 19 Dec 92 22:17:00 GMT
  11. Lines: 33
  12.  
  13. In <1gu849INNp6k@menudo.uh.edu> svec5@menudo.uh.edu (T.C. Zhao) writes:
  14.  
  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. |  * check to see if tempnam has the errno bug.
  19. |  */
  20. | #include <stdio.h>
  21. | #include <stdlib.h>
  22. | #include <unistd.h>
  23. | #include <errno.h>
  24. | int main(int argc, char **argv)
  25. | {
  26. |    char *p;
  27. |    errno = 0;
  28. |    p = tempnam(0, 0);
  29. |    if(errno) fprintf(stderr," tempnam is broken\n");
  30. |    return 0;
  31. | }
  32.  
  33. It isn't a bug.  The bug is in your code.  errno is only supposed
  34. to be tested after failures of system calls or other library
  35. routines that document that they set errno on failure.
  36.  
  37. Since tempnam() needs to make sure the file it is existing doesn't
  38. exist, it isn't surprising that errno is set (but you shouldn't
  39. count on it either way!).
  40. --
  41. Let no one tell me that silence gives consent,  |   Dave Olson
  42. because whoever is silent dissents.             |   Silicon Graphics, Inc.
  43.     Maria Isabel Barreno                        |   olson@sgi.com
  44.