Whamcloud - gitweb
LU-8843 client: fix all less than 0 comparison for unsigned values 11/23811/8
authorJames Simmons <uja.ornl@yahoo.com>
Tue, 24 Jan 2017 13:42:04 +0000 (08:42 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 10 Feb 2017 03:54:15 +0000 (03:54 +0000)
Remove all test of less than zero for unsigned values
found with -Wtype-limits.

Change-Id: Ia0a5cc5fc280b3856397cc8a494014368a04bf75
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/23811
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
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>
lustre/include/cl_object.h
lustre/llite/rw.c
lustre/lov/lov_object.c
lustre/osc/osc_cache.c
lustre/ptlrpc/layout.c

index de0470f..7e84abb 100644 (file)
@@ -1353,7 +1353,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 49162a5..27cb478 100644 (file)
@@ -116,8 +116,8 @@ 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);
-        lprocfs_counter_incr(sbi->ll_ra_stats, which);
+       LASSERTF(which < _NR_RA_STAT, "which: %u\n", which);
+       lprocfs_counter_incr(sbi->ll_ra_stats, which);
 }
 
 void ll_ra_stats_inc(struct inode *inode, enum ra_stat which)
index 4512f99..d7deb38 100644 (file)
@@ -632,14 +632,14 @@ const static struct lov_layout_operations lov_dispatch[] = {
 /**
  * Performs a double-dispatch based on the layout type of an object.
  */
-#define LOV_2DISPATCH_NOLOCK(obj, op, ...)                              \
-({                                                                      \
-        struct lov_object                      *__obj = (obj);          \
-        enum lov_layout_type                    __llt;                  \
-                                                                        \
-        __llt = __obj->lo_type;                                         \
-        LASSERT(0 <= __llt && __llt < ARRAY_SIZE(lov_dispatch));        \
-        lov_dispatch[__llt].op(__VA_ARGS__);                            \
+#define LOV_2DISPATCH_NOLOCK(obj, op, ...)             \
+({                                                     \
+       struct lov_object *__obj = (obj);               \
+       enum lov_layout_type __llt;                     \
+                                                       \
+       __llt = __obj->lo_type;                         \
+       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)
@@ -750,13 +750,13 @@ static int lov_layout_change(const struct lu_env *unused,
        int rc;
        ENTRY;
 
-       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 4904eee..c417c10 100644 (file)
@@ -776,6 +776,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);
@@ -783,6 +784,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
@@ -811,8 +813,8 @@ restart:
                /* create a new extent */
                EASSERT(osc_extent_is_overlapped(obj, cur) == 0, cur);
                cur->oe_grants = chunksize + cli->cl_grant_extent_tax;
+               LASSERT(*grants >= cur->oe_grants);
                *grants -= cur->oe_grants;
-               LASSERT(*grants >= 0);
 
                cur->oe_state = OES_CACHE;
                found = osc_extent_hold(cur);
@@ -839,7 +841,6 @@ restart:
 
 out:
        osc_extent_put(env, cur);
-       LASSERT(*grants >= 0);
        return found;
 }
 
@@ -1205,8 +1206,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);
        EXIT;
index 882be72..c9b2502 100644 (file)
@@ -1928,7 +1928,7 @@ static __u32 __req_capsule_offset(const struct req_capsule *pill,
                                  const struct req_msg_field *field,
                                  enum req_location loc)
 {
-        int offset;
+       unsigned int offset;
 
         offset = field->rmf_offset[pill->rc_fmt->rf_idx][loc];
         LASSERTF(offset > 0, "%s:%s, off=%d, loc=%d\n",
@@ -1936,7 +1936,7 @@ static __u32 __req_capsule_offset(const struct req_capsule *pill,
                             field->rmf_name, offset, loc);
         offset --;
 
-        LASSERT(0 <= offset && offset < REQ_MAX_FIELD_NR);
+       LASSERT(offset < REQ_MAX_FIELD_NR);
         return offset;
 }