]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: eliminate signed/unsigned comparisons
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 2 Feb 2011 18:24:17 +0000 (10:24 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 3 Feb 2011 12:10:31 +0000 (04:10 -0800)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/crush/crush.c
src/crush/mapper.c

index fabd302e5779c0188b55916be81d7913dce84105..388d18b5af0621c6fa05a32ee0e6387f9e607562 100644 (file)
@@ -28,7 +28,7 @@ const char *crush_bucket_alg_name(int alg)
  */
 int crush_get_bucket_item_weight(struct crush_bucket *b, int p)
 {
-       if (p >= b->size)
+       if ((__u32)p >= b->size)
                return 0;
 
        switch (b->alg) {
@@ -52,7 +52,8 @@ int crush_get_bucket_item_weight(struct crush_bucket *b, int p)
  */
 void crush_calc_parents(struct crush_map *map)
 {
-       int i, b, c;
+       int b, c;
+       __u32 i;
 
        for (b = 0; b < map->max_buckets; b++) {
                if (map->buckets[b] == NULL)
@@ -124,10 +125,9 @@ void crush_destroy_bucket(struct crush_bucket *b)
  */
 void crush_destroy(struct crush_map *map)
 {
-       int b;
-
        /* buckets */
        if (map->buckets) {
+               __s32 b;
                for (b = 0; b < map->max_buckets; b++) {
                        if (map->buckets[b] == NULL)
                                continue;
@@ -138,6 +138,7 @@ void crush_destroy(struct crush_map *map)
 
        /* rules */
        if (map->rules) {
+               __u32 b;
                for (b = 0; b < map->max_rules; b++)
                        kfree(map->rules[b]);
                kfree(map->rules);
index d903426a1f2f69ad5d4d4c6f7ed77cd01b7577b5..13712c87f33eb46beb55b0334558c84dec5064f9 100644 (file)
@@ -34,7 +34,7 @@
  */
 int crush_find_rule(struct crush_map *map, int ruleset, int type, int size)
 {
-       int i;
+       __u32 i;
 
        for (i = 0; i < map->max_rules; i++) {
                if (map->rules[i] &&
@@ -72,7 +72,7 @@ static int bucket_perm_choose(struct crush_bucket *bucket,
        unsigned i, s;
 
        /* start a new permutation if @x has changed */
-       if (bucket->perm_x != x || bucket->perm_n == 0) {
+       if (bucket->perm_x != (__u32)x || bucket->perm_n == 0) {
                dprintk("bucket %d new x=%d\n", bucket->id, x);
                bucket->perm_x = x;
 
@@ -219,7 +219,7 @@ static int bucket_tree_choose(struct crush_bucket_tree *bucket,
 static int bucket_straw_choose(struct crush_bucket_straw *bucket,
                               int x, int r)
 {
-       int i;
+       __u32 i;
        int high = 0;
        __u64 high_draw = 0;
        __u64 draw;
@@ -296,7 +296,7 @@ static int crush_choose(struct crush_map *map,
                        int *out2)
 {
        int rep;
-       int ftotal, flocal;
+       unsigned int ftotal, flocal;
        int retry_descent, retry_bucket, skip_rep;
        struct crush_bucket *in = bucket;
        int r;
@@ -304,7 +304,7 @@ static int crush_choose(struct crush_map *map,
        int item = 0;
        int itemtype;
        int collide, reject;
-       const int orig_tries = 5; /* attempts before we fall back to search */
+       const unsigned int orig_tries = 5; /* attempts before we fall back to search */
 
        dprintk("CHOOSE%s bucket %d x %d outpos %d numrep %d\n", recurse_to_leaf ? "_LEAF" : "",
                bucket->id, x, outpos, numrep);
@@ -325,7 +325,7 @@ static int crush_choose(struct crush_map *map,
                                r = rep;
                                if (in->alg == CRUSH_BUCKET_UNIFORM) {
                                        /* be careful */
-                                       if (firstn || numrep >= in->size)
+                                       if (firstn || (__u32)numrep >= in->size)
                                                /* r' = r + f_total */
                                                r += ftotal;
                                        else if (in->size % numrep == 0)
@@ -425,7 +425,7 @@ reject:
                                                /* else give up */
                                                skip_rep = 1;
                                        dprintk("  reject %d  collide %d  "
-                                               "ftotal %d  flocal %d\n",
+                                               "ftotal %u  flocal %u\n",
                                                reject, collide, ftotal,
                                                flocal);
                                }
@@ -473,13 +473,13 @@ int crush_do_rule(struct crush_map *map,
        int osize;
        int *tmp;
        struct crush_rule *rule;
-       int step;
+       __u32 step;
        int i, j;
        int numrep;
        int firstn;
        int rc = -1;
 
-       BUG_ON(ruleno >= map->max_rules);
+       BUG_ON((__u32)ruleno >= map->max_rules);
 
        rule = map->rules[ruleno];
        result_len = 0;