]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Use size_t as an iteration point over int 961/head
authorstaticfox <staticfox@staticfox.net>
Mon, 11 Apr 2016 14:36:37 +0000 (10:36 -0400)
committerstaticfox <staticfox@staticfox.net>
Mon, 11 Apr 2016 15:06:22 +0000 (11:06 -0400)
This cleans up some sign-compare warnings as well as avoids any
possibilities of unintended signed offsets for indices during
iteration.

Signed-off-by: Matt Ullman <staticfox@staticfox.net>
src/lxc/arguments.c
src/lxc/bdev/bdev.c
src/lxc/bdev/lxcoverlay.c
src/lxc/conf.c
src/lxc/confile.c
src/lxc/network.c
src/lxc/nl.c
src/lxc/parse.c
src/lxc/utils.c

index e021143765e691bde0876d22bcf2c21f6389f25f..c2f7b67a6128f5c2ee3b98ce53ec1ca363547ab0 100644 (file)
@@ -40,7 +40,7 @@ static int build_shortopts(const struct option *a_options,
                           char *a_shortopts, size_t a_size)
 {
        const struct option *opt;
-       int i = 0;
+       size_t i = 0;
 
        if (!a_options || !a_shortopts || !a_size)
                return -1;
index 6b2911579f398e17acf345bf15e6f757ef2d24ca..1534cc9cfa5f3f35bddcacce7539ad8521c0542c 100644 (file)
@@ -823,7 +823,7 @@ static struct bdev *do_bdev_create(const char *dest, const char *type,
 
 static struct bdev *bdev_get(const char *type)
 {
-       int i;
+       size_t i;
        struct bdev *bdev;
 
        for (i = 0; i < numbdevs; i++) {
@@ -843,7 +843,7 @@ static struct bdev *bdev_get(const char *type)
 
 static const struct bdev_type *get_bdev_by_name(const char *name)
 {
-       int i;
+       size_t i;
 
        for (i = 0; i < numbdevs; i++) {
                if (strcmp(bdevs[i].name, name) == 0)
@@ -856,7 +856,7 @@ static const struct bdev_type *get_bdev_by_name(const char *name)
 
 static const struct bdev_type *bdev_query(struct lxc_conf *conf, const char *src)
 {
-       int i;
+       size_t i;
 
        if (conf->rootfs.bdev_type)
                return get_bdev_by_name(conf->rootfs.bdev_type);
index 86181d92f1a7a068667381ae27c2146fb0cac3fb..3caadbc4afe9753e78cb66036743431e136e3a89 100644 (file)
@@ -569,7 +569,7 @@ int ovl_update_abs_paths(struct lxc_conf *lxc_conf, const char *lxc_path,
        char old_upper[MAXPATHLEN];
        char old_work[MAXPATHLEN];
        char *cleanpath = NULL;
-       int i;
+       size_t i;
        int fret = -1;
        int ret = 0;
        struct lxc_list *iterator;
index 3b023efea3ccaa7c2ced292c60361ee2b2404837..e8dfaaee220ffcd14e36a9793a4186c4cea85736 100644 (file)
@@ -1989,7 +1989,8 @@ static int setup_mount_entries(const struct lxc_rootfs *rootfs, struct lxc_list
 static int parse_cap(const char *cap)
 {
        char *ptr = NULL;
-       int i, capid = -1;
+       size_t i;
+       int capid = -1;
 
        if (!strcmp(cap, "none"))
                return -2;
index 7f341646c4802996d88d48e6b1188159a3f0ce4f..8c366c83b24dd2ce46a0cc565f8d3c0f0fecafe6 100644 (file)
@@ -274,7 +274,7 @@ static const size_t config_size = sizeof(config)/sizeof(struct lxc_config_t);
 
 extern struct lxc_config_t *lxc_getconfig(const char *key)
 {
-       int i;
+       size_t i;
 
        for (i = 0; i < config_size; i++)
                if (!strncmp(config[i].name, key,
@@ -297,7 +297,8 @@ extern struct lxc_config_t *lxc_getconfig(const char *key)
 
 int lxc_listconfigs(char *retv, int inlen)
 {
-       int i, fulllen = 0, len;
+       size_t i;
+       int fulllen = 0, len;
 
        if (!retv)
                inlen = 0;
@@ -607,7 +608,7 @@ static int macvlan_mode(int *valuep, const char *value)
                { "passthru", MACVLAN_MODE_PASSTHRU },
        };
 
-       int i;
+       size_t i;
 
        for (i = 0; i < sizeof(m)/sizeof(m[0]); i++) {
                if (strcmp(m[i].name, value))
@@ -1350,7 +1351,7 @@ static int rt_sig_num(const char *signame)
 }
 
 static int sig_parse(const char *signame) {
-       int n;
+       size_t n;
 
        if (isdigit(*signame)) {
                return sig_num(signame);
@@ -2055,7 +2056,7 @@ signed long lxc_config_parse_arch(const char *arch)
        };
        size_t len = sizeof(pername) / sizeof(pername[0]);
 
-       int i;
+       size_t i;
 
        for (i = 0; i < len; i++) {
                if (!strcmp(pername[i].name, arch))
index 31c82bbbbe4ca2d7dfe958e85a40667c3ff95f71..86c3ee5995d7788504c7378311e5ad094b5731e5 100644 (file)
@@ -1507,7 +1507,7 @@ static const char padchar[] =
 char *lxc_mkifname(char *template)
 {
        char *name = NULL;
-       int i = 0;
+       size_t i = 0;
        FILE *urandom;
        unsigned int seed;
        struct ifaddrs *ifaddr, *ifa;
index 19a3a6c0615ac772dfbbae7d36d0584bb80f7727..f194efcf2bb920a7cd1c22995d3f8718e241657a 100644 (file)
@@ -54,7 +54,7 @@ static int nla_put(struct nlmsg *nlmsg, int attr,
        struct rtattr *rta;
        size_t rtalen = RTA_LENGTH(len);
        size_t tlen = NLMSG_ALIGN(nlmsg->nlmsghdr->nlmsg_len) + RTA_ALIGN(rtalen);
-       
+
        if (tlen > nlmsg->cap)
                return -ENOMEM;
 
index 5852ca403dc08882f63556b779f0458dbf7dc57f..b8eef7f04eaeb141a2f77e95a32299ff9d16aa4d 100644 (file)
@@ -66,7 +66,7 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback, void *data)
 
 int lxc_char_left_gc(const char *buffer, size_t len)
 {
-       int i;
+       size_t i;
        for (i = 0; i < len; i++) {
                if (buffer[i] == ' ' ||
                    buffer[i] == '\t')
index 61567e32aa1c0351bd3bdb28bc822064886f2afd..5c35ae8dd7033840bd730729adaa689f14a7d91b 100644 (file)
@@ -941,7 +941,7 @@ void **lxc_append_null_to_array(void **array, size_t count)
        if (count) {
                temp = realloc(array, (count + 1) * sizeof(*array));
                if (!temp) {
-                       int i;
+                       size_t i;
                        for (i = 0; i < count; i++)
                                free(array[i]);
                        free(array);