replace_file_start: remove parameter TMP_FILE
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 8 Oct 2015 16:15:42 +0000 (18:15 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Fri, 9 Oct 2015 05:35:17 +0000 (07:35 +0200)
This parameter was never used (all callers passed NULL) and I cannot
imagine why anyone would be interested in it.

src/data/csv-file-writer.c
src/data/make-file.c
src/data/make-file.h
src/data/por-file-writer.c
src/data/sys-file-writer.c
src/language/data-io/data-writer.c

index 99fe41351063516cb752b4b9d3acfc436eac83b9..7a437c5947a2d49c561ad22babed47dcf18c955c 100644 (file)
@@ -154,8 +154,7 @@ csv_writer_open (struct file_handle *fh, const struct dictionary *dict,
     goto error;
 
   /* Create the file on disk. */
-  w->rf = replace_file_start (fh, "w", 0666,
-                              &w->file, NULL);
+  w->rf = replace_file_start (fh, "w", 0666,  &w->file);
   if (w->rf == NULL)
     {
       msg (ME, _("Error opening `%s' for writing as a system file: %s."),
index be1a0127493586d42262c022d705c0c2e2657d2d..b5d6d5845b964a901111072051a7b987a4fa3e63 100644 (file)
@@ -17,6 +17,7 @@
 #include <config.h>
 
 #include "data/make-file.h"
+#include "libpspp/i18n.h"
 
 #include <assert.h>
 #include <errno.h>
@@ -54,7 +55,7 @@ static void unlink_replace_files (void);
 
 struct replace_file *
 replace_file_start (const struct file_handle *fh, const char *mode,
-                    mode_t permissions, FILE **fp, char **tmp_name)
+                    mode_t permissions, FILE **fp)
 {
   static bool registered;
   struct stat s;
@@ -92,8 +93,6 @@ replace_file_start (const struct file_handle *fh, const char *mode,
       rf = xmalloc (sizeof *rf);
       rf->file_name = NULL;
       rf->tmp_name = xstrdup (file_name);
-      if (tmp_name != NULL)
-        *tmp_name = rf->tmp_name;
       return rf;
     }
 
@@ -149,17 +148,12 @@ replace_file_start (const struct file_handle *fh, const char *mode,
   ll_push_head (&all_files, &rf->ll);
   unblock_fatal_signals ();
 
-  if (tmp_name != NULL)
-    *tmp_name = rf->tmp_name;
-
   return rf;
 
 error:
   unblock_fatal_signals ();
   free_replace_file (rf);
   *fp = NULL;
-  if (tmp_name != NULL)
-    *tmp_name = NULL;
   errno = saved_errno;
   return NULL;
 }
index 2e424fefdf8f4d8716617950c932d6bc2874b861..a2bcc76eb11bdda3ec0917844f0c9b11c1175ced 100644 (file)
 struct file_handle;
 
 /* Prepares to atomically replace a (potentially) existing file
-   by a new file, by creating a temporary file with the given
-   PERMISSIONS bits in the same directory as *FILE_NAME.
+   by a new file., by creating a temporary file with the given
+   PERMISSIONS bits.
 
    Special files are an exception: they are not atomically
    replaced but simply opened for writing.
 
-   If successful, stores the temporary file's name in *TMP_NAME
-   and a stream for it opened according to MODE (which should be
+   If successful, stores a stream for it opened according to MODE (which should be
    "w" or "wb") in *FP.  Returns a ticket that can be used to
    commit or abort the file replacement.  If neither action has
    yet been taken, program termination via signal will cause
-   *TMP_FILE to be unlinked.
+   all resources to be released.  The return value must not be
+   explicitly freed.
+
+   The caller is responsible for closing *FP */
 
-   The caller is responsible for closing *FP, but *TMP_NAME is
-   owned by the callee. */
 struct replace_file *replace_file_start (const struct file_handle *fh,
                                          const char *mode, mode_t permissions,
-                                         FILE **fp, char **tmp_name);
+                                         FILE **fp);
 
 /* Commits or aborts the replacement of a (potentially) existing
    file by a new file, using the ticket returned by
index 7a3c971dec614e92091bcabfb54c41439780c8b7..3a4e88e7f0cb6e5c6b5a545340e00f8168d7723d 100644 (file)
@@ -154,7 +154,7 @@ pfm_open_writer (struct file_handle *fh, struct dictionary *dict,
   if (opts.create_writeable)
     mode |= 0222;
   w->rf = replace_file_start (fh, "w", mode,
-                              &w->file, NULL);
+                              &w->file);
   if (w->rf == NULL)
     {
       msg (ME, _("Error opening `%s' for writing as a portable file: %s."),
index 0f970190d4733fb8dd763370653c5717a738ae03..1cad0110f9e03266a7cc329a3f5a8c85dcde6224 100644 (file)
@@ -251,7 +251,7 @@ sfm_open_writer (struct file_handle *fh, struct dictionary *d,
   mode = 0444;
   if (opts.create_writeable)
     mode |= 0222;
-  w->rf = replace_file_start (fh, "wb", mode, &w->file, NULL);
+  w->rf = replace_file_start (fh, "wb", mode, &w->file);
   if (w->rf == NULL)
     {
       msg (ME, _("Error opening `%s' for writing as a system file: %s."),
index 8ae72513391bd8949a52e3180e89cf7c63467f62..c34ba90754704f1fce27d9d2e737aeb1fc31c789 100644 (file)
@@ -92,8 +92,7 @@ dfm_open_writer (struct file_handle *fh, const char *encoding)
   w = xmalloc (sizeof *w);
   w->fh = fh_ref (fh);
   w->lock = lock;
-  w->rf = replace_file_start (w->fh, "wb", 0666,
-                              &w->file, NULL);
+  w->rf = replace_file_start (w->fh, "wb", 0666, &w->file);
   w->encoding = xstrdup (encoding);
   w->line_ends = fh_get_line_ends (fh);
   w->unit = ei.unit;