patch 9.0.1208: code is indented more than necessary

Problem:    Code is indented more than necessary.
Solution:   Use an early return where it makes sense. (Yegappan Lakshmanan,
            closes #11819)
diff --git a/src/os_unix.c b/src/os_unix.c
index 194f4be..0dfbd49 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -780,16 +780,16 @@
     int
 mch_stackcheck(char *p)
 {
-    if (stack_limit != NULL)
+    if (stack_limit == NULL)
+	return OK;
+
+    if (stack_grows_downwards)
     {
-	if (stack_grows_downwards)
-	{
-	    if (p < stack_limit)
-		return FAIL;
-	}
-	else if (p > stack_limit)
+	if (p < stack_limit)
 	    return FAIL;
     }
+    else if (p > stack_limit)
+	return FAIL;
     return OK;
 }
 #endif
@@ -837,25 +837,25 @@
     static void
 init_signal_stack(void)
 {
-    if (signal_stack != NULL)
-    {
+    if (signal_stack == NULL)
+	return;
+
 # ifdef HAVE_SIGALTSTACK
 #  ifdef HAVE_SS_BASE
-	sigstk.ss_base = signal_stack;
+    sigstk.ss_base = signal_stack;
 #  else
-	sigstk.ss_sp = signal_stack;
+    sigstk.ss_sp = signal_stack;
 #  endif
-	sigstk.ss_size = get_signal_stack_size();
-	sigstk.ss_flags = 0;
-	(void)sigaltstack(&sigstk, NULL);
+    sigstk.ss_size = get_signal_stack_size();
+    sigstk.ss_flags = 0;
+    (void)sigaltstack(&sigstk, NULL);
 # else
-	sigstk.ss_sp = signal_stack;
-	if (stack_grows_downwards)
-	    sigstk.ss_sp += get_signal_stack_size() - 1;
-	sigstk.ss_onstack = 0;
-	(void)sigstack(&sigstk, NULL);
+    sigstk.ss_sp = signal_stack;
+    if (stack_grows_downwards)
+	sigstk.ss_sp += get_signal_stack_size() - 1;
+    sigstk.ss_onstack = 0;
+    (void)sigstack(&sigstk, NULL);
 # endif
-    }
 }
 #endif
 
@@ -2020,91 +2020,90 @@
     int			retval = FALSE;
     Status		status;
 
-    if (get_x11_windis() == OK)
+    if (get_x11_windis() != OK)
+	return FALSE;
+
+    // Get window/icon name if any
+    if (get_title)
+	status = XGetWMName(x11_display, x11_window, &text_prop);
+    else
+	status = XGetWMIconName(x11_display, x11_window, &text_prop);
+
+    /*
+     * If terminal is xterm, then x11_window may be a child window of the
+     * outer xterm window that actually contains the window/icon name, so
+     * keep traversing up the tree until a window with a title/icon is
+     * found.
+     */
+    // Previously this was only done for xterm and alike.  I don't see a
+    // reason why it would fail for other terminal emulators.
+    // if (term_is_xterm)
+    Window	    root;
+    Window	    parent;
+    Window	    win = x11_window;
+    Window	   *children;
+    unsigned int    num_children;
+
+    while (!status || text_prop.value == NULL)
     {
-	// Get window/icon name if any
+	if (!XQueryTree(x11_display, win, &root, &parent, &children,
+		    &num_children))
+	    break;
+	if (children)
+	    XFree((void *)children);
+	if (parent == root || parent == 0)
+	    break;
+
+	win = parent;
 	if (get_title)
-	    status = XGetWMName(x11_display, x11_window, &text_prop);
+	    status = XGetWMName(x11_display, win, &text_prop);
 	else
-	    status = XGetWMIconName(x11_display, x11_window, &text_prop);
+	    status = XGetWMIconName(x11_display, win, &text_prop);
+    }
 
-	/*
-	 * If terminal is xterm, then x11_window may be a child window of the
-	 * outer xterm window that actually contains the window/icon name, so
-	 * keep traversing up the tree until a window with a title/icon is
-	 * found.
-	 */
-	// Previously this was only done for xterm and alike.  I don't see a
-	// reason why it would fail for other terminal emulators.
-	// if (term_is_xterm)
+    if (status && text_prop.value != NULL)
+    {
+	retval = TRUE;
+	if (!test_only)
 	{
-	    Window	    root;
-	    Window	    parent;
-	    Window	    win = x11_window;
-	    Window	   *children;
-	    unsigned int    num_children;
-
-	    while (!status || text_prop.value == NULL)
+	    if (get_title)
+		vim_free(oldtitle);
+	    else
+		vim_free(oldicon);
+	    if (text_prop.encoding == XA_STRING && !has_mbyte)
 	    {
-		if (!XQueryTree(x11_display, win, &root, &parent, &children,
-							       &num_children))
-		    break;
-		if (children)
-		    XFree((void *)children);
-		if (parent == root || parent == 0)
-		    break;
-
-		win = parent;
 		if (get_title)
-		    status = XGetWMName(x11_display, win, &text_prop);
+		    oldtitle = vim_strsave((char_u *)text_prop.value);
 		else
-		    status = XGetWMIconName(x11_display, win, &text_prop);
+		    oldicon = vim_strsave((char_u *)text_prop.value);
 	    }
-	}
-	if (status && text_prop.value != NULL)
-	{
-	    retval = TRUE;
-	    if (!test_only)
+	    else
 	    {
-		if (get_title)
-		    vim_free(oldtitle);
+		char    **cl;
+		Status  transform_status;
+		int	    n = 0;
+
+		transform_status = XmbTextPropertyToTextList(x11_display,
+			&text_prop,
+			&cl, &n);
+		if (transform_status >= Success && n > 0 && cl[0])
+		{
+		    if (get_title)
+			oldtitle = vim_strsave((char_u *) cl[0]);
+		    else
+			oldicon = vim_strsave((char_u *) cl[0]);
+		    XFreeStringList(cl);
+		}
 		else
-		    vim_free(oldicon);
-		if (text_prop.encoding == XA_STRING && !has_mbyte)
 		{
 		    if (get_title)
 			oldtitle = vim_strsave((char_u *)text_prop.value);
 		    else
 			oldicon = vim_strsave((char_u *)text_prop.value);
 		}
-		else
-		{
-		    char    **cl;
-		    Status  transform_status;
-		    int	    n = 0;
-
-		    transform_status = XmbTextPropertyToTextList(x11_display,
-								 &text_prop,
-								 &cl, &n);
-		    if (transform_status >= Success && n > 0 && cl[0])
-		    {
-			if (get_title)
-			    oldtitle = vim_strsave((char_u *) cl[0]);
-			else
-			    oldicon = vim_strsave((char_u *) cl[0]);
-			XFreeStringList(cl);
-		    }
-		    else
-		    {
-			if (get_title)
-			    oldtitle = vim_strsave((char_u *)text_prop.value);
-			else
-			    oldicon = vim_strsave((char_u *)text_prop.value);
-		    }
-		}
 	    }
-	    XFree((void *)text_prop.value);
 	}
+	XFree((void *)text_prop.value);
     }
     return retval;
 }
@@ -2772,52 +2771,52 @@
     DIR		*dirp;
     struct dirent *dp;
 
-    if (mch_lstat((char *)name, &st) >= 0)
+    if (mch_lstat((char *)name, &st) < 0)
+	return;
+
+    // Open the directory where the file is located.
+    slash = vim_strrchr(name, '/');
+    if (slash == NULL)
     {
-	// Open the directory where the file is located.
-	slash = vim_strrchr(name, '/');
-	if (slash == NULL)
-	{
-	    dirp = opendir(".");
-	    tail = name;
-	}
-	else
-	{
-	    *slash = NUL;
-	    dirp = opendir((char *)name);
-	    *slash = '/';
-	    tail = slash + 1;
-	}
+	dirp = opendir(".");
+	tail = name;
+    }
+    else
+    {
+	*slash = NUL;
+	dirp = opendir((char *)name);
+	*slash = '/';
+	tail = slash + 1;
+    }
 
-	if (dirp != NULL)
+    if (dirp == NULL)
+	return;
+
+    while ((dp = readdir(dirp)) != NULL)
+    {
+	// Only accept names that differ in case and are the same byte
+	// length. TODO: accept different length name.
+	if (STRICMP(tail, dp->d_name) == 0
+		&& STRLEN(tail) == STRLEN(dp->d_name))
 	{
-	    while ((dp = readdir(dirp)) != NULL)
+	    char_u	newname[MAXPATHL + 1];
+	    struct stat st2;
+
+	    // Verify the inode is equal.
+	    vim_strncpy(newname, name, MAXPATHL);
+	    vim_strncpy(newname + (tail - name), (char_u *)dp->d_name,
+		    MAXPATHL - (tail - name));
+	    if (mch_lstat((char *)newname, &st2) >= 0
+		    && st.st_ino == st2.st_ino
+		    && st.st_dev == st2.st_dev)
 	    {
-		// Only accept names that differ in case and are the same byte
-		// length. TODO: accept different length name.
-		if (STRICMP(tail, dp->d_name) == 0
-			&& STRLEN(tail) == STRLEN(dp->d_name))
-		{
-		    char_u	newname[MAXPATHL + 1];
-		    struct stat st2;
-
-		    // Verify the inode is equal.
-		    vim_strncpy(newname, name, MAXPATHL);
-		    vim_strncpy(newname + (tail - name), (char_u *)dp->d_name,
-						    MAXPATHL - (tail - name));
-		    if (mch_lstat((char *)newname, &st2) >= 0
-			    && st.st_ino == st2.st_ino
-			    && st.st_dev == st2.st_dev)
-		    {
-			STRCPY(tail, dp->d_name);
-			break;
-		    }
-		}
+		STRCPY(tail, dp->d_name);
+		break;
 	    }
-
-	    closedir(dirp);
 	}
     }
+
+    closedir(dirp);
 }
 #endif
 
@@ -2902,46 +2901,46 @@
     if (selinux_enabled == -1)
 	selinux_enabled = is_selinux_enabled();
 
-    if (selinux_enabled > 0)
+    if (selinux_enabled <= 0)
+	return;
+
+    // Use "char *" instead of "security_context_t" to avoid a deprecation
+    // warning.
+    char *from_context = NULL;
+    char *to_context = NULL;
+
+    if (getfilecon((char *)from_file, &from_context) < 0)
     {
-	// Use "char *" instead of "security_context_t" to avoid a deprecation
-	// warning.
-	char *from_context = NULL;
-	char *to_context = NULL;
-
-	if (getfilecon((char *)from_file, &from_context) < 0)
-	{
-	    // If the filesystem doesn't support extended attributes,
-	    // the original had no special security context and the
-	    // target cannot have one either.
-	    if (errno == EOPNOTSUPP)
-		return;
-
-	    msg_puts(_("\nCould not get security context for "));
-	    msg_outtrans(from_file);
-	    msg_putchar('\n');
+	// If the filesystem doesn't support extended attributes,
+	// the original had no special security context and the
+	// target cannot have one either.
+	if (errno == EOPNOTSUPP)
 	    return;
-	}
-	if (getfilecon((char *)to_file, &to_context) < 0)
+
+	msg_puts(_("\nCould not get security context for "));
+	msg_outtrans(from_file);
+	msg_putchar('\n');
+	return;
+    }
+    if (getfilecon((char *)to_file, &to_context) < 0)
+    {
+	msg_puts(_("\nCould not get security context for "));
+	msg_outtrans(to_file);
+	msg_putchar('\n');
+	freecon (from_context);
+	return ;
+    }
+    if (strcmp(from_context, to_context) != 0)
+    {
+	if (setfilecon((char *)to_file, from_context) < 0)
 	{
-	    msg_puts(_("\nCould not get security context for "));
+	    msg_puts(_("\nCould not set security context for "));
 	    msg_outtrans(to_file);
 	    msg_putchar('\n');
-	    freecon (from_context);
-	    return ;
 	}
-	if (strcmp(from_context, to_context) != 0)
-	{
-	    if (setfilecon((char *)to_file, from_context) < 0)
-	    {
-		msg_puts(_("\nCould not set security context for "));
-		msg_outtrans(to_file);
-		msg_putchar('\n');
-	    }
-	}
-	freecon(to_context);
-	freecon(from_context);
     }
+    freecon(to_context);
+    freecon(from_context);
 }
 #endif // HAVE_SELINUX
 
@@ -3549,21 +3548,21 @@
     int		retval = -1;
 
     tty_fd = get_tty_fd(fd);
-    if (tty_fd >= 0)
-    {
+    if (tty_fd < 0)
+	return -1;
+
 #ifdef NEW_TTY_SYSTEM
 # ifdef HAVE_TERMIOS_H
-	retval = tcgetattr(tty_fd, (struct termios *)term);
+    retval = tcgetattr(tty_fd, (struct termios *)term);
 # else
-	retval = ioctl(tty_fd, TCGETA, (struct termio *)term);
+    retval = ioctl(tty_fd, TCGETA, (struct termio *)term);
 # endif
 #else
-	// for "old" tty systems
-	retval = ioctl(tty_fd, TIOCGETP, (struct sgttyb *)term);
+    // for "old" tty systems
+    retval = ioctl(tty_fd, TIOCGETP, (struct sgttyb *)term);
 #endif
-	if (tty_fd != fd)
-	    close(tty_fd);
-    }
+    if (tty_fd != fd)
+	close(tty_fd);
     return retval;
 }
 
@@ -3682,18 +3681,18 @@
     char_u	buf[2];
     char_u	*p;
 
-    if (get_tty_info(read_cmd_fd, &info) == OK)
-    {
-	intr_char = info.interrupt;
-	buf[0] = info.backspace;
-	buf[1] = NUL;
-	add_termcode((char_u *)"kb", buf, FALSE);
+    if (get_tty_info(read_cmd_fd, &info) != OK)
+	return;
 
-	// If <BS> and <DEL> are now the same, redefine <DEL>.
-	p = find_termcode((char_u *)"kD");
-	if (p != NULL && p[0] == buf[0] && p[1] == buf[1])
-	    do_fixdel(NULL);
-    }
+    intr_char = info.interrupt;
+    buf[0] = info.backspace;
+    buf[1] = NUL;
+    add_termcode((char_u *)"kb", buf, FALSE);
+
+    // If <BS> and <DEL> are now the same, redefine <DEL>.
+    p = find_termcode((char_u *)"kD");
+    if (p != NULL && p[0] == buf[0] && p[1] == buf[1])
+	do_fixdel(NULL);
 }
 
 /*
@@ -4160,30 +4159,30 @@
     int		retval = -1;
 
     tty_fd = get_tty_fd(fd);
-    if (tty_fd >= 0)
-    {
+    if (tty_fd < 0)
+	return FAIL;
+
 # if defined(TIOCSWINSZ)
-	struct winsize ws;
+    struct winsize ws;
 
-	ws.ws_col = cols;
-	ws.ws_row = rows;
-	ws.ws_xpixel = cols * 5;
-	ws.ws_ypixel = rows * 10;
-	retval = ioctl(tty_fd, TIOCSWINSZ, &ws);
-	ch_log(NULL, "ioctl(TIOCSWINSZ) %s",
-					  retval == 0 ? "success" : "failed");
+    ws.ws_col = cols;
+    ws.ws_row = rows;
+    ws.ws_xpixel = cols * 5;
+    ws.ws_ypixel = rows * 10;
+    retval = ioctl(tty_fd, TIOCSWINSZ, &ws);
+    ch_log(NULL, "ioctl(TIOCSWINSZ) %s",
+	    retval == 0 ? "success" : "failed");
 # elif defined(TIOCSSIZE)
-	struct ttysize ts;
+    struct ttysize ts;
 
-	ts.ts_cols = cols;
-	ts.ts_lines = rows;
-	retval = ioctl(tty_fd, TIOCSSIZE, &ts);
-	ch_log(NULL, "ioctl(TIOCSSIZE) %s",
-					  retval == 0 ? "success" : "failed");
+    ts.ts_cols = cols;
+    ts.ts_lines = rows;
+    retval = ioctl(tty_fd, TIOCSSIZE, &ts);
+    ch_log(NULL, "ioctl(TIOCSSIZE) %s",
+	    retval == 0 ? "success" : "failed");
 # endif
-	if (tty_fd != fd)
-	    close(tty_fd);
-    }
+    if (tty_fd != fd)
+	close(tty_fd);
     return retval == 0 ? OK : FAIL;
 }
 #endif
@@ -4362,28 +4361,28 @@
 	*name2 = NULL;
 
     *pty_master_fd = mch_openpty(&tty_name);	    // open pty
-    if (*pty_master_fd >= 0)
-    {
-	// Leaving out O_NOCTTY may lead to waitpid() always returning
-	// 0 on Mac OS X 10.7 thereby causing freezes. Let's assume
-	// adding O_NOCTTY always works when defined.
+    if (*pty_master_fd < 0)
+	return;
+
+    // Leaving out O_NOCTTY may lead to waitpid() always returning
+    // 0 on Mac OS X 10.7 thereby causing freezes. Let's assume
+    // adding O_NOCTTY always works when defined.
 #ifdef O_NOCTTY
-	*pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA, 0);
+    *pty_slave_fd = open(tty_name, O_RDWR | O_NOCTTY | O_EXTRA, 0);
 #else
-	*pty_slave_fd = open(tty_name, O_RDWR | O_EXTRA, 0);
+    *pty_slave_fd = open(tty_name, O_RDWR | O_EXTRA, 0);
 #endif
-	if (*pty_slave_fd < 0)
-	{
-	    close(*pty_master_fd);
-	    *pty_master_fd = -1;
-	}
-	else
-	{
-	    if (name1 != NULL)
-		*name1 = vim_strsave((char_u *)tty_name);
-	    if (name2 != NULL)
-		*name2 = vim_strsave((char_u *)tty_name);
-	}
+    if (*pty_slave_fd < 0)
+    {
+	close(*pty_master_fd);
+	*pty_master_fd = -1;
+    }
+    else
+    {
+	if (name1 != NULL)
+	    *name1 = vim_strsave((char_u *)tty_name);
+	if (name2 != NULL)
+	    *name2 = vim_strsave((char_u *)tty_name);
     }
 }
 #endif
@@ -7250,29 +7249,28 @@
 	return 0;
 #endif
 
-    if (!gpm_flag)
+    if (gpm_flag)
+	return 1; // already open
+
+    gpm_connect.eventMask = (GPM_UP | GPM_DRAG | GPM_DOWN);
+    gpm_connect.defaultMask = ~GPM_HARD;
+    // Default handling for mouse move
+    gpm_connect.minMod = 0; // Handle any modifier keys
+    gpm_connect.maxMod = 0xffff;
+    if (Gpm_Open(&gpm_connect, 0) > 0)
     {
-	gpm_connect.eventMask = (GPM_UP | GPM_DRAG | GPM_DOWN);
-	gpm_connect.defaultMask = ~GPM_HARD;
-	// Default handling for mouse move
-	gpm_connect.minMod = 0; // Handle any modifier keys
-	gpm_connect.maxMod = 0xffff;
-	if (Gpm_Open(&gpm_connect, 0) > 0)
-	{
-	    // gpm library tries to handling TSTP causes
-	    // problems. Anyways, we close connection to Gpm whenever
-	    // we are going to suspend or starting an external process
-	    // so we shouldn't  have problem with this
+	// gpm library tries to handling TSTP causes
+	// problems. Anyways, we close connection to Gpm whenever
+	// we are going to suspend or starting an external process
+	// so we shouldn't  have problem with this
 # ifdef SIGTSTP
-	    signal(SIGTSTP, restricted ? SIG_IGN : (void (*)())sig_tstp);
+	signal(SIGTSTP, restricted ? SIG_IGN : (void (*)())sig_tstp);
 # endif
-	    return 1; // succeed
-	}
-	if (gpm_fd == -2)
-	    Gpm_Close(); // We don't want to talk to xterm via gpm
-	return 0;
+	return 1; // succeed
     }
-    return 1; // already open
+    if (gpm_fd == -2)
+	Gpm_Close(); // We don't want to talk to xterm via gpm
+    return 0;
 }
 
 /*
@@ -7395,14 +7393,13 @@
     mouse.operation = MOUSE_MODE;
     mouse.u.mode.mode = 0;
     mouse.u.mode.signal = SIGUSR2;
-    if (ioctl(1, CONS_MOUSECTL, &mouse) != -1)
-    {
-	signal(SIGUSR2, (void (*)())sig_sysmouse);
-	mouse.operation = MOUSE_SHOW;
-	ioctl(1, CONS_MOUSECTL, &mouse);
-	return OK;
-    }
-    return FAIL;
+    if (ioctl(1, CONS_MOUSECTL, &mouse) == -1)
+	return FAIL;
+
+    signal(SIGUSR2, (void (*)())sig_sysmouse);
+    mouse.operation = MOUSE_SHOW;
+    ioctl(1, CONS_MOUSECTL, &mouse);
+    return OK;
 }
 
 /*
@@ -8243,14 +8240,14 @@
     void
 xsmp_close(void)
 {
-    if (xsmp_icefd != -1)
-    {
-	SmcCloseConnection(xsmp.smcconn, 0, NULL);
-	if (xsmp.clientid != NULL)
-	    free(xsmp.clientid);
-	xsmp.clientid = NULL;
-	xsmp_icefd = -1;
-    }
+    if (xsmp_icefd == -1)
+	return;
+
+    SmcCloseConnection(xsmp.smcconn, 0, NULL);
+    if (xsmp.clientid != NULL)
+	free(xsmp.clientid);
+    xsmp.clientid = NULL;
+    xsmp_icefd = -1;
 }
 #endif // USE_XSMP
 
@@ -8348,11 +8345,11 @@
     void
 delete_timer(void)
 {
-    if (timer_created)
-    {
-	timer_delete(timer_id);
-	timer_created = FALSE;
-    }
+    if (!timer_created)
+	return;
+
+    timer_delete(timer_id);
+    timer_created = FALSE;
 }
 
 # else // HAVE_TIMER_CREATE