summaryrefslogtreecommitdiff
path: root/libc/misc/internals/tempname.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/misc/internals/tempname.c')
-rw-r--r--libc/misc/internals/tempname.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libc/misc/internals/tempname.c b/libc/misc/internals/tempname.c
index ca87b0c06..f9b714a68 100644
--- a/libc/misc/internals/tempname.c
+++ b/libc/misc/internals/tempname.c
@@ -152,12 +152,12 @@ static void brain_damaged_fillrand(unsigned char *buf, unsigned int len)
for (i = 0; i < len; ++i) {
rh = high % NUM_LETTERS;
high /= NUM_LETTERS;
-#define L ((UINT32_MAX % NUM_LETTERS + 1) % NUM_LETTERS)
- k = (low % NUM_LETTERS) + (L * rh);
-#undef L
-#define H ((UINT32_MAX / NUM_LETTERS) + ((UINT32_MAX % NUM_LETTERS + 1) / NUM_LETTERS))
- low = (low / NUM_LETTERS) + (H * rh) + (k / NUM_LETTERS);
-#undef H
+#define _L ((UINT32_MAX % NUM_LETTERS + 1) % NUM_LETTERS)
+ k = (low % NUM_LETTERS) + (_L * rh);
+#undef _L
+#define _H ((UINT32_MAX / NUM_LETTERS) + ((UINT32_MAX % NUM_LETTERS + 1) / NUM_LETTERS))
+ low = (low / NUM_LETTERS) + (_H * rh) + (k / NUM_LETTERS);
+#undef _H
k %= NUM_LETTERS;
buf[i] = letters[k];
}
@@ -218,7 +218,8 @@ int attribute_hidden __gen_tempname (char *tmpl, int kind, int flags,
/* Give up now. */
return -1;
} else
- fd = 0;
+ /* File already exists, so return with non-zero value */
+ return -1;
}
case __GT_FILE:
fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL | flags, mode);