fix tempnam name generation, and a small bug in tmpnam on retry limit

This commit is contained in:
Rich Felker
2011-03-29 09:00:22 -04:00
parent a88edbec15
commit 8250742b90
2 changed files with 20 additions and 21 deletions

View File

@ -26,5 +26,5 @@ char *tmpnam(char *s)
n = ts.tv_nsec ^ (unsigned)&s ^ (unsigned)s;
snprintf(s, L_tmpnam, "/tmp/t%x-%x", a_fetch_add(&index, 1), n);
} while (!__syscall(SYS_access, s, F_OK) && try++<MAXTRIES);
return try==MAXTRIES ? 0 : s;
return try>=MAXTRIES ? 0 : s;
}