commit 8eddf7bc269f5df5c33206f9a60efab3dabef678
parent 2623f39c7b2d2f3e0e2fe8cba1628c778a7d87b9
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 17 Jul 2020 16:52:47 +0200
tweaks: reshuffle a condition, to avoid a repetition of code
Diffstat:
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -1655,16 +1655,11 @@ bool make_backup_of(char *realname)
original = fopen(realname, "rb");
- if (original == NULL) {
- warn_and_briefly_pause(_("Cannot read original file"));
- fclose(backup_file);
- goto failure;
- }
-
- /* Copy the existing file to the backup. */
- verdict = copy_file(original, backup_file, FALSE);
+ /* If opening succeeded, copy the existing file to the backup. */
+ if (original != NULL)
+ verdict = copy_file(original, backup_file, FALSE);
- if (verdict < 0) {
+ if (original == NULL || verdict < 0) {
warn_and_briefly_pause(_("Cannot read original file"));
fclose(backup_file);
goto failure;