[MINC-development] patches for tmpnam
Steve ROBBINS
minc-development@bic.mni.mcgill.ca
Wed, 5 Mar 2003 22:07:06 -0500
On Mon, Mar 03, 2003 at 05:06:51PM -0500, Vicka Corey wrote:
> Hi -- here are the changes I've put in to get rid of gcc warnings
> from calls to tmpnam().
The changes you propose will cause file descriptor leakage which
is not acceptable, especially not in a library.
It's true that you can get around that by closing the file
descriptor returned by mkstemp(), but that really misses the
point of the warnings. The linker is warning you of a race
condition. If the tmpnam() calls are going to be replaced,
the race ought to be fixed. There's no point in doing it just
to get rid of a link warning.
-Steve
P.S. GCC 3 no longer emits this particular warning, anyway.
P.P.S. The man page for mkstemp() on my system says "Don't use this function,
use tmpfile(3) instead. It is better defined and more portable."