summaryrefslogtreecommitdiff
path: root/lib/tempname.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2006-09-20 18:38:14 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2006-09-20 18:38:14 +0000
commitd00ac15a6511b77ab132d4b6694acbb5b9a6f402 (patch)
treec3bba7cc88ecaf936cc2a468b05276e65d334128 /lib/tempname.c
parent06a3032f9f6c73bafdff90a5c7052149e5f0b546 (diff)
downloadgnulib-d00ac15a6511b77ab132d4b6694acbb5b9a6f402.tar.gz
* tempname.c (__gen_tempname): Change attempts_min
into a macro. Use preprocessor to decide how to initialize attempts [Coverity CID 67].
Diffstat (limited to 'lib/tempname.c')
-rw-r--r--lib/tempname.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/tempname.c b/lib/tempname.c
index d143882c92..6fef5e9a1e 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -213,11 +213,15 @@ __gen_tempname (char *tmpl, int kind)
necessary to try all these combinations. Instead if a reasonable
number of names is tried (we define reasonable as 62**3) fail to
give the system administrator the chance to remove the problems. */
- unsigned int attempts_min = 62 * 62 * 62;
+#define ATTEMPTS_MIN (62 * 62 * 62)
/* The number of times to attempt to generate a temporary file. To
conform to POSIX, this must be no smaller than TMP_MAX. */
- unsigned int attempts = attempts_min < TMP_MAX ? TMP_MAX : attempts_min;
+#if ATTEMPTS_MIN < TMP_MAX
+ unsigned int attempts = TMP_MAX;
+#else
+ unsigned int attempts = ATTEMPTS_MIN;
+#endif
len = strlen (tmpl);
if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))