diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-12-16 15:39:26 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-12-16 15:39:26 -0500 |
commit | 10a45846dc959f8b3ab9436f0809e90d1adf4ee4 (patch) | |
tree | b0d02669f08f94b80abcc0a8d9687ba4c8c80561 /src/nvim/fileio.c | |
parent | 3a61b84543c7cd843fe60d9ec4b356fb18f6a726 (diff) | |
parent | e0b23b3d090f58c772ff0175c38afa1d5e0f1612 (diff) | |
download | rneovim-10a45846dc959f8b3ab9436f0809e90d1adf4ee4.tar.gz rneovim-10a45846dc959f8b3ab9436f0809e90d1adf4ee4.tar.bz2 rneovim-10a45846dc959f8b3ab9436f0809e90d1adf4ee4.zip |
Merge pull request #1688 from elmart/coverity-issues-1
coverity issues
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r-- | src/nvim/fileio.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 9734ac07f9..9c6d7c96bb 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2839,27 +2839,25 @@ buf_write ( * Check if backup file already exists. */ if (os_fileinfo((char *)backup, &file_info_new)) { - /* - * Check if backup file is same as original file. - * May happen when modname() gave the same file back (e.g. silly - * link). If we don't check here, we either ruin the file when - * copying or erase it after writing. - */ if (os_fileinfo_id_equal(&file_info_new, &file_info_old)) { + /* + * Backup file is same as original file. + * May happen when modname() gave the same file back (e.g. silly + * link). If we don't check here, we either ruin the file when + * copying or erase it after writing. + */ free(backup); backup = NULL; /* no backup file to delete */ - } - - /* - * If we are not going to keep the backup file, don't - * delete an existing one, try to use another name. - * Change one character, just before the extension. - */ - if (!p_bk) { - wp = backup + STRLEN(backup) - 1 - - STRLEN(backup_ext); - if (wp < backup) /* empty file name ??? */ + } else if (!p_bk) { + /* + * We are not going to keep the backup file, so don't + * delete an existing one, and try to use another name instead. + * Change one character, just before the extension. + */ + wp = backup + STRLEN(backup) - 1 - STRLEN(backup_ext); + if (wp < backup) { /* empty file name ??? */ wp = backup; + } *wp = 'z'; while (*wp > 'a' && os_fileinfo((char *)backup, &file_info_new)) { |