Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Shutting up a silly compiler warning



In the last episode (Feb 29), Bart Schaefer said:
> Jos Backus just reported this one to me, from the FreeBSD compiler:
> 
> utils.o: In function `gettempname':
> utils.o(.text+0x1bfa): warning: mktemp() possibly used unsafely; consider
> using mkstemp()
> 
> Zsh does NOT use mktemp() unsafely, and it can't use mkstemp()
> because it sometimes wants to create a FIFO or other non-plain-file. 

(it being zsh, not mktemp().  This confused me the first time I read
this :) 

> What's the way to get rid of this warning without actually changing
> the code?

Under FreeBSD, you can use the undocumented _mktemp() function to
bypass the linker warning.  I don't know if the other BSDs implement
their warning message in the same way.  Does OpenBSD print a similar
warning for sprintf? :)

char * _mktemp(char *path)
{	return(_gettemp(path, (int *)NULL, 0, 0) ? path : (char *)NULL);
}

__warn_references(mktemp, "warning: mktemp() possibly used unsafely; consider using mkstemp()");

char * mktemp(char *path)
{	return(_mktemp(path));
}


-- 
	Dan Nelson
	dnelson@xxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author