staging: lustre: lustre: fix all less than 0 comparison for unsigned values
authorJames Simmons <jsimmons@infradead.org>
Wed, 26 Jul 2017 15:22:27 +0000 (11:22 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 30 Jul 2017 15:08:31 +0000 (08:08 -0700)
Remove all test of less than zero for unsigned values
found with -Wtype-limits.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8843
Reviewed-on: https://review.whamcloud.com/23811
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/cl_object.h
drivers/staging/lustre/lustre/llite/rw.c
drivers/staging/lustre/lustre/lov/lov_object.c
drivers/staging/lustre/lustre/mdc/lproc_mdc.c
drivers/staging/lustre/lustre/osc/osc_cache.c

index 90a0c501e1ead97eabfb2cb7c767975b389fc2ab..6887b81fa9010a1805e895a344bb8c32a9a060cd 100644 (file)
@@ -1358,7 +1358,7 @@ struct cl_2queue {
 /** IO types */
 enum cl_io_type {
        /** read system call */
-       CIT_READ,
+       CIT_READ = 1,
        /** write system call */
        CIT_WRITE,
        /** truncate, utime system calls */
index 1bac51f882a7462fe1496b1c44f94798fc83461a..166455e05cc29f7efdb28c57fb9064ce1c70c16f 100644 (file)
@@ -115,7 +115,7 @@ void ll_ra_count_put(struct ll_sb_info *sbi, unsigned long len)
 
 static void ll_ra_stats_inc_sbi(struct ll_sb_info *sbi, enum ra_stat which)
 {
-       LASSERTF(which >= 0 && which < _NR_RA_STAT, "which: %u\n", which);
+       LASSERTF(which < _NR_RA_STAT, "which: %u\n", which);
        lprocfs_counter_incr(sbi->ll_ra_stats, which);
 }
 
index a33955aabbc54326fd3be6fb6addd451e49c9004..8fc0bcc11aa201d52a146ab7bb99fffc23e39db0 100644 (file)
@@ -638,7 +638,7 @@ static const struct lov_layout_operations lov_dispatch[] = {
        enum lov_layout_type                __llt;                \
                                                                        \
        __llt = __obj->lo_type;                                  \
-       LASSERT(0 <= __llt && __llt < ARRAY_SIZE(lov_dispatch));        \
+       LASSERT(__llt < ARRAY_SIZE(lov_dispatch));              \
        lov_dispatch[__llt].op(__VA_ARGS__);                        \
 })
 
@@ -697,7 +697,7 @@ do {                                                                    \
                                                                        \
        lov_conf_freeze(__obj);                                         \
        __llt = __obj->lo_type;                                  \
-       LASSERT(0 <= __llt && __llt < ARRAY_SIZE(lov_dispatch));        \
+       LASSERT(__llt < ARRAY_SIZE(lov_dispatch));      \
        lov_dispatch[__llt].op(__VA_ARGS__);                        \
        lov_conf_thaw(__obj);                                           \
 } while (0)
@@ -748,13 +748,13 @@ static int lov_layout_change(const struct lu_env *unused,
        u16 refcheck;
        int rc;
 
-       LASSERT(0 <= lov->lo_type && lov->lo_type < ARRAY_SIZE(lov_dispatch));
+       LASSERT(lov->lo_type < ARRAY_SIZE(lov_dispatch));
 
        env = cl_env_get(&refcheck);
        if (IS_ERR(env))
                return PTR_ERR(env);
 
-       LASSERT(0 <= llt && llt < ARRAY_SIZE(lov_dispatch));
+       LASSERT(llt < ARRAY_SIZE(lov_dispatch));
 
        CDEBUG(D_INODE, DFID " from %s to %s\n",
               PFID(lu_object_fid(lov2lu(lov))),
index 9fea535d6fc6280b5ae38085cb61878816814d3f..51a7047ff20912da3c6c0b25cb95daf50972bf78 100644 (file)
@@ -57,7 +57,7 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
        if (rc)
                return rc;
 
-       if (val < 0 || val > 1)
+       if (val > 1)
                return -ERANGE;
 
        /* opposite senses */
index 0100d27f9f66021c8f57f5842adbbd7561b0f1ec..e1207c227b7999fc1bb523683d8ee4644e257592 100644 (file)
@@ -783,6 +783,7 @@ restart:
                        /* pull ext's start back to cover cur */
                        ext->oe_start = cur->oe_start;
                        ext->oe_grants += chunksize;
+                       LASSERT(*grants >= chunksize);
                        *grants -= chunksize;
 
                        found = osc_extent_hold(ext);
@@ -790,6 +791,7 @@ restart:
                        /* rear merge */
                        ext->oe_end = cur->oe_end;
                        ext->oe_grants += chunksize;
+                       LASSERT(*grants >= chunksize);
                        *grants -= chunksize;
 
                        /* try to merge with the next one because we just fill
@@ -819,8 +821,8 @@ restart:
                /* create a new extent */
                EASSERT(osc_extent_is_overlapped(obj, cur) == 0, cur);
                cur->oe_grants = chunksize + cli->cl_extent_tax;
+               LASSERT(*grants >= cur->oe_grants);
                *grants -= cur->oe_grants;
-               LASSERT(*grants >= 0);
 
                cur->oe_state = OES_CACHE;
                found = osc_extent_hold(cur);
@@ -849,7 +851,6 @@ restart:
 
 out:
        osc_extent_put(env, cur);
-       LASSERT(*grants >= 0);
        return found;
 }
 
@@ -1219,8 +1220,8 @@ static int osc_extent_expand(struct osc_extent *ext, pgoff_t index,
 
        ext->oe_end = end_index;
        ext->oe_grants += chunksize;
+       LASSERT(*grants >= chunksize);
        *grants -= chunksize;
-       LASSERT(*grants >= 0);
        EASSERTF(osc_extent_is_overlapped(obj, ext) == 0, ext,
                 "overlapped after expanding for %lu.\n", index);