Mercurial > vim
diff src/fileio.c @ 31600:f1d5ad2b978e v9.0.1132
patch 9.0.1132: code is indented more than needed
Commit: https://github.com/vim/vim/commit/dc4daa3a3915fba11ac87d27977240d9a5e0d47d
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon Jan 2 16:54:53 2023 +0000
patch 9.0.1132: code is indented more than needed
Problem: Code is indented more than needed.
Solution: Use an early return to reduce indentation. (Yegappan Lakshmanan,
closes #11769)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 02 Jan 2023 18:00:04 +0100 |
parents | d8e7d725a666 |
children | fcc497515cce |
line wrap: on
line diff
--- a/src/fileio.c +++ b/src/fileio.c @@ -2767,15 +2767,15 @@ set_file_options(int set_options, exarg_ void set_forced_fenc(exarg_T *eap) { - if (eap->force_enc != 0) - { - 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); - } + if (eap->force_enc == 0) + return; + + 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) - { - vim_tempdir_dp = dp; - flock(dirfd(vim_tempdir_dp), LOCK_SH); - } + if (dp == NULL) + return; + + 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