From caac150b2b0f799a09cab7b3b49498b9dc7ec0e8 Mon Sep 17 00:00:00 2001 From: "Kaleb S. KEITHLEY" Date: Wed, 13 Mar 2013 01:05:54 -0400 Subject: 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 Signed-off-by: Kaleb S. KEITHLEY Reviewed-on: http://review.gluster.org/4654 Tested-by: Gluster Build System Reviewed-by: Jeff Darcy --- contrib/stdlib/gf_mkostemp.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'contrib') diff --git a/contrib/stdlib/gf_mkostemp.c b/contrib/stdlib/gf_mkostemp.c index 988300adb..931249a45 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - /* 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 . */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + 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], -- cgit