diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-02-02 21:33:46 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-02-02 21:33:46 +0800 |
commit | 1bce6d6e16283a5de46e4c0b9d80742f226bea66 (patch) | |
tree | d213d4f933afe58e59c1e8c3670589a072e76b5b /src | |
parent | 2559359035b7b0dd6f94fef9573e8133176c1553 (diff) | |
download | rneovim-1bce6d6e16283a5de46e4c0b9d80742f226bea66.tar.gz rneovim-1bce6d6e16283a5de46e4c0b9d80742f226bea66.tar.bz2 rneovim-1bce6d6e16283a5de46e4c0b9d80742f226bea66.zip |
vim-patch:8.2.3947: unnecessary check for NULL pointer
Problem: Unnecessary check for NULL pointer.
Solution: Remove the check. (closes vim/vim#9434)
https://github.com/vim/vim/commit/f38aad85cf8e4e930c96cb843bc136949c8dbd29
Reorder the two if branches to match upstream.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_docmd.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 07fbf1c61a..b859d29a86 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7870,9 +7870,11 @@ bool changedir_func(char_u *new_dir, CdScope scope) new_dir = NameBuff; } - bool dir_differs = new_dir == NULL || pdir == NULL - || pathcmp((char *)pdir, (char *)new_dir, -1) != 0; - if (new_dir != NULL && (!dir_differs || vim_chdir(new_dir) == 0)) { + bool dir_differs = pdir == NULL || pathcmp((char *)pdir, (char *)new_dir, -1) != 0; + if (dir_differs && vim_chdir(new_dir) != 0) { + emsg(_(e_failed)); + xfree(pdir); + } else { char_u **pp; switch (scope) { @@ -7890,9 +7892,6 @@ bool changedir_func(char_u *new_dir, CdScope scope) post_chdir(scope, dir_differs); retval = true; - } else { - emsg(_(e_failed)); - xfree(pdir); } return retval; |