Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1697292

[PATCH 11/20] staging: lustre: lustre: fix all less than 0 comparison for unsigned values

From James Simmons <jsimmons@infradead.org>
Newsgroups linux.kernel
Subject [PATCH 11/20] staging: lustre: lustre: fix all less than 0 comparison for unsigned values
Date 2017-07-26 17:30 +0200
Message-ID <u7wq6-23J-35@gated-at.bofh.it> (permalink)
References <u7wq5-23J-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 drivers/staging/lustre/lustre/include/cl_object.h | 2 +-
 drivers/staging/lustre/lustre/llite/rw.c          | 2 +-
 drivers/staging/lustre/lustre/lov/lov_object.c    | 8 ++++----
 drivers/staging/lustre/lustre/mdc/lproc_mdc.c     | 2 +-
 drivers/staging/lustre/lustre/osc/osc_cache.c     | 7 ++++---
 5 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h
index 90a0c50..6887b81 100644
--- a/drivers/staging/lustre/lustre/include/cl_object.h
+++ b/drivers/staging/lustre/lustre/include/cl_object.h
@@ -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 */
diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c
index 1bac51f..166455e 100644
--- a/drivers/staging/lustre/lustre/llite/rw.c
+++ b/drivers/staging/lustre/lustre/llite/rw.c
@@ -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);
 }
 
diff --git a/drivers/staging/lustre/lustre/lov/lov_object.c b/drivers/staging/lustre/lustre/lov/lov_object.c
index 14f3826..4913229 100644
--- a/drivers/staging/lustre/lustre/lov/lov_object.c
+++ b/drivers/staging/lustre/lustre/lov/lov_object.c
@@ -638,7 +638,7 @@ static int lov_attr_get_raid0(const struct lu_env *env, struct cl_object *obj,
 	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 @@ static inline void lov_conf_thaw(struct lov_object *lov)
 									\
 	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))),
diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
index 9021c46..e40644b 100644
--- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
+++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
@@ -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 */
diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c
index 0100d27..e1207c2 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -783,6 +783,7 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env,
 			/* 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 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env,
 			/* 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 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env,
 		/* 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 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env,
 
 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);
 
-- 
1.8.3.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/20] staging: lustre: batch of fixes to decrease test failures James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 17/20] staging: lustre: llite: allow cached acls James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 04/20] staging: lustre: lov: fix 'control flow' error in lov_io_init_released James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 13/20] staging: lustre: ptlrpc: restore 64-bit time for struct ptlrpc_cli_req James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 06/20] staging: lustre: lmv: assume a real connection in lmv_connect() James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 07/20] staging: lustre: lov: Ensure correct operation for large object sizes James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 11/20] staging: lustre: lustre: fix all less than 0 comparison for unsigned values James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 03/20] staging: lustre: ldlm: crash on umount in cleanup_resource James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 10/20] staging: lustre: ldlm: restore interval_iterate_reverse function James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 14/20] staging: lustre: ptlrpc: don't use CFS_DURATION_T for time64_t James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 08/20] staging: lustre: ptlrpc: correct use of list_add_tail() James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 01/20] staging: lustre: osc: soft lock - osc_makes_rpc() James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 19/20] staging: lustre: llite: add xattr.h header to xattr.c James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 16/20] staging: lustre: libcfs: fix test for libcfs_ioctl_hdr minimum size James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 05/20] staging: lustre: lov: remove unused code James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 20/20] staging: lustre: llite: set security xattr using __vfs_setxattr James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 12/20] staging: lustre: linkea: linkEA size limitation James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 02/20] staging: lustre: ldlm: restore missing newlines in ldlm sysfs files James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200
  [PATCH 09/20] staging: lustre: ptlrpc: no need to reassign mbits for replay James Simmons <jsimmons@infradead.org> - 2017-07-26 17:30 +0200

csiph-web