]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
terminal: lxc_terminal_allocate()
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 28 Feb 2018 11:12:59 +0000 (12:12 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 28 Feb 2018 16:08:07 +0000 (17:08 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/terminal.c

index 1aad822a5ac3e334814604cad0a6ca00d09fb631..a0d3144c53433e4931e20e9709d5dfbadc2fd8ba 100644 (file)
@@ -600,13 +600,18 @@ on_error:
 
 int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
 {
-       int masterfd = -1, ttynum;
+       int ttynum;
+       int masterfd = -1;
        struct lxc_tty_info *ttys = &conf->ttys;
        struct lxc_terminal *terminal = &conf->console;
 
        if (*ttyreq == 0) {
-               if (lxc_terminal_peer_proxy_alloc(terminal, sockfd) < 0)
+               int ret;
+
+               ret = lxc_terminal_peer_proxy_alloc(terminal, sockfd);
+               if (ret < 0)
                        goto out;
+
                masterfd = terminal->proxy.master;
                goto out;
        }
@@ -618,16 +623,17 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
                if (ttys->tty[*ttyreq - 1].busy)
                        goto out;
 
-               /* the requested tty is available */
+               /* The requested tty is available. */
                ttynum = *ttyreq;
                goto out_tty;
        }
 
-       /* search for next available tty, fixup index tty1 => [0] */
-       for (ttynum = 1; ttynum <= ttys->nbtty && ttys->tty[ttynum - 1].busy; ttynum++)
+       /* Search for next available tty, fixup index tty1 => [0]. */
+       for (ttynum = 1; ttynum <= ttys->nbtty && ttys->tty[ttynum - 1].busy; ttynum++) {
                ;
+       }
 
-       /* we didn't find any available slot for tty */
+       /* We didn't find any available slot for tty. */
        if (ttynum > ttys->nbtty)
                goto out;
 
@@ -636,6 +642,7 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
 out_tty:
        ttys->tty[ttynum - 1].busy = sockfd;
        masterfd = ttys->tty[ttynum - 1].master;
+
 out:
        return masterfd;
 }