change to ee.c

Tim Kientzle kientzle at freebsd.org
Sun Nov 30 11:41:54 PST 2008


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


More information about the freebsd-hackers mailing list