X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fclean-temp.c;h=7acc68857dc529aee1302506f60a9598fd71302c;hb=bbdcfead98c6d3536215c3f0f603e4f92a28d26b;hp=f3a0324518070acee69d27afc240759b9d1f74a1;hpb=d4dbda64df423d3e5519b19eb5d6c26f98b222bf;p=gnulib.git diff --git a/lib/clean-temp.c b/lib/clean-temp.c index f3a032451..7acc68857 100644 --- a/lib/clean-temp.c +++ b/lib/clean-temp.c @@ -67,6 +67,13 @@ # define uintptr_t unsigned long #endif +#if !GNULIB_FCNTL_SAFER +/* The results of open() in this file are not used with fchdir, + therefore save some unnecessary work in fchdir.c. */ +# undef open +# undef close +#endif + /* The use of 'volatile' in the types below (and ISO C 99 section 5.1.2.3.(5)) ensure that while constructing or modifying the data structures, the field @@ -154,8 +161,8 @@ static gl_list_t /* */ volatile descriptors; static bool string_equals (const void *x1, const void *x2) { - const char *s1 = x1; - const char *s2 = x2; + const char *s1 = (const char *) x1; + const char *s2 = (const char *) x2; return strcmp (s1, s2) == 0; } @@ -167,7 +174,7 @@ string_equals (const void *x1, const void *x2) static size_t string_hash (const void *x) { - const char *s = x; + const char *s = (const char *) x; size_t h = 0; for (; *s; s++) @@ -251,7 +258,7 @@ create_temp_dir (const char *prefix, const char *parentdir, struct tempdir * volatile *tmpdirp = NULL; struct tempdir *tmpdir; size_t i; - char *template; + char *xtemplate; char *tmpdirname; /* See whether it can take the slot of an earlier temporary directory @@ -273,8 +280,7 @@ create_temp_dir (const char *prefix, const char *parentdir, size_t old_allocated = cleanup_list.tempdir_allocated; size_t new_allocated = 2 * cleanup_list.tempdir_allocated + 1; struct tempdir * volatile *new_array = - (struct tempdir * volatile *) - xmalloc (new_allocated * sizeof (struct tempdir * volatile)); + XNMALLOC (new_allocated, struct tempdir * volatile); if (old_allocated == 0) /* First use of this facility. Register the cleanup handler. */ @@ -306,7 +312,7 @@ create_temp_dir (const char *prefix, const char *parentdir, } /* Initialize a 'struct tempdir'. */ - tmpdir = (struct tempdir *) xmalloc (sizeof (struct tempdir)); + tmpdir = XMALLOC (struct tempdir); tmpdir->dirname = NULL; tmpdir->cleanup_verbose = cleanup_verbose; tmpdir->subdirs = gl_list_create_empty (GL_LINKEDHASH_LIST, @@ -315,15 +321,15 @@ create_temp_dir (const char *prefix, const char *parentdir, string_equals, string_hash, false); /* Create the temporary directory. */ - template = (char *) xallocsa (PATH_MAX); - if (path_search (template, PATH_MAX, parentdir, prefix, parentdir == NULL)) + xtemplate = (char *) xallocsa (PATH_MAX); + if (path_search (xtemplate, PATH_MAX, parentdir, prefix, parentdir == NULL)) { error (0, errno, _("cannot find a temporary directory, try setting $TMPDIR")); goto quit; } block_fatal_signals (); - tmpdirname = mkdtemp (template); + tmpdirname = mkdtemp (xtemplate); if (tmpdirname != NULL) { tmpdir->dirname = tmpdirname; @@ -334,7 +340,7 @@ create_temp_dir (const char *prefix, const char *parentdir, { error (0, errno, _("cannot create a temporary directory using template \"%s\""), - template); + xtemplate); goto quit; } /* Replace tmpdir->dirname with a copy that has indefinite extent. @@ -342,11 +348,11 @@ create_temp_dir (const char *prefix, const char *parentdir, block because then the cleanup handler would not remove the directory if xstrdup fails. */ tmpdir->dirname = xstrdup (tmpdirname); - freesa (template); + freesa (xtemplate); return (struct temp_dir *) tmpdir; quit: - freesa (template); + freesa (xtemplate); return NULL; }