From 0f98466e2fdee6834a5f906e41d21d9ad54015f1 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 16 Oct 2019 16:05:40 +0200 Subject: [PATCH] tweaks: adjust the indentation after the previous change Also, don't bother assigning the stream pointer of the existing file to variable 'f', as it gets overwritten right away by the pointer of the temp file. --- src/files.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/files.c b/src/files.c index 191218d6..c66952d5 100644 --- a/src/files.c +++ b/src/files.c @@ -1724,13 +1724,11 @@ bool write_file(const char *name, FILE *stream, bool tmp, int fd_source; FILE *f_source = NULL; - f = fopen(realname, "rb"); - - if (f == NULL) { - statusline(ALERT, _("Error reading %s: %s"), realname, - strerror(errno)); - goto cleanup_and_exit; - } + if (fopen(realname, "rb") == NULL) { + statusline(ALERT, _("Error reading %s: %s"), realname, + strerror(errno)); + goto cleanup_and_exit; + } tempname = safe_tempfile(&f); @@ -1740,19 +1738,19 @@ bool write_file(const char *name, FILE *stream, bool tmp, goto cleanup_and_exit; } - fd_source = open(realname, O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR); + fd_source = open(realname, O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR); - if (fd_source != -1) { - f_source = fdopen(fd_source, "rb"); - if (f_source == NULL) { - statusline(ALERT, _("Error reading %s: %s"), realname, - strerror(errno)); - close(fd_source); - fclose(f); - unlink(tempname); - goto cleanup_and_exit; - } + if (fd_source != -1) { + f_source = fdopen(fd_source, "rb"); + if (f_source == NULL) { + statusline(ALERT, _("Error reading %s: %s"), realname, + strerror(errno)); + close(fd_source); + fclose(f); + unlink(tempname); + goto cleanup_and_exit; } + } if (f_source == NULL || copy_file(f_source, f, TRUE) != 0) { statusline(ALERT, _("Error writing temp file: %s"),