[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] Change to tclUnixPipe.c (get rid of a warning)
make complains when building tclUnixPipe.o (from
~ns/tcl8.3.2/unix/tclUnixPipe.c). The warning concerns use of
tmpnam().
Below is the contents of my patch to eliminate the warning -
following the suggestion made by the compiler to use mkstemp in place
of tmpnam.
I've also attached the file, since my mailer seems to want to wrap
things at odd places.
--
Brian Lee Bowers | RADIANT Team (Summer Intern)
[email protected] | Los Alamos National Laboratory
--- tclUnixPipe.c Mon Jun 4 17:53:42 2001
+++ /space/ns-allinone-current/tcl8.3.2/unix/tclUnixPipe.c Tue Jun 26
09:21:53 2001
@@ -182,14 +182,21 @@
TclpCreateTempFile(contents)
CONST char *contents; /* String to write into temp file, or
NULL. */
{
- char fileName[L_tmpnam], *native;
+ /* Removing tmpnam() use in favor of mkstemp() */
+ static char t[] = "tupXXXXXX"; /* template name */
+ char fileName[10]; /* name passed to mkstemp must be var */
+
+ char /*fileName[L_tmpnam],*/ *native;
Tcl_DString dstring;
int fd;
- if (tmpnam(fileName) == NULL) { /* INTL: Native. */
- return NULL;
- }
- fd = open(fileName, O_RDWR|O_CREAT|O_TRUNC, 0666); /* INTL:
Native. */
+ strncpy(fileName, t, 10); /* get template into var */
+ fd = mkstemp(fileName); /* create the temporaray file */
+
+/* if (tmpnam(fileName) == NULL) { /* INTL: Native. */
+/* return NULL; */
+/* } */
+/* fd = open(fileName, O_RDWR|O_CREAT|O_TRUNC, 0666); /* INTL:
Native. */
if (fd == -1) {
return NULL;
}
--- tclUnixPipe.c Mon Jun 4 17:53:42 2001
+++ /space/ns-allinone-current/tcl8.3.2/unix/tclUnixPipe.c Tue Jun 26 09:21:53 2001
@@ -182,14 +182,21 @@
TclpCreateTempFile(contents)
CONST char *contents; /* String to write into temp file, or NULL. */
{
- char fileName[L_tmpnam], *native;
+ /* Removing tmpnam() use in favor of mkstemp() */
+ static char t[] = "tupXXXXXX"; /* template name */
+ char fileName[10]; /* name passed to mkstemp must be var */
+
+ char /*fileName[L_tmpnam],*/ *native;
Tcl_DString dstring;
int fd;
- if (tmpnam(fileName) == NULL) { /* INTL: Native. */
- return NULL;
- }
- fd = open(fileName, O_RDWR|O_CREAT|O_TRUNC, 0666); /* INTL: Native. */
+ strncpy(fileName, t, 10); /* get template into var */
+ fd = mkstemp(fileName); /* create the temporaray file */
+
+/* if (tmpnam(fileName) == NULL) { /* INTL: Native. */
+/* return NULL; */
+/* } */
+/* fd = open(fileName, O_RDWR|O_CREAT|O_TRUNC, 0666); /* INTL: Native. */
if (fd == -1) {
return NULL;
}