]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: fix integer comparisons
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 3 Sep 2021 07:35:34 +0000 (09:35 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 14 Oct 2021 15:25:18 +0000 (17:25 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c

index fcd0e36cdd081812b081577011c58ee026b74a07..7b720fcb3a446228e0e7a34776597de76892e1a9 100644 (file)
@@ -21,7 +21,7 @@
 #include <sys/types.h>
 #include <sys/utsname.h>
 #include <syslog.h>
-#include <time.h>
+#include <sys/time.h>
 #include <unistd.h>
 
 #include "af_unix.h"
 #include "strlcat.h"
 #endif
 
+#if HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#endif
+
 lxc_log_define(confile, lxc);
 
 #define lxc_config_define(name)                                             \
@@ -2396,7 +2400,7 @@ static int set_config_console_buffer_size(const char *key, const char *value,
        if (buffer_size == 0)
                return ret_errno(EINVAL);
 
-       if (buffer_size != size)
+       if (buffer_size != (uint64_t)size)
                NOTICE("Passed size was not a power of 2. Rounding log size to next power of two: %" PRIu64 " bytes", buffer_size);
 
        lxc_conf->console.buffer_size = buffer_size;
@@ -2441,7 +2445,7 @@ static int set_config_console_size(const char *key, const char *value,
        if (log_size == 0)
                return ret_errno(EINVAL);
 
-       if (log_size != size)
+       if (log_size != (uint64_t)size)
                NOTICE("Passed size was not a power of 2. Rounding log size to next power of two: %" PRIu64 " bytes", log_size);
 
        lxc_conf->console.log_size = log_size;
@@ -2994,7 +2998,7 @@ int lxc_config_parse_arch(const char *arch, signed long *persona)
                { "x86_64",    PER_LINUX   },
        };
 
-       for (int i = 0; i < ARRAY_SIZE(pername); i++) {
+       for (size_t i = 0; i < ARRAY_SIZE(pername); i++) {
                if (!strequal(pername[i].name, arch))
                        continue;
 
@@ -4224,7 +4228,7 @@ static int get_config_init_groups(const char *key, char *retv, int inlen,
        if (c->init_groups.size == 0)
                return 0;
 
-       for (int i = 0; i < c->init_groups.size; i++)
+       for (size_t i = 0; i < c->init_groups.size; i++)
                strprint(retv, inlen, "%s%d", (i > 0) ? "," : "",
                         c->init_groups.list[i]);