]> git.proxmox.com Git - mirror_lxc.git/commitdiff
terminal: fix integer comparisons
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 3 Sep 2021 09:41:25 +0000 (11:41 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 3 Sep 2021 11:01:42 +0000 (13:01 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/terminal.c

index 543e947bbb2ca6707b43e9aa9961ab8b132ed6e8..a1f974be0c3144fc70a0a6a4b7db11fcab685f42 100644 (file)
@@ -270,7 +270,7 @@ static int lxc_terminal_write_log_file(struct lxc_terminal *terminal, char *buf,
                if (ret < 0)
                        return ret;
 
-               if (bytes_read <= terminal->log_size)
+               if ((uint64_t)bytes_read <= terminal->log_size)
                        return lxc_write_nointr(terminal->log_fd, buf, bytes_read);
 
                /* Write as much as we can into the buffer and loose the rest. */
@@ -301,7 +301,7 @@ static int lxc_terminal_write_log_file(struct lxc_terminal *terminal, char *buf,
        if (ret < 0)
                return ret;
 
-       if (terminal->log_size < bytes_read) {
+       if (terminal->log_size < (uint64_t)bytes_read) {
                /* Well, this is unfortunate because it means that there is more
                 * to write than the user has granted us space. There are
                 * multiple ways to handle this but let's use the simplest one:
@@ -615,7 +615,7 @@ on_error:
 
 int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
 {
-       int ttynum;
+       size_t ttynum;
        int ptxfd = -1;
        struct lxc_tty_info *ttys = &conf->ttys;
        struct lxc_terminal *terminal = &conf->console;
@@ -632,7 +632,7 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
        }
 
        if (*ttyreq > 0) {
-               if (*ttyreq > ttys->max)
+               if ((size_t)*ttyreq > ttys->max)
                        goto out;
 
                if (ttys->tty[*ttyreq - 1].busy >= 0)
@@ -652,7 +652,7 @@ int lxc_terminal_allocate(struct lxc_conf *conf, int sockfd, int *ttyreq)
        if (ttynum > ttys->max)
                goto out;
 
-       *ttyreq = ttynum;
+       *ttyreq = (int)ttynum;
 
 out_tty:
        ttys->tty[ttynum - 1].busy = sockfd;
@@ -664,11 +664,10 @@ out:
 
 void lxc_terminal_free(struct lxc_conf *conf, int fd)
 {
-       int i;
        struct lxc_tty_info *ttys = &conf->ttys;
        struct lxc_terminal *terminal = &conf->console;
 
-       for (i = 0; i < ttys->max; i++)
+       for (size_t i = 0; i < ttys->max; i++)
                if (ttys->tty[i].busy == fd)
                        ttys->tty[i].busy = -1;