tweaks: add a local variable, for clarity, to not preuse another one

master
Benno Schulenberg 2019-10-17 11:49:21 +02:00
parent e915fb1650
commit b554606047
1 changed files with 4 additions and 4 deletions

View File

@ -1564,16 +1564,16 @@ bool write_file(const char *name, FILE *stream, bool tmp,
static struct timespec filetime[2]; static struct timespec filetime[2];
char *backupname; char *backupname;
int backup_cflags, backup_fd; int backup_cflags, backup_fd;
FILE *backup_file = NULL; FILE *original = NULL, *backup_file = NULL;
/* Save the original file's access and modification times. */ /* Save the original file's access and modification times. */
filetime[0].tv_sec = openfile->current_stat->st_atime; filetime[0].tv_sec = openfile->current_stat->st_atime;
filetime[1].tv_sec = openfile->current_stat->st_mtime; filetime[1].tv_sec = openfile->current_stat->st_mtime;
/* Open the file of which a backup must be made. */ /* Open the file of which a backup must be made. */
f = fopen(realname, "rb"); original = fopen(realname, "rb");
if (f == NULL) { if (original == NULL) {
statusline(ALERT, _("Error reading %s: %s"), realname, statusline(ALERT, _("Error reading %s: %s"), realname,
strerror(errno)); strerror(errno));
/* If we can't read from the original file, go on, since saving /* If we can't read from the original file, go on, since saving
@ -1680,7 +1680,7 @@ bool write_file(const char *name, FILE *stream, bool tmp,
} }
/* Copy the file. */ /* Copy the file. */
if (copy_file(f, backup_file, FALSE) != 0) { if (copy_file(original, backup_file, FALSE) != 0) {
fclose(backup_file); fclose(backup_file);
statusline(ALERT, _("Error reading %s: %s"), realname, statusline(ALERT, _("Error reading %s: %s"), realname,
strerror(errno)); strerror(errno));