Date: Sun, 30 Nov 2008 11:41:30 -0800 From: Tim Kientzle <kientzle@freebsd.org> To: Eitan Adler <eitanadlerlist@gmail.com> Cc: freebsd-hackers@freebsd.org, d@delphij.net Subject: Re: change to ee.c Message-ID: <4932EC6A.1070205@freebsd.org> In-Reply-To: <493214DC.2080904@gmail.com> References: <49320FF7.4040901@gmail.com> <4932122A.8070209@delphij.net> <493214DC.2080904@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4932EC6A.1070205>
