diff --git a/src/cl65/main.c b/src/cl65/main.c index 900602c87..8d8aac932 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -673,7 +673,7 @@ static void Compile (const char* File) if (DoAssemble) { /* set a temporary output file name */ - TmpFile = MakeTmpFilename(File, ".s"); + TmpFile = MakeTmpFilename(".s"); CmdSetOutput (&CC65, TmpFile); } diff --git a/src/common/fname.c b/src/common/fname.c index c5000bc72..f026f776d 100644 --- a/src/common/fname.c +++ b/src/common/fname.c @@ -119,16 +119,26 @@ char* MakeFilename (const char* Origin, const char* Ext) -char* MakeTmpFilename (const char* Origin, const char* Ext) +char* MakeTmpFilename (const char* Ext) /* Make a new temporary file name from Ext. tmpnam(3) is called -** and Ext is appended to generate the filename. Origin is ignored. +** and Ext is appended to generate the filename. ** The result is placed in a malloc'ed buffer and returned. */ { char* Out; char Buffer[L_tmpnam * 2]; /* a lazy way to ensure we have space for Ext */ - tmpnam(Buffer); + /* + ** gcc emits the following warning here: + ** + ** warning: the use of `tmpnam' is dangerous, better use `mkstemp' + ** + ** however, mkstemp actually opens a file, which we do not want. + ** we could write our own version, but then we would have to struggle + ** with supporting multiple build environments. tmpnam(3) is fine + ** here. + */ + (void) tmpnam(Buffer); strcat(Buffer, Ext); Out = xmalloc (strlen (Buffer) + 1); diff --git a/src/common/fname.h b/src/common/fname.h index 1dc985f93..cd163e4e7 100644 --- a/src/common/fname.h +++ b/src/common/fname.h @@ -59,7 +59,7 @@ char* MakeFilename (const char* Origin, const char* Ext); ** The function may be used to create "foo.o" from "foo.s". */ -char* MakeTmpFilename (const char* Origin, const char* Ext); +char* MakeTmpFilename (const char* Ext); /* Make a new temporary file name from Ext. tmpnam(3) is called ** and Ext is appended to generate the filename. Origin is ignored. ** The result is placed in a malloc'ed buffer and returned.