* tempname.c (__gen_tempname): Change attempts_min
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 20 Sep 2006 18:38:14 +0000 (18:38 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 20 Sep 2006 18:38:14 +0000 (18:38 +0000)
into a macro.  Use preprocessor to decide how to initialize
attempts [Coverity CID 67].

lib/ChangeLog
lib/tempname.c

index 54a86e1c82a2652f3188221e2a05a3098298e8d1..900564e14072e18bb3d1499849d785e96f4f13bc 100644 (file)
@@ -1,3 +1,13 @@
+2006-09-20  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Import this patch from libc:
+
+       2006-04-07  Ulrich Drepper  <drepper@redhat.com>
+
+       * tempname.c (__gen_tempname): Change attempts_min
+       into a macro.  Use preprocessor to decide how to initialize
+       attempts [Coverity CID 67].
+
 2006-09-18  Bruno Haible  <bruno@clisp.org>
 
        * javaversion.c: Include configmake.h.
index d143882c928cc2effea0d00257e6d4cb9b0cc9cb..6fef5e9a1ea3b98bc6551286f8baa0d9de91bbc4 100644 (file)
@@ -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"))