Eitan Adler wrote:
Xin LI wrote:

Tanks for interested in this but I'm afraid that your patch is
incorrect.  mkstemp returns a file descriptor rather than a string
pointer, therefore, the subsequent open() would have undefined behavior.
It looks like that we actually want fd = mkstemp() here.

Thanks.  If this is the case how come gcc did not return any warnings?

Try to think of compiler warnings as a luxury.
For a variety of reasons (some having to do with
the somewhat permissive nature of the C language),
it's extremely hard for the compiler to detect
anything other than the most blatant screw-ups.

Whenever using a new function, pay very careful
attention to the man pages:

  man mkstemp

clearly says that mkstemp returns a file descriptor:

  "The mkstemp() function ... creates the template
  file, mode 0600, returning a file descriptor opened
  for reading and writing."

Tim
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to