summaryrefslogtreecommitdiffstats
path: root/contrib/stdlib
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2013-03-13 01:05:54 -0400
committerVijay Bellur <vbellur@redhat.com>2013-03-13 10:33:02 -0700
commitcaac150b2b0f799a09cab7b3b49498b9dc7ec0e8 (patch)
tree4c495fde4fe9e50e57c700f76b615b071644f9bc /contrib/stdlib
parentac524f5907058f96eb68ffe0503f60a37c0a5dc8 (diff)
Renamed TMP_MAX to GF_TMP_MAX to avoid namespace clash on OSX.
(Just moving things along. I don't mean to step on any toes, but wasn't sure if I had confused things with my previous review comment.) Change-Id: I095abf751ef952ba6e225305ec5c2afc5e62ee95 BUG: 919953 Signed-off-by: Justin Clift <jclift@redhat.com> Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: http://review.gluster.org/4654 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'contrib/stdlib')
-rw-r--r--contrib/stdlib/gf_mkostemp.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/contrib/stdlib/gf_mkostemp.c b/contrib/stdlib/gf_mkostemp.c
index 988300adb1c..931249a4520 100644
--- a/contrib/stdlib/gf_mkostemp.c
+++ b/contrib/stdlib/gf_mkostemp.c
@@ -1,16 +1,5 @@
/* Borrowed from glibc-2.16/sysdeps/posix/tempname.c */
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <time.h>
-#include <inttypes.h>
-
/* Copyright (C) 1991-2001, 2006, 2007, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -28,6 +17,17 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/time.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <time.h>
+#include <inttypes.h>
+
static const char letters[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@@ -35,6 +35,10 @@ static const char letters[] =
rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
*/
+#if !defined(TMP_MAX)
+#define TMP_MAX 238328
+#endif
+
int
gf_mkostemp (char *tmpl, int suffixlen, int flags)
{
@@ -51,15 +55,8 @@ gf_mkostemp (char *tmpl, int suffixlen, int flags)
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. */
-#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. */
-#if ATTEMPTS_MIN < TMP_MAX
- unsigned int attempts = TMP_MAX;
-#else
- unsigned int attempts = ATTEMPTS_MIN;
-#endif
+
+ unsigned int attempts = TMP_MAX; /* TMP_MAX == 62³ */
len = strlen (tmpl);
if (len < 6 + suffixlen || memcmp (&tmpl[len - 6 - suffixlen],