* lib/stdint_.h (uintmax_t): Fix typo: int64_t -> uint64_t.
[gnulib.git] / lib / clean-temp.c
index 36a5294..aa82974 100644 (file)
@@ -39,6 +39,9 @@
 #include "xallocsa.h"
 #include "gl_linkedhash_list.h"
 #include "gettext.h"
+#if GNULIB_FWRITEERROR
+# include "fwriteerror.h"
+#endif
 #if GNULIB_CLOSE_STREAM
 # include "close-stream.h"
 #endif
@@ -151,8 +154,8 @@ static gl_list_t /* <int> */ 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;
 }
 
@@ -164,7 +167,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++)
@@ -248,7 +251,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
@@ -270,8 +273,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.  */
@@ -303,7 +305,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,
@@ -312,15 +314,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;
@@ -331,7 +333,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.
@@ -339,11 +341,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;
 }