diff --git a/src/arglist.c b/src/arglist.c
index 6183faf..bb31c45 100644
--- a/src/arglist.c
+++ b/src/arglist.c
@@ -693,56 +693,56 @@
 	    emsg(_(e_cannot_go_before_first_file));
 	else
 	    emsg(_(e_cannot_go_beyond_last_file));
+
+	return;
+    }
+
+    setpcmark();
+#ifdef FEAT_GUI
+    need_mouse_correct = TRUE;
+#endif
+
+    // split window or create new tab page first
+    if (*eap->cmd == 's' || cmdmod.cmod_tab != 0)
+    {
+	if (win_split(0, 0) == FAIL)
+	    return;
+	RESET_BINDING(curwin);
     }
     else
     {
-	setpcmark();
-#ifdef FEAT_GUI
-	need_mouse_correct = TRUE;
-#endif
-
-	// split window or create new tab page first
-	if (*eap->cmd == 's' || cmdmod.cmod_tab != 0)
+	// if 'hidden' set, only check for changed file when re-editing
+	// the same buffer
+	other = TRUE;
+	if (buf_hide(curbuf))
 	{
-	    if (win_split(0, 0) == FAIL)
-		return;
-	    RESET_BINDING(curwin);
+	    p = fix_fname(alist_name(&ARGLIST[argn]));
+	    other = otherfile(p);
+	    vim_free(p);
 	}
-	else
-	{
-	    // if 'hidden' set, only check for changed file when re-editing
-	    // the same buffer
-	    other = TRUE;
-	    if (buf_hide(curbuf))
-	    {
-		p = fix_fname(alist_name(&ARGLIST[argn]));
-		other = otherfile(p);
-		vim_free(p);
-	    }
-	    if ((!buf_hide(curbuf) || !other)
-		  && check_changed(curbuf, CCGD_AW
-					 | (other ? 0 : CCGD_MULTWIN)
-					 | (eap->forceit ? CCGD_FORCEIT : 0)
-					 | CCGD_EXCMD))
-		return;
-	}
-
-	curwin->w_arg_idx = argn;
-	if (argn == ARGCOUNT - 1 && curwin->w_alist == &global_alist)
-	    arg_had_last = TRUE;
-
-	// Edit the file; always use the last known line number.
-	// When it fails (e.g. Abort for already edited file) restore the
-	// argument index.
-	if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
-		      eap, ECMD_LAST,
-		      (buf_hide(curwin->w_buffer) ? ECMD_HIDE : 0)
-			 + (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL)
-	    curwin->w_arg_idx = old_arg_idx;
-	// like Vi: set the mark where the cursor is in the file.
-	else if (eap->cmdidx != CMD_argdo)
-	    setmark('\'');
+	if ((!buf_hide(curbuf) || !other)
+		&& check_changed(curbuf, CCGD_AW
+		    | (other ? 0 : CCGD_MULTWIN)
+		    | (eap->forceit ? CCGD_FORCEIT : 0)
+		    | CCGD_EXCMD))
+	    return;
     }
+
+    curwin->w_arg_idx = argn;
+    if (argn == ARGCOUNT - 1 && curwin->w_alist == &global_alist)
+	arg_had_last = TRUE;
+
+    // Edit the file; always use the last known line number.
+    // When it fails (e.g. Abort for already edited file) restore the
+    // argument index.
+    if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
+		eap, ECMD_LAST,
+		(buf_hide(curwin->w_buffer) ? ECMD_HIDE : 0)
+		+ (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL)
+	curwin->w_arg_idx = old_arg_idx;
+    // like Vi: set the mark where the cursor is in the file.
+    else if (eap->cmdidx != CMD_argdo)
+	setmark('\'');
 }
 
 /*
diff --git a/src/buffer.c b/src/buffer.c
index 7e47729..9856898 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -146,19 +146,19 @@
     void
 buffer_ensure_loaded(buf_T *buf)
 {
-    if (buf->b_ml.ml_mfp == NULL)
-    {
-	aco_save_T	aco;
+    if (buf->b_ml.ml_mfp != NULL)
+	return;
 
-	// Make sure the buffer is in a window.  If not then skip it.
-	aucmd_prepbuf(&aco, buf);
-	if (curbuf == buf)
-	{
-	    if (swap_exists_action != SEA_READONLY)
-		swap_exists_action = SEA_NONE;
-	    open_buffer(FALSE, NULL, 0);
-	    aucmd_restbuf(&aco);
-	}
+    aco_save_T	aco;
+
+    // Make sure the buffer is in a window.  If not then skip it.
+    aucmd_prepbuf(&aco, buf);
+    if (curbuf == buf)
+    {
+	if (swap_exists_action != SEA_READONLY)
+	    swap_exists_action = SEA_NONE;
+	open_buffer(FALSE, NULL, 0);
+	aucmd_restbuf(&aco);
     }
 }
 #endif
@@ -3582,18 +3582,18 @@
     buf_T	*buf;
 
     buf = buflist_findnr(fnum);
-    if (buf != NULL)
-    {
-	if (buf->b_sfname != buf->b_ffname)
-	    vim_free(buf->b_sfname);
-	vim_free(buf->b_ffname);
-	buf->b_ffname = vim_strsave(name);
-	buf->b_sfname = NULL;
-	// Allocate ffname and expand into full path.  Also resolves .lnk
-	// files on Win32.
-	fname_expand(buf, &buf->b_ffname, &buf->b_sfname);
-	buf->b_fname = buf->b_sfname;
-    }
+    if (buf == NULL)
+	return;
+
+    if (buf->b_sfname != buf->b_ffname)
+	vim_free(buf->b_sfname);
+    vim_free(buf->b_ffname);
+    buf->b_ffname = vim_strsave(name);
+    buf->b_sfname = NULL;
+    // Allocate ffname and expand into full path.  Also resolves .lnk
+    // files on Win32.
+    fname_expand(buf, &buf->b_ffname, &buf->b_sfname);
+    buf->b_fname = buf->b_sfname;
 }
 
 /*
@@ -5921,14 +5921,14 @@
     void
 set_buflisted(int on)
 {
-    if (on != curbuf->b_p_bl)
-    {
-	curbuf->b_p_bl = on;
-	if (on)
-	    apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
-	else
-	    apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
-    }
+    if (on == curbuf->b_p_bl)
+	return;
+
+    curbuf->b_p_bl = on;
+    if (on)
+	apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf);
+    else
+	apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf);
 }
 
 /*
diff --git a/src/clientserver.c b/src/clientserver.c
index ccb7238..2a091a6 100644
--- a/src/clientserver.c
+++ b/src/clientserver.c
@@ -191,38 +191,38 @@
     void
 exec_on_server(mparm_T *parmp)
 {
-    if (parmp->serverName_arg == NULL || *parmp->serverName_arg != NUL)
+    if (parmp->serverName_arg != NULL && *parmp->serverName_arg == NUL)
+	return;
+
+# ifdef MSWIN
+    // Initialise the client/server messaging infrastructure.
+    serverInitMessaging();
+# endif
+
+    /*
+     * When a command server argument was found, execute it.  This may
+     * exit Vim when it was successful.  Otherwise it's executed further
+     * on.  Remember the encoding used here in "serverStrEnc".
+     */
+    if (parmp->serverArg)
     {
-# ifdef MSWIN
-	// Initialise the client/server messaging infrastructure.
-	serverInitMessaging();
-# endif
-
-	/*
-	 * When a command server argument was found, execute it.  This may
-	 * exit Vim when it was successful.  Otherwise it's executed further
-	 * on.  Remember the encoding used here in "serverStrEnc".
-	 */
-	if (parmp->serverArg)
-	{
-	    cmdsrv_main(&parmp->argc, parmp->argv,
-				    parmp->serverName_arg, &parmp->serverStr);
-	    parmp->serverStrEnc = vim_strsave(p_enc);
-	}
-
-	// If we're still running, get the name to register ourselves.
-	// On Win32 can register right now, for X11 need to setup the
-	// clipboard first, it's further down.
-	parmp->servername = serverMakeName(parmp->serverName_arg,
-							      parmp->argv[0]);
-# ifdef MSWIN
-	if (parmp->servername != NULL)
-	{
-	    serverSetName(parmp->servername);
-	    vim_free(parmp->servername);
-	}
-# endif
+	cmdsrv_main(&parmp->argc, parmp->argv,
+		parmp->serverName_arg, &parmp->serverStr);
+	parmp->serverStrEnc = vim_strsave(p_enc);
     }
+
+    // If we're still running, get the name to register ourselves.
+    // On Win32 can register right now, for X11 need to setup the
+    // clipboard first, it's further down.
+    parmp->servername = serverMakeName(parmp->serverName_arg,
+	    parmp->argv[0]);
+# ifdef MSWIN
+    if (parmp->servername != NULL)
+    {
+	serverSetName(parmp->servername);
+	vim_free(parmp->servername);
+    }
+# endif
 }
 
 /*
diff --git a/src/dosinst.c b/src/dosinst.c
index 60e3c64..4eae5aa 100644
--- a/src/dosinst.c
+++ b/src/dosinst.c
@@ -830,87 +830,88 @@
     char	*vimarg = targets[choices[idx].arg].exearg;
     FILE	*fd;
 
-    if (*batpath != NUL)
+    if (*batpath == NUL)
+	return;
+
+    fd = fopen(batpath, "w");
+    if (fd == NULL)
     {
-	fd = fopen(batpath, "w");
-	if (fd == NULL)
-	    printf("\nERROR: Cannot open \"%s\" for writing.\n", batpath);
-	else
-	{
-	    need_uninstall_entry = 1;
-
-	    fprintf(fd, "@echo off\n");
-	    fprintf(fd, "rem -- Run Vim --\n");
-	    fprintf(fd, VIMBAT_UNINSTKEY "\n");
-	    fprintf(fd, "\n");
-	    fprintf(fd, "setlocal\n");
-
-	    /*
-	     * Don't use double quotes for the "set" argument, also when it
-	     * contains a space.  The quotes would be included in the value.
-	     * The order of preference is:
-	     * 1. $VIMRUNTIME/vim.exe	    (user preference)
-	     * 2. $VIM/vim81/vim.exe	    (hard coded version)
-	     * 3. installdir/vim.exe	    (hard coded install directory)
-	     */
-	    fprintf(fd, "set VIM_EXE_DIR=%s\n", installdir);
-	    fprintf(fd, "if exist \"%%VIM%%\\%s\\%s\" set VIM_EXE_DIR=%%VIM%%\\%s\n",
-			       VIM_VERSION_NODOT, exename, VIM_VERSION_NODOT);
-	    fprintf(fd, "if exist \"%%VIMRUNTIME%%\\%s\" set VIM_EXE_DIR=%%VIMRUNTIME%%\n", exename);
-	    fprintf(fd, "\n");
-
-	    // Give an error message when the executable could not be found.
-	    fprintf(fd, "if not exist \"%%VIM_EXE_DIR%%\\%s\" (\n", exename);
-	    fprintf(fd, "    echo \"%%VIM_EXE_DIR%%\\%s\" not found\n", exename);
-	    fprintf(fd, "    goto :eof\n");
-	    fprintf(fd, ")\n");
-	    fprintf(fd, "\n");
-
-	    if (*exename == 'g')
-	    {
-		fprintf(fd, "rem check --nofork argument\n");
-		fprintf(fd, "set VIMNOFORK=\n");
-		fprintf(fd, ":loopstart\n");
-		fprintf(fd, "if .%%1==. goto loopend\n");
-		fprintf(fd, "if .%%1==.--nofork (\n");
-		fprintf(fd, "    set VIMNOFORK=1\n");
-		fprintf(fd, ") else if .%%1==.-f (\n");
-		fprintf(fd, "    set VIMNOFORK=1\n");
-		fprintf(fd, ")\n");
-		fprintf(fd, "shift\n");
-		fprintf(fd, "goto loopstart\n");
-		fprintf(fd, ":loopend\n");
-		fprintf(fd, "\n");
-	    }
-
-	    if (*exename == 'g')
-	    {
-		// For gvim.exe use "start /b" to avoid that the console window
-		// stays open.
-		fprintf(fd, "if .%%VIMNOFORK%%==.1 (\n");
-		fprintf(fd, "    start \"dummy\" /b /wait ");
-		// Always use quotes, $VIM or $VIMRUNTIME might have a space.
-		fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
-							     exename, vimarg);
-		fprintf(fd, ") else (\n");
-		fprintf(fd, "    start \"dummy\" /b ");
-		// Always use quotes, $VIM or $VIMRUNTIME might have a space.
-		fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
-							     exename, vimarg);
-		fprintf(fd, ")\n");
-	    }
-	    else
-	    {
-		// Always use quotes, $VIM or $VIMRUNTIME might have a space.
-		fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
-							     exename, vimarg);
-	    }
-
-	    fclose(fd);
-	    printf("%s has been %s\n", batpath,
-				 oldname == NULL ? "created" : "overwritten");
-	}
+	printf("\nERROR: Cannot open \"%s\" for writing.\n", batpath);
+	return;
     }
+
+    need_uninstall_entry = 1;
+
+    fprintf(fd, "@echo off\n");
+    fprintf(fd, "rem -- Run Vim --\n");
+    fprintf(fd, VIMBAT_UNINSTKEY "\n");
+    fprintf(fd, "\n");
+    fprintf(fd, "setlocal\n");
+
+    /*
+     * Don't use double quotes for the "set" argument, also when it
+     * contains a space.  The quotes would be included in the value.
+     * The order of preference is:
+     * 1. $VIMRUNTIME/vim.exe	    (user preference)
+     * 2. $VIM/vim81/vim.exe	    (hard coded version)
+     * 3. installdir/vim.exe	    (hard coded install directory)
+     */
+    fprintf(fd, "set VIM_EXE_DIR=%s\n", installdir);
+    fprintf(fd, "if exist \"%%VIM%%\\%s\\%s\" set VIM_EXE_DIR=%%VIM%%\\%s\n",
+	    VIM_VERSION_NODOT, exename, VIM_VERSION_NODOT);
+    fprintf(fd, "if exist \"%%VIMRUNTIME%%\\%s\" set VIM_EXE_DIR=%%VIMRUNTIME%%\n", exename);
+    fprintf(fd, "\n");
+
+    // Give an error message when the executable could not be found.
+    fprintf(fd, "if not exist \"%%VIM_EXE_DIR%%\\%s\" (\n", exename);
+    fprintf(fd, "    echo \"%%VIM_EXE_DIR%%\\%s\" not found\n", exename);
+    fprintf(fd, "    goto :eof\n");
+    fprintf(fd, ")\n");
+    fprintf(fd, "\n");
+
+    if (*exename == 'g')
+    {
+	fprintf(fd, "rem check --nofork argument\n");
+	fprintf(fd, "set VIMNOFORK=\n");
+	fprintf(fd, ":loopstart\n");
+	fprintf(fd, "if .%%1==. goto loopend\n");
+	fprintf(fd, "if .%%1==.--nofork (\n");
+	fprintf(fd, "    set VIMNOFORK=1\n");
+	fprintf(fd, ") else if .%%1==.-f (\n");
+	fprintf(fd, "    set VIMNOFORK=1\n");
+	fprintf(fd, ")\n");
+	fprintf(fd, "shift\n");
+	fprintf(fd, "goto loopstart\n");
+	fprintf(fd, ":loopend\n");
+	fprintf(fd, "\n");
+    }
+
+    if (*exename == 'g')
+    {
+	// For gvim.exe use "start /b" to avoid that the console window
+	// stays open.
+	fprintf(fd, "if .%%VIMNOFORK%%==.1 (\n");
+	fprintf(fd, "    start \"dummy\" /b /wait ");
+	// Always use quotes, $VIM or $VIMRUNTIME might have a space.
+	fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
+		exename, vimarg);
+	fprintf(fd, ") else (\n");
+	fprintf(fd, "    start \"dummy\" /b ");
+	// Always use quotes, $VIM or $VIMRUNTIME might have a space.
+	fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
+		exename, vimarg);
+	fprintf(fd, ")\n");
+    }
+    else
+    {
+	// Always use quotes, $VIM or $VIMRUNTIME might have a space.
+	fprintf(fd, "\"%%VIM_EXE_DIR%%\\%s\" %s %%*\n",
+		exename, vimarg);
+    }
+
+    fclose(fd);
+    printf("%s has been %s\n", batpath,
+	    oldname == NULL ? "created" : "overwritten");
 }
 
 /*
diff --git a/src/evalfunc.c b/src/evalfunc.c
index 314a3f8..56dc7b8 100644
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -3172,48 +3172,48 @@
 f_balloon_gettext(typval_T *argvars UNUSED, typval_T *rettv)
 {
     rettv->v_type = VAR_STRING;
-    if (balloonEval != NULL)
-    {
-	if (balloonEval->msg == NULL)
-	    rettv->vval.v_string = NULL;
-	else
-	    rettv->vval.v_string = vim_strsave(balloonEval->msg);
-    }
+    if (balloonEval == NULL)
+	return;
+
+    if (balloonEval->msg == NULL)
+	rettv->vval.v_string = NULL;
+    else
+	rettv->vval.v_string = vim_strsave(balloonEval->msg);
 }
 
     static void
 f_balloon_show(typval_T *argvars, typval_T *rettv UNUSED)
 {
-    if (balloonEval != NULL)
+    if (balloonEval == NULL)
+	return;
+
+    if (in_vim9script()
+	    && check_for_string_or_list_arg(argvars, 0) == FAIL)
+	return;
+
+    if (argvars[0].v_type == VAR_LIST
+# ifdef FEAT_GUI
+	    && !gui.in_use
+# endif
+       )
     {
-	if (in_vim9script()
-		&& check_for_string_or_list_arg(argvars, 0) == FAIL)
+	list_T *l = argvars[0].vval.v_list;
+
+	// empty list removes the balloon
+	post_balloon(balloonEval, NULL,
+		l == NULL || l->lv_len == 0 ? NULL : l);
+    }
+    else
+    {
+	char_u *mesg;
+
+	if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
 	    return;
 
-	if (argvars[0].v_type == VAR_LIST
-# ifdef FEAT_GUI
-		&& !gui.in_use
-# endif
-	   )
-	{
-	    list_T *l = argvars[0].vval.v_list;
-
-	    // empty list removes the balloon
-	    post_balloon(balloonEval, NULL,
-				       l == NULL || l->lv_len == 0 ? NULL : l);
-	}
-	else
-	{
-	    char_u *mesg;
-
-	    if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
-		return;
-
-	    mesg = tv_get_string_chk(&argvars[0]);
-	    if (mesg != NULL)
-		// empty string removes the balloon
-		post_balloon(balloonEval, *mesg == NUL ? NULL : mesg, NULL);
-	}
+	mesg = tv_get_string_chk(&argvars[0]);
+	if (mesg != NULL)
+	    // empty string removes the balloon
+	    post_balloon(balloonEval, *mesg == NUL ? NULL : mesg, NULL);
     }
 }
 
@@ -3221,25 +3221,25 @@
     static void
 f_balloon_split(typval_T *argvars, typval_T *rettv UNUSED)
 {
-    if (rettv_list_alloc(rettv) == OK)
+    if (rettv_list_alloc(rettv) != OK)
+	return;
+
+    char_u *msg;
+
+    if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
+	return;
+    msg = tv_get_string_chk(&argvars[0]);
+    if (msg != NULL)
     {
-	char_u *msg;
+	pumitem_T	*array;
+	int		size = split_message(msg, &array);
 
-	if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
-	    return;
-	msg = tv_get_string_chk(&argvars[0]);
-	if (msg != NULL)
-	{
-	    pumitem_T	*array;
-	    int		size = split_message(msg, &array);
-
-	    // Skip the first and last item, they are always empty.
-	    for (int i = 1; i < size - 1; ++i)
-		list_append_string(rettv->vval.v_list, array[i].pum_text, -1);
-	    while (size > 0)
-		vim_free(array[--size].pum_text);
-	    vim_free(array);
-	}
+	// Skip the first and last item, they are always empty.
+	for (int i = 1; i < size - 1; ++i)
+	    list_append_string(rettv->vval.v_list, array[i].pum_text, -1);
+	while (size > 0)
+	    vim_free(array[--size].pum_text);
+	vim_free(array);
     }
 }
 # endif
@@ -3676,18 +3676,18 @@
 
     pid = (int)tv_get_number(&argvars[0]);
     if (pid == 0)
-	emsg(_(e_invalid_argument));
-    else
     {
-	HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
-
-	if (hProcess != NULL)
-	{
-	    DebugBreakProcess(hProcess);
-	    CloseHandle(hProcess);
-	    rettv->vval.v_number = OK;
-	}
+	emsg(_(e_invalid_argument));
+	return;
     }
+
+    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
+    if (hProcess == NULL)
+	return;
+
+    DebugBreakProcess(hProcess);
+    CloseHandle(hProcess);
+    rettv->vval.v_number = OK;
 }
 #endif
 
@@ -3932,12 +3932,12 @@
 	len = (int)STRLEN(value);	// Append the entire string
     else
 	len = value_len;		// Append only "value_len" characters
-    if (ga_grow(&redir_execute_ga, len) == OK)
-    {
-	mch_memmove((char *)redir_execute_ga.ga_data
-				       + redir_execute_ga.ga_len, value, len);
-	redir_execute_ga.ga_len += len;
-    }
+    if (ga_grow(&redir_execute_ga, len) != OK)
+	return;
+
+    mch_memmove((char *)redir_execute_ga.ga_data
+	    + redir_execute_ga.ga_len, value, len);
+    redir_execute_ga.ga_len += len;
 }
 
 #if defined(FEAT_LUA) || defined(PROTO)
@@ -5043,14 +5043,14 @@
     static void
 f_getcharsearch(typval_T *argvars UNUSED, typval_T *rettv)
 {
-    if (rettv_dict_alloc(rettv) == OK)
-    {
-	dict_T *dict = rettv->vval.v_dict;
+    if (rettv_dict_alloc(rettv) != OK)
+	return;
 
-	dict_add_string(dict, "char", last_csearch());
-	dict_add_number(dict, "forward", last_csearch_forward());
-	dict_add_number(dict, "until", last_csearch_until());
-    }
+    dict_T *dict = rettv->vval.v_dict;
+
+    dict_add_string(dict, "char", last_csearch());
+    dict_add_number(dict, "forward", last_csearch_forward());
+    dict_add_number(dict, "until", last_csearch_until());
 }
 
 /*
@@ -6792,29 +6792,29 @@
     }
 
     l = argvars[0].vval.v_list;
-    if (l != NULL)
-    {
-	CHECK_LIST_MATERIALIZE(l);
-	item = l->lv_first;
-	if (argvars[2].v_type != VAR_UNKNOWN)
-	{
-	    // Start at specified item.  Use the cached index that list_find()
-	    // sets, so that a negative number also works.
-	    item = list_find(l, (long)tv_get_number_chk(&argvars[2], &error));
-	    idx = l->lv_u.mat.lv_idx;
-	    if (argvars[3].v_type != VAR_UNKNOWN)
-		ic = (int)tv_get_bool_chk(&argvars[3], &error);
-	    if (error)
-		item = NULL;
-	}
+    if (l == NULL)
+	return;
 
-	for ( ; item != NULL; item = item->li_next, ++idx)
-	    if (tv_equal(&item->li_tv, &argvars[1], ic, FALSE))
-	    {
-		rettv->vval.v_number = idx;
-		break;
-	    }
+    CHECK_LIST_MATERIALIZE(l);
+    item = l->lv_first;
+    if (argvars[2].v_type != VAR_UNKNOWN)
+    {
+	// Start at specified item.  Use the cached index that list_find()
+	// sets, so that a negative number also works.
+	item = list_find(l, (long)tv_get_number_chk(&argvars[2], &error));
+	idx = l->lv_u.mat.lv_idx;
+	if (argvars[3].v_type != VAR_UNKNOWN)
+	    ic = (int)tv_get_bool_chk(&argvars[3], &error);
+	if (error)
+	    item = NULL;
     }
+
+    for ( ; item != NULL; item = item->li_next, ++idx)
+	if (tv_equal(&item->li_tv, &argvars[1], ic, FALSE))
+	{
+	    rettv->vval.v_number = idx;
+	    break;
+	}
 }
 
 /*
@@ -8363,22 +8363,26 @@
     if (error)
 	return;		// type error; errmsg already given
     if (stride == 0)
-	emsg(_(e_stride_is_zero));
-    else if (stride > 0 ? end + 1 < start : end - 1 > start)
-	emsg(_(e_start_past_end));
-    else
     {
-	list_T *list = rettv->vval.v_list;
-
-	// Create a non-materialized list.  This is much more efficient and
-	// works with ":for".  If used otherwise CHECK_LIST_MATERIALIZE() must
-	// be called.
-	list->lv_first = &range_list_item;
-	list->lv_u.nonmat.lv_start = start;
-	list->lv_u.nonmat.lv_end = end;
-	list->lv_u.nonmat.lv_stride = stride;
-	list->lv_len = (end - start) / stride + 1;
+	emsg(_(e_stride_is_zero));
+	return;
     }
+    if (stride > 0 ? end + 1 < start : end - 1 > start)
+    {
+	emsg(_(e_start_past_end));
+	return;
+    }
+
+    list_T *list = rettv->vval.v_list;
+
+    // Create a non-materialized list.  This is much more efficient and
+    // works with ":for".  If used otherwise CHECK_LIST_MATERIALIZE() must
+    // be called.
+    list->lv_first = &range_list_item;
+    list->lv_u.nonmat.lv_start = start;
+    list->lv_u.nonmat.lv_end = end;
+    list->lv_u.nonmat.lv_stride = stride;
+    list->lv_len = (end - start) / stride + 1;
 }
 
 /*
@@ -9382,34 +9386,34 @@
 	return;
 
     name = tv_get_string_chk(argvars);
-    if (name != NULL)
+    if (name == NULL)
+	return;
+
+    if (list2fpos(&argvars[1], &pos, &fnum, &curswant, charpos) != OK)
+	return;
+
+    if (pos.col != MAXCOL && --pos.col < 0)
+	pos.col = 0;
+    if ((name[0] == '.' && name[1] == NUL))
     {
-	if (list2fpos(&argvars[1], &pos, &fnum, &curswant, charpos) == OK)
+	// set cursor; "fnum" is ignored
+	curwin->w_cursor = pos;
+	if (curswant >= 0)
 	{
-	    if (pos.col != MAXCOL && --pos.col < 0)
-		pos.col = 0;
-	    if ((name[0] == '.' && name[1] == NUL))
-	    {
-		// set cursor; "fnum" is ignored
-		curwin->w_cursor = pos;
-		if (curswant >= 0)
-		{
-		    curwin->w_curswant = curswant - 1;
-		    curwin->w_set_curswant = FALSE;
-		}
-		check_cursor();
-		rettv->vval.v_number = 0;
-	    }
-	    else if (name[0] == '\'' && name[1] != NUL && name[2] == NUL)
-	    {
-		// set mark
-		if (setmark_pos(name[1], &pos, fnum) == OK)
-		    rettv->vval.v_number = 0;
-	    }
-	    else
-		emsg(_(e_invalid_argument));
+	    curwin->w_curswant = curswant - 1;
+	    curwin->w_set_curswant = FALSE;
 	}
+	check_cursor();
+	rettv->vval.v_number = 0;
     }
+    else if (name[0] == '\'' && name[1] != NUL && name[2] == NUL)
+    {
+	// set mark
+	if (setmark_pos(name[1], &pos, fnum) == OK)
+	    rettv->vval.v_number = 0;
+    }
+    else
+	emsg(_(e_invalid_argument));
 }
 /*
  * "setcharpos()" function
@@ -9430,32 +9434,32 @@
     if (check_for_dict_arg(argvars, 0) == FAIL)
 	return;
 
-    if ((d = argvars[0].vval.v_dict) != NULL)
+    if ((d = argvars[0].vval.v_dict) == NULL)
+	return;
+
+    csearch = dict_get_string(d, "char", FALSE);
+    if (csearch != NULL)
     {
-	csearch = dict_get_string(d, "char", FALSE);
-	if (csearch != NULL)
+	if (enc_utf8)
 	{
-	    if (enc_utf8)
-	    {
-		int pcc[MAX_MCO];
-		int c = utfc_ptr2char(csearch, pcc);
+	    int pcc[MAX_MCO];
+	    int c = utfc_ptr2char(csearch, pcc);
 
-		set_last_csearch(c, csearch, utfc_ptr2len(csearch));
-	    }
-	    else
-		set_last_csearch(PTR2CHAR(csearch),
-						csearch, mb_ptr2len(csearch));
+	    set_last_csearch(c, csearch, utfc_ptr2len(csearch));
 	}
-
-	di = dict_find(d, (char_u *)"forward", -1);
-	if (di != NULL)
-	    set_csearch_direction((int)tv_get_number(&di->di_tv)
-							? FORWARD : BACKWARD);
-
-	di = dict_find(d, (char_u *)"until", -1);
-	if (di != NULL)
-	    set_csearch_until(!!tv_get_number(&di->di_tv));
+	else
+	    set_last_csearch(PTR2CHAR(csearch),
+		    csearch, mb_ptr2len(csearch));
     }
+
+    di = dict_find(d, (char_u *)"forward", -1);
+    if (di != NULL)
+	set_csearch_direction((int)tv_get_number(&di->di_tv)
+		? FORWARD : BACKWARD);
+
+    di = dict_find(d, (char_u *)"until", -1);
+    if (di != NULL)
+	set_csearch_until(!!tv_get_number(&di->di_tv));
 }
 
 /*
diff --git a/src/evalvars.c b/src/evalvars.c
index d946669..389a9e4 100644
--- a/src/evalvars.c
+++ b/src/evalvars.c
@@ -350,15 +350,15 @@
     typval_T	*tvp;
 
     val = vim_strsave(value);
-    if (val != NULL)
-    {
-	tvp = alloc_string_tv(val);
-	if (tvp != NULL)
-	{
-	    set_var(name, tvp, FALSE);
-	    free_tv(tvp);
-	}
-    }
+    if (val == NULL)
+	return;
+
+    tvp = alloc_string_tv(val);
+    if (tvp == NULL)
+	return;
+
+    set_var(name, tvp, FALSE);
+    free_tv(tvp);
 }
 
     int
@@ -576,14 +576,14 @@
     hashitem_T	*hi;
 
     vimvars[idx].vv_tv = *save_tv;
-    if (vimvars[idx].vv_tv_type == VAR_UNKNOWN)
-    {
-	hi = hash_find(&vimvarht, vimvars[idx].vv_di.di_key);
-	if (HASHITEM_EMPTY(hi))
-	    internal_error("restore_vimvar()");
-	else
-	    hash_remove(&vimvarht, hi, "restore vimvar");
-    }
+    if (vimvars[idx].vv_tv_type != VAR_UNKNOWN)
+	return;
+
+    hi = hash_find(&vimvarht, vimvars[idx].vv_di.di_key);
+    if (HASHITEM_EMPTY(hi))
+	internal_error("restore_vimvar()");
+    else
+	hash_remove(&vimvarht, hi, "restore vimvar");
 }
 
 /*
@@ -2740,11 +2740,11 @@
     clear_tv(&vimvars[idx].vv_di.di_tv);
     vimvars[idx].vv_tv_type = VAR_DICT;
     vimvars[idx].vv_dict = val;
-    if (val != NULL)
-    {
-	++val->dv_refcount;
-	dict_set_items_ro(val);
-    }
+    if (val == NULL)
+	return;
+
+    ++val->dv_refcount;
+    dict_set_items_ro(val);
 }
 
 /*
@@ -3562,11 +3562,11 @@
 {
     dictitem_T	*di = HI2DI(hi);
 
-    if (hash_remove(ht, hi, "delete variable") == OK)
-    {
-	clear_tv(&di->di_tv);
-	vim_free(di);
-    }
+    if (hash_remove(ht, hi, "delete variable") != OK)
+	return;
+
+    clear_tv(&di->di_tv);
+    vim_free(di);
 }
 
 /*
@@ -4317,29 +4317,29 @@
     varname = tv_get_string_chk(&argvars[off + 1]);
     varp = &argvars[off + 2];
 
-    if (win != NULL && varname != NULL && varp != NULL)
+    if (win == NULL || varname == NULL || varp == NULL)
+	return;
+
+    need_switch_win = !(tp == curtab && win == curwin);
+    if (!need_switch_win
+	    || switch_win(&switchwin, win, tp, TRUE) == OK)
     {
-	need_switch_win = !(tp == curtab && win == curwin);
-	if (!need_switch_win
-	       || switch_win(&switchwin, win, tp, TRUE) == OK)
+	if (*varname == '&')
+	    set_option_from_tv(varname + 1, varp);
+	else
 	{
-	    if (*varname == '&')
-		set_option_from_tv(varname + 1, varp);
-	    else
+	    winvarname = alloc(STRLEN(varname) + 3);
+	    if (winvarname != NULL)
 	    {
-		winvarname = alloc(STRLEN(varname) + 3);
-		if (winvarname != NULL)
-		{
-		    STRCPY(winvarname, "w:");
-		    STRCPY(winvarname + 2, varname);
-		    set_var(winvarname, varp, TRUE);
-		    vim_free(winvarname);
-		}
+		STRCPY(winvarname, "w:");
+		STRCPY(winvarname + 2, varname);
+		set_var(winvarname, varp, TRUE);
+		vim_free(winvarname);
 	    }
 	}
-	if (need_switch_win)
-	    restore_win(&switchwin, TRUE);
     }
+    if (need_switch_win)
+	restore_win(&switchwin, TRUE);
 }
 
 /*
@@ -4686,24 +4686,24 @@
     varname = tv_get_string_chk(&argvars[1]);
     varp = &argvars[2];
 
-    if (varname != NULL && varp != NULL && tp != NULL)
+    if (varname == NULL || varp == NULL || tp == NULL)
+	return;
+
+    save_curtab = curtab;
+    goto_tabpage_tp(tp, FALSE, FALSE);
+
+    tabvarname = alloc(STRLEN(varname) + 3);
+    if (tabvarname != NULL)
     {
-	save_curtab = curtab;
-	goto_tabpage_tp(tp, FALSE, FALSE);
-
-	tabvarname = alloc(STRLEN(varname) + 3);
-	if (tabvarname != NULL)
-	{
-	    STRCPY(tabvarname, "t:");
-	    STRCPY(tabvarname + 2, varname);
-	    set_var(tabvarname, varp, TRUE);
-	    vim_free(tabvarname);
-	}
-
-	// Restore current tabpage
-	if (valid_tabpage(save_curtab))
-	    goto_tabpage_tp(save_curtab, FALSE, FALSE);
+	STRCPY(tabvarname, "t:");
+	STRCPY(tabvarname + 2, varname);
+	set_var(tabvarname, varp, TRUE);
+	vim_free(tabvarname);
     }
+
+    // Restore current tabpage
+    if (valid_tabpage(save_curtab))
+	goto_tabpage_tp(save_curtab, FALSE, FALSE);
 }
 
 /*
@@ -4757,37 +4757,37 @@
     buf = tv_get_buf_from_arg(&argvars[0]);
     varp = &argvars[2];
 
-    if (buf != NULL && varname != NULL && varp != NULL)
+    if (buf == NULL || varname == NULL || varp == NULL)
+	return;
+
+    if (*varname == '&')
     {
-	if (*varname == '&')
+	aco_save_T	aco;
+
+	// Set curbuf to be our buf, temporarily.
+	aucmd_prepbuf(&aco, buf);
+	if (curbuf == buf)
 	{
-	    aco_save_T	aco;
+	    // Only when it worked to set "curbuf".
+	    set_option_from_tv(varname + 1, varp);
 
-	    // Set curbuf to be our buf, temporarily.
-	    aucmd_prepbuf(&aco, buf);
-	    if (curbuf == buf)
-	    {
-		// Only when it worked to set "curbuf".
-		set_option_from_tv(varname + 1, varp);
-
-		// reset notion of buffer
-		aucmd_restbuf(&aco);
-	    }
+	    // reset notion of buffer
+	    aucmd_restbuf(&aco);
 	}
-	else
+    }
+    else
+    {
+	bufvarname = alloc(STRLEN(varname) + 3);
+	if (bufvarname != NULL)
 	{
-	    bufvarname = alloc(STRLEN(varname) + 3);
-	    if (bufvarname != NULL)
-	    {
-		buf_T *save_curbuf = curbuf;
+	    buf_T *save_curbuf = curbuf;
 
-		curbuf = buf;
-		STRCPY(bufvarname, "b:");
-		STRCPY(bufvarname + 2, varname);
-		set_var(bufvarname, varp, TRUE);
-		vim_free(bufvarname);
-		curbuf = save_curbuf;
-	    }
+	    curbuf = buf;
+	    STRCPY(bufvarname, "b:");
+	    STRCPY(bufvarname + 2, varname);
+	    set_var(bufvarname, varp, TRUE);
+	    vim_free(bufvarname);
+	    curbuf = save_curbuf;
 	}
     }
 }
@@ -4930,31 +4930,30 @@
     p = vim_strchr(name, '.');
     if (p == NULL)
 	return;
+
     import = find_imported(name, p - name, FALSE);
-    if (import != NULL && SCRIPT_ID_VALID(import->imp_sid))
+    if (import == NULL || !SCRIPT_ID_VALID(import->imp_sid))
+	return;
+
+    scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
+    if (si->sn_autoload_prefix == NULL)
+	return;
+
+    char_u *newname = concat_str(si->sn_autoload_prefix, p + 1);
+    if (newname == NULL)
+	return;
+
+    if (cb->cb_partial != NULL)
     {
-	scriptitem_T *si = SCRIPT_ITEM(import->imp_sid);
-
-	if (si->sn_autoload_prefix != NULL)
-	{
-	    char_u *newname = concat_str(si->sn_autoload_prefix, p + 1);
-
-	    if (newname != NULL)
-	    {
-		if (cb->cb_partial != NULL)
-		{
-		    if (cb->cb_name == cb->cb_partial->pt_name)
-			cb->cb_name = newname;
-		    vim_free(cb->cb_partial->pt_name);
-		    cb->cb_partial->pt_name = newname;
-		}
-		else
-		{
-		    vim_free(cb->cb_name);
-		    cb->cb_name = newname;
-		}
-	    }
-	}
+	if (cb->cb_name == cb->cb_partial->pt_name)
+	    cb->cb_name = newname;
+	vim_free(cb->cb_partial->pt_name);
+	cb->cb_partial->pt_name = newname;
+    }
+    else
+    {
+	vim_free(cb->cb_name);
+	cb->cb_name = newname;
     }
 }
 
diff --git a/src/evalwindow.c b/src/evalwindow.c
index f8c0c7a..8b47b98 100644
--- a/src/evalwindow.c
+++ b/src/evalwindow.c
@@ -718,66 +718,66 @@
 
     id = (int)tv_get_number(argvars);
     wp = win_id2wp_tp(id, &tp);
-    if (wp != NULL && tp != NULL)
+    if (wp == NULL || tp == NULL)
+	return;
+
+    pos_T	curpos = wp->w_cursor;
+    char_u	cwd[MAXPATHL];
+    int	cwd_status = FAIL;
+#ifdef FEAT_AUTOCHDIR
+    char_u	autocwd[MAXPATHL];
+    int	apply_acd = FALSE;
+#endif
+
+    // Getting and setting directory can be slow on some systems, only do
+    // this when the current or target window/tab have a local directory or
+    // 'acd' is set.
+    if (curwin != wp
+	    && (curwin->w_localdir != NULL
+		|| wp->w_localdir != NULL
+		|| (curtab != tp
+		    && (curtab->tp_localdir != NULL
+			|| tp->tp_localdir != NULL))
+#ifdef FEAT_AUTOCHDIR
+		|| p_acd
+#endif
+	       ))
+	cwd_status = mch_dirname(cwd, MAXPATHL);
+
+#ifdef FEAT_AUTOCHDIR
+    // If 'acd' is set, check we are using that directory.  If yes, then
+    // apply 'acd' afterwards, otherwise restore the current directory.
+    if (cwd_status == OK && p_acd)
     {
-	pos_T	curpos = wp->w_cursor;
-	char_u	cwd[MAXPATHL];
-	int	cwd_status = FAIL;
-#ifdef FEAT_AUTOCHDIR
-	char_u	autocwd[MAXPATHL];
-	int	apply_acd = FALSE;
+	do_autochdir();
+	apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
+	    && STRCMP(cwd, autocwd) == 0;
+    }
 #endif
 
-	// Getting and setting directory can be slow on some systems, only do
-	// this when the current or target window/tab have a local directory or
-	// 'acd' is set.
-	if (curwin != wp
-		&& (curwin->w_localdir != NULL
-		    || wp->w_localdir != NULL
-		    || (curtab != tp
-			&& (curtab->tp_localdir != NULL
-			    || tp->tp_localdir != NULL))
+    if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
+    {
+	check_cursor();
+	execute_common(argvars, rettv, 1);
+    }
+    restore_win_noblock(&switchwin, TRUE);
 #ifdef FEAT_AUTOCHDIR
-		    || p_acd
+    if (apply_acd)
+	do_autochdir();
+    else
 #endif
-		    ))
-	    cwd_status = mch_dirname(cwd, MAXPATHL);
-
-#ifdef FEAT_AUTOCHDIR
-	// If 'acd' is set, check we are using that directory.  If yes, then
-	// apply 'acd' afterwards, otherwise restore the current directory.
-	if (cwd_status == OK && p_acd)
-	{
-	    do_autochdir();
-	    apply_acd = mch_dirname(autocwd, MAXPATHL) == OK
-						  && STRCMP(cwd, autocwd) == 0;
-	}
-#endif
-
-	if (switch_win_noblock(&switchwin, wp, tp, TRUE) == OK)
-	{
-	    check_cursor();
-	    execute_common(argvars, rettv, 1);
-	}
-	restore_win_noblock(&switchwin, TRUE);
-#ifdef FEAT_AUTOCHDIR
-	if (apply_acd)
-	    do_autochdir();
-	else
-#endif
-	    if (cwd_status == OK)
+	if (cwd_status == OK)
 	    mch_chdir((char *)cwd);
 
-	// Update the status line if the cursor moved.
-	if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
-	    wp->w_redr_status = TRUE;
+    // Update the status line if the cursor moved.
+    if (win_valid(wp) && !EQUAL_POS(curpos, wp->w_cursor))
+	wp->w_redr_status = TRUE;
 
-	// In case the command moved the cursor or changed the Visual area,
-	// check it is valid.
-	check_cursor();
-	if (VIsual_active)
-	    check_pos(curbuf, &VIsual);
-    }
+    // In case the command moved the cursor or changed the Visual area,
+    // check it is valid.
+    check_cursor();
+    if (VIsual_active)
+	check_pos(curbuf, &VIsual);
 }
 
 /*
@@ -1093,11 +1093,11 @@
     rettv->v_type = VAR_STRING;
     rettv->vval.v_string = NULL;
     rettv->vval.v_string = alloc(2);
-    if (rettv->vval.v_string != NULL)
-    {
-	rettv->vval.v_string[0] = cmdwin_type;
-	rettv->vval.v_string[1] = NUL;
-    }
+    if (rettv->vval.v_string == NULL)
+	return;
+
+    rettv->vval.v_string[0] = cmdwin_type;
+    rettv->vval.v_string[1] = NUL;
 }
 
 /*
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 9a507c9..4755952 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -7049,12 +7049,12 @@
 	}
     }
 
-    if (fname != NULL)
-    {
-	eap->arg = fname;
-	do_exedit(eap, NULL);
-	vim_free(fname);
-    }
+    if (fname == NULL)
+	return;
+
+    eap->arg = fname;
+    do_exedit(eap, NULL);
+    vim_free(fname);
 }
 
 /*
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 4884ebd..49331c4 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -4210,11 +4210,11 @@
 {
     rettv->v_type = VAR_STRING;
     rettv->vval.v_string = alloc(2);
-    if (rettv->vval.v_string != NULL)
-    {
-	rettv->vval.v_string[0] = get_cmdline_type();
-	rettv->vval.v_string[1] = NUL;
-    }
+    if (rettv->vval.v_string == NULL)
+	return;
+
+    rettv->vval.v_string[0] = get_cmdline_type();
+    rettv->vval.v_string[1] = NUL;
 }
 
 // Set the command line str to "str".
diff --git a/src/fileio.c b/src/fileio.c
index 1ee08e2..d8b395a 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2767,15 +2767,15 @@
     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 @@
 	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 @@
    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 @@
     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 @@
     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
 
diff --git a/src/float.c b/src/float.c
index 04bb8a1..9e8074d 100644
--- a/src/float.c
+++ b/src/float.c
@@ -288,15 +288,15 @@
     if (in_vim9script() && check_for_float_or_nr_arg(argvars, 0) == FAIL)
 	return;
 
-    if (get_float_arg(argvars, &f) == OK)
-    {
-	if (f <= (float_T)-VARNUM_MAX + DBL_EPSILON)
-	    rettv->vval.v_number = -VARNUM_MAX;
-	else if (f >= (float_T)VARNUM_MAX - DBL_EPSILON)
-	    rettv->vval.v_number = VARNUM_MAX;
-	else
-	    rettv->vval.v_number = (varnumber_T)f;
-    }
+    if (get_float_arg(argvars, &f) != OK)
+	return;
+
+    if (f <= (float_T)-VARNUM_MAX + DBL_EPSILON)
+	rettv->vval.v_number = -VARNUM_MAX;
+    else if (f >= (float_T)VARNUM_MAX - DBL_EPSILON)
+	rettv->vval.v_number = VARNUM_MAX;
+    else
+	rettv->vval.v_number = (varnumber_T)f;
 }
 
 /*
diff --git a/src/fold.c b/src/fold.c
index a226d6f..d722a56 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -644,59 +644,59 @@
 	    i = (int)(fp - (fold_T *)gap->ga_data);
     }
 
-    if (ga_grow(gap, 1) == OK)
+    if (ga_grow(gap, 1) != OK)
+	return;
+
+    fp = (fold_T *)gap->ga_data + i;
+    ga_init2(&fold_ga, sizeof(fold_T), 10);
+
+    // Count number of folds that will be contained in the new fold.
+    for (cont = 0; i + cont < gap->ga_len; ++cont)
+	if (fp[cont].fd_top > end_rel)
+	    break;
+    if (cont > 0 && ga_grow(&fold_ga, cont) == OK)
     {
-	fp = (fold_T *)gap->ga_data + i;
-	ga_init2(&fold_ga, sizeof(fold_T), 10);
+	// If the first fold starts before the new fold, let the new fold
+	// start there.  Otherwise the existing fold would change.
+	if (start_rel > fp->fd_top)
+	    start_rel = fp->fd_top;
 
-	// Count number of folds that will be contained in the new fold.
-	for (cont = 0; i + cont < gap->ga_len; ++cont)
-	    if (fp[cont].fd_top > end_rel)
-		break;
-	if (cont > 0 && ga_grow(&fold_ga, cont) == OK)
-	{
-	    // If the first fold starts before the new fold, let the new fold
-	    // start there.  Otherwise the existing fold would change.
-	    if (start_rel > fp->fd_top)
-		start_rel = fp->fd_top;
+	// When last contained fold isn't completely contained, adjust end
+	// of new fold.
+	if (end_rel < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1)
+	    end_rel = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1;
+	// Move contained folds to inside new fold.
+	mch_memmove(fold_ga.ga_data, fp, sizeof(fold_T) * cont);
+	fold_ga.ga_len += cont;
+	i += cont;
 
-	    // When last contained fold isn't completely contained, adjust end
-	    // of new fold.
-	    if (end_rel < fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1)
-		end_rel = fp[cont - 1].fd_top + fp[cont - 1].fd_len - 1;
-	    // Move contained folds to inside new fold.
-	    mch_memmove(fold_ga.ga_data, fp, sizeof(fold_T) * cont);
-	    fold_ga.ga_len += cont;
-	    i += cont;
-
-	    // Adjust line numbers in contained folds to be relative to the
-	    // new fold.
-	    for (j = 0; j < cont; ++j)
-		((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel;
-	}
-	// Move remaining entries to after the new fold.
-	if (i < gap->ga_len)
-	    mch_memmove(fp + 1, (fold_T *)gap->ga_data + i,
-				     sizeof(fold_T) * (gap->ga_len - i));
-	gap->ga_len = gap->ga_len + 1 - cont;
-
-	// insert new fold
-	fp->fd_nested = fold_ga;
-	fp->fd_top = start_rel;
-	fp->fd_len = end_rel - start_rel + 1;
-
-	// We want the new fold to be closed.  If it would remain open because
-	// of using 'foldlevel', need to adjust fd_flags of containing folds.
-	if (use_level && !closed && level < curwin->w_p_fdl)
-	    closeFold(start, 1L);
-	if (!use_level)
-	    curwin->w_fold_manual = TRUE;
-	fp->fd_flags = FD_CLOSED;
-	fp->fd_small = MAYBE;
-
-	// redraw
-	changed_window_setting();
+	// Adjust line numbers in contained folds to be relative to the
+	// new fold.
+	for (j = 0; j < cont; ++j)
+	    ((fold_T *)fold_ga.ga_data)[j].fd_top -= start_rel;
     }
+    // Move remaining entries to after the new fold.
+    if (i < gap->ga_len)
+	mch_memmove(fp + 1, (fold_T *)gap->ga_data + i,
+		sizeof(fold_T) * (gap->ga_len - i));
+    gap->ga_len = gap->ga_len + 1 - cont;
+
+    // insert new fold
+    fp->fd_nested = fold_ga;
+    fp->fd_top = start_rel;
+    fp->fd_len = end_rel - start_rel + 1;
+
+    // We want the new fold to be closed.  If it would remain open because
+    // of using 'foldlevel', need to adjust fd_flags of containing folds.
+    if (use_level && !closed && level < curwin->w_p_fdl)
+	closeFold(start, 1L);
+    if (!use_level)
+	curwin->w_fold_manual = TRUE;
+    fp->fd_flags = FD_CLOSED;
+    fp->fd_small = MAYBE;
+
+    // redraw
+    changed_window_setting();
 }
 
 // deleteFold() {{{2
@@ -1719,27 +1719,27 @@
     int		count;
     int		n;
 
-    if (fp->fd_small == MAYBE)
-    {
-	// Mark any nested folds to maybe-small
-	setSmallMaybe(&fp->fd_nested);
+    if (fp->fd_small != MAYBE)
+	return;
 
-	if (fp->fd_len > curwin->w_p_fml)
-	    fp->fd_small = FALSE;
-	else
+    // Mark any nested folds to maybe-small
+    setSmallMaybe(&fp->fd_nested);
+
+    if (fp->fd_len > curwin->w_p_fml)
+	fp->fd_small = FALSE;
+    else
+    {
+	count = 0;
+	for (n = 0; n < fp->fd_len; ++n)
 	{
-	    count = 0;
-	    for (n = 0; n < fp->fd_len; ++n)
+	    count += plines_win_nofold(wp, fp->fd_top + lnum_off + n);
+	    if (count > curwin->w_p_fml)
 	    {
-		count += plines_win_nofold(wp, fp->fd_top + lnum_off + n);
-		if (count > curwin->w_p_fml)
-		{
-		    fp->fd_small = FALSE;
-		    return;
-		}
+		fp->fd_small = FALSE;
+		return;
 	    }
-	    fp->fd_small = TRUE;
 	}
+	fp->fd_small = TRUE;
     }
 }
 
@@ -1799,26 +1799,26 @@
     line = ml_get(lnum);
     line_len = (int)STRLEN(line);
 
-    if (u_save(lnum - 1, lnum + 1) == OK)
-    {
-	// Check if the line ends with an unclosed comment
-	(void)skip_comment(line, FALSE, FALSE, &line_is_comment);
-	newline = alloc(line_len + markerlen + STRLEN(cms) + 1);
-	if (newline == NULL)
-	    return;
-	STRCPY(newline, line);
-	// Append the marker to the end of the line
-	if (p == NULL || line_is_comment)
-	    vim_strncpy(newline + line_len, marker, markerlen);
-	else
-	{
-	    STRCPY(newline + line_len, cms);
-	    STRNCPY(newline + line_len + (p - cms), marker, markerlen);
-	    STRCPY(newline + line_len + (p - cms) + markerlen, p + 2);
-	}
+    if (u_save(lnum - 1, lnum + 1) != OK)
+	return;
 
-	ml_replace(lnum, newline, FALSE);
+    // Check if the line ends with an unclosed comment
+    (void)skip_comment(line, FALSE, FALSE, &line_is_comment);
+    newline = alloc(line_len + markerlen + STRLEN(cms) + 1);
+    if (newline == NULL)
+	return;
+    STRCPY(newline, line);
+    // Append the marker to the end of the line
+    if (p == NULL || line_is_comment)
+	vim_strncpy(newline + line_len, marker, markerlen);
+    else
+    {
+	STRCPY(newline + line_len, cms);
+	STRNCPY(newline + line_len + (p - cms), marker, markerlen);
+	STRCPY(newline + line_len + (p - cms) + markerlen, p + 2);
     }
+
+    ml_replace(lnum, newline, FALSE);
 }
 
 // deleteFoldMarkers() {{{2
diff --git a/src/version.c b/src/version.c
index babedcc..08a0215 100644
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1132,
+/**/
     1131,
 /**/
     1130,
