diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-01-02 16:54:53 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-01-02 16:54:53 +0000 |
commit | dc4daa3a3915fba11ac87d27977240d9a5e0d47d (patch) | |
tree | 7c28de30cdf3c6a351bd41795612be078f451c9f /src/fileio.c | |
parent | a2942c74683be3f67c6044c2886dc6c237358b3d (diff) | |
download | vim-git-dc4daa3a3915fba11ac87d27977240d9a5e0d47d.tar.gz |
patch 9.0.1132: code is indented more than neededv9.0.1132
Problem: Code is indented more than needed.
Solution: Use an early return to reduce indentation. (Yegappan Lakshmanan,
closes #11769)
Diffstat (limited to 'src/fileio.c')
-rw-r--r-- | src/fileio.c | 69 |
1 files changed, 34 insertions, 35 deletions
diff --git a/src/fileio.c b/src/fileio.c index 1ee08e21e..d8b395acf 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2767,15 +2767,15 @@ set_file_options(int set_options, exarg_T *eap) void set_forced_fenc(exarg_T *eap) { - if (eap->force_enc != 0) - { - char_u *fenc = enc_canonize(eap->cmd + eap->force_enc); + if (eap->force_enc == 0) + return; - if (fenc != NULL) - set_string_option_direct((char_u *)"fenc", -1, - fenc, OPT_FREE|OPT_LOCAL, 0); - vim_free(fenc); - } + char_u *fenc = enc_canonize(eap->cmd + eap->force_enc); + + if (fenc != NULL) + set_string_option_direct((char_u *)"fenc", -1, + fenc, OPT_FREE|OPT_LOCAL, 0); + vim_free(fenc); } /* @@ -5070,12 +5070,11 @@ vim_opentempdir(void) return; dp = opendir((const char*)vim_tempdir); + if (dp == NULL) + return; - if (dp != NULL) - { - vim_tempdir_dp = dp; - flock(dirfd(vim_tempdir_dp), LOCK_SH); - } + vim_tempdir_dp = dp; + flock(dirfd(vim_tempdir_dp), LOCK_SH); } /* @@ -5084,11 +5083,11 @@ vim_opentempdir(void) static void vim_closetempdir(void) { - if (vim_tempdir_dp != NULL) - { - closedir(vim_tempdir_dp); - vim_tempdir_dp = NULL; - } + if (vim_tempdir_dp == NULL) + return; + + closedir(vim_tempdir_dp); + vim_tempdir_dp = NULL; } # endif @@ -5098,16 +5097,16 @@ vim_closetempdir(void) void vim_deltempdir(void) { - if (vim_tempdir != NULL) - { + if (vim_tempdir == NULL) + return; + # if defined(UNIX) && defined(HAVE_FLOCK) && defined(HAVE_DIRFD) - vim_closetempdir(); + vim_closetempdir(); # endif - // remove the trailing path separator - gettail(vim_tempdir)[-1] = NUL; - delete_recursive(vim_tempdir); - VIM_CLEAR(vim_tempdir); - } + // remove the trailing path separator + gettail(vim_tempdir)[-1] = NUL; + delete_recursive(vim_tempdir); + VIM_CLEAR(vim_tempdir); } /* @@ -5121,17 +5120,17 @@ vim_settempdir(char_u *tempdir) char_u *buf; buf = alloc(MAXPATHL + 2); - if (buf != NULL) - { - if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL) - STRCPY(buf, tempdir); - add_pathsep(buf); - vim_tempdir = vim_strsave(buf); + if (buf == NULL) + return; + + if (vim_FullName(tempdir, buf, MAXPATHL, FALSE) == FAIL) + STRCPY(buf, tempdir); + add_pathsep(buf); + vim_tempdir = vim_strsave(buf); # if defined(UNIX) && defined(HAVE_FLOCK) && defined(HAVE_DIRFD) - vim_opentempdir(); + vim_opentempdir(); # endif - vim_free(buf); - } + vim_free(buf); } #endif |