From: John Darrington Date: Thu, 8 Oct 2015 16:15:42 +0000 (+0200) Subject: replace_file_start: remove parameter TMP_FILE X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f93d0472eae9d03fb4bcd26a3d7a6301e32fbdde;p=pspp replace_file_start: remove parameter TMP_FILE This parameter was never used (all callers passed NULL) and I cannot imagine why anyone would be interested in it. --- diff --git a/src/data/csv-file-writer.c b/src/data/csv-file-writer.c index 99fe413510..7a437c5947 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 be1a012749..b5d6d5845b 100644 --- a/src/data/make-file.c +++ b/src/data/make-file.c @@ -17,6 +17,7 @@ #include #include "data/make-file.h" +#include "libpspp/i18n.h" #include #include @@ -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 2e424fefdf..a2bcc76eb1 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 7a3c971dec..3a4e88e7f0 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 0f970190d4..1cad0110f9 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 8ae7251339..c34ba90754 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;