]> 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>
Fri, 3 Sep 2021 11:00:58 +0000 (13:00 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c

index 9a2fcc3fcd4bcc16f780d4eca27f3d155e43e16c..6b1cfd4be605c5f734889ad3682f56a5a4f1f0d7 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)                                             \
@@ -2540,7 +2544,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;
@@ -2585,7 +2589,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;
@@ -3216,7 +3220,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;
 
@@ -4508,7 +4512,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]);