pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 5/5] replace_file_start: remove parameter TMP_FILE


From: John Darrington
Subject: [PATCH 5/5] replace_file_start: remove parameter TMP_FILE
Date: Thu, 8 Oct 2015 18:30:27 +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         |    3 +--
 src/data/make-file.c               |   10 ++--------
 src/data/make-file.h               |   16 ++++++++--------
 src/data/por-file-writer.c         |    2 +-
 src/data/sys-file-writer.c         |    2 +-
 src/language/data-io/data-writer.c |    3 +--
 6 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/src/data/csv-file-writer.c b/src/data/csv-file-writer.c
index 99fe413..7a437c5 100644
--- a/src/data/csv-file-writer.c
+++ b/src/data/csv-file-writer.c
@@ -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."),
diff --git a/src/data/make-file.c b/src/data/make-file.c
index be1a012..b5d6d58 100644
--- a/src/data/make-file.c
+++ b/src/data/make-file.c
@@ -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;
 }
diff --git a/src/data/make-file.h b/src/data/make-file.h
index 2e424fe..a2bcc76 100644
--- a/src/data/make-file.h
+++ b/src/data/make-file.h
@@ -24,24 +24,24 @@
 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
diff --git a/src/data/por-file-writer.c b/src/data/por-file-writer.c
index 7a3c971..3a4e88e 100644
--- a/src/data/por-file-writer.c
+++ b/src/data/por-file-writer.c
@@ -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."),
diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c
index 0f97019..1cad011 100644
--- a/src/data/sys-file-writer.c
+++ b/src/data/sys-file-writer.c
@@ -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."),
diff --git a/src/language/data-io/data-writer.c 
b/src/language/data-io/data-writer.c
index 8ae7251..c34ba90 100644
--- a/src/language/data-io/data-writer.c
+++ b/src/language/data-io/data-writer.c
@@ -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;
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]