From 862cdaa5db90edaeee64e21b2b7b0dba3986a3da Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Mon, 29 Jul 2013 17:23:48 +0200 Subject: [PATCH] LU-3097 build: fix 'no effect' errors Fix 'no effect' issues found by Coverity version 6.5.1: Unsigned compared against 0 (NO_EFFECT) This greater-than-or-equal-to-zero comparison of an unsigned value is always true. Signed-off-by: Sebastien Buisson Change-Id: Ic832e990c428ba674dcb8ba0f04c2bbf78fa8ee9 Reviewed-on: http://review.whamcloud.com/7166 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/llite/xattr.c | 19 +++++++++---------- lustre/lmv/lmv_obd.c | 6 +++--- lustre/lov/lov_obd.c | 12 ++++++------ lustre/mdd/mdd_dir.c | 16 ++++++++-------- lustre/mdd/mdd_object.c | 1 - lustre/mdt/mdt_lproc.c | 2 +- lustre/ptlrpc/sec_bulk.c | 1 - lustre/tests/fsx.c | 8 ++++---- lustre/utils/liblustreapi.c | 14 +++++--------- 9 files changed, 36 insertions(+), 43 deletions(-) diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c index 67ab229..c6b9cfb 100644 --- a/lustre/llite/xattr.c +++ b/lustre/llite/xattr.c @@ -402,21 +402,20 @@ do_getxattr: } #ifdef CONFIG_FS_POSIX_ACL - if (rce && rce->rce_ops == RMT_LSETFACL) { + if (rce != NULL && rce->rce_ops == RMT_LSETFACL) { ext_acl_xattr_header *acl; - acl = lustre_posix_acl_xattr_2ext((posix_acl_xattr_header *)buffer, - rc); - if (IS_ERR(acl)) - GOTO(out, rc = PTR_ERR(acl)); + acl = lustre_posix_acl_xattr_2ext(buffer, rc); + if (IS_ERR(acl)) + GOTO(out, rc = PTR_ERR(acl)); rc = ee_add(&sbi->ll_et, current_pid(), ll_inode2fid(inode), xattr_type, acl); - if (unlikely(rc < 0)) { - lustre_ext_acl_xattr_free(acl); - GOTO(out, rc); - } - } + if (unlikely(rc < 0)) { + lustre_ext_acl_xattr_free(acl); + GOTO(out, rc); + } + } #endif EXIT; diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 88452be..61fe8bd 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -990,9 +990,9 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, struct lmv_tgt_desc *tgt = NULL; struct obd_quotactl *oqctl; - if (qctl->qc_valid == QC_MDTIDX) { - if (qctl->qc_idx < 0 || count <= qctl->qc_idx) - RETURN(-EINVAL); + if (qctl->qc_valid == QC_MDTIDX) { + if (count <= qctl->qc_idx) + RETURN(-EINVAL); tgt = lmv->tgts[qctl->qc_idx]; if (tgt == NULL || tgt->ltd_exp == NULL) diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 4df99ef..20b14e5 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -2035,13 +2035,13 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct lov_tgt_desc *tgt = NULL; struct obd_quotactl *oqctl; - if (qctl->qc_valid == QC_OSTIDX) { - if (qctl->qc_idx < 0 || count <= qctl->qc_idx) - RETURN(-EINVAL); + if (qctl->qc_valid == QC_OSTIDX) { + if (count <= qctl->qc_idx) + RETURN(-EINVAL); - tgt = lov->lov_tgts[qctl->qc_idx]; - if (!tgt || !tgt->ltd_exp) - RETURN(-EINVAL); + tgt = lov->lov_tgts[qctl->qc_idx]; + if (!tgt || !tgt->ltd_exp) + RETURN(-EINVAL); } else if (qctl->qc_valid == QC_UUID) { for (i = 0; i < count; i++) { tgt = lov->lov_tgts[i]; diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 71d7443..8048d11 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -2466,16 +2466,16 @@ static int mdd_declare_rename(const struct lu_env *env, la->la_valid = LA_CTIME; rc = mdo_declare_attr_set(env, mdd_tobj, la, handle); - if (rc) - return rc; + if (rc) + return rc; - mdd_declare_links_del(env, mdd_tobj, handle); - if (rc) - return rc; + rc = mdd_declare_links_del(env, mdd_tobj, handle); + if (rc) + return rc; - rc = mdd_declare_finish_unlink(env, mdd_tobj, ma, handle); - if (rc) - return rc; + rc = mdd_declare_finish_unlink(env, mdd_tobj, ma, handle); + if (rc) + return rc; } rc = mdd_declare_changelog_ext_store(env, mdd, tname, sname, handle); diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 5d688cc..ea03362 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -1390,7 +1390,6 @@ static int mdd_swap_layouts(const struct lu_env *env, struct md_object *obj1, fst_fl = LU_XATTR_CREATE; } - LASSERT(snd_buf->lb_buf != NULL); snd_lmm = snd_buf->lb_buf; snd_gen = le16_to_cpu(snd_lmm->lmm_layout_gen); diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index fd2b92d..90d0c85 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -914,7 +914,7 @@ static int lprocfs_wr_enable_remote_dir(struct file *file, const char *buffer, if (rc) return rc; - if (val < 0 || val > 1) + if (val > 1) return -ERANGE; mdt->mdt_enable_remote_dir = val; diff --git a/lustre/ptlrpc/sec_bulk.c b/lustre/ptlrpc/sec_bulk.c index a3314d9..77fdaee 100644 --- a/lustre/ptlrpc/sec_bulk.c +++ b/lustre/ptlrpc/sec_bulk.c @@ -450,7 +450,6 @@ out: static inline void enc_pools_wakeup(void) { LASSERT(spin_is_locked(&page_pools.epp_lock)); - LASSERT(page_pools.epp_waitqlen >= 0); if (unlikely(page_pools.epp_waitqlen)) { LASSERT(cfs_waitq_active(&page_pools.epp_waitq)); diff --git a/lustre/tests/fsx.c b/lustre/tests/fsx.c index 49f476d..b467333 100644 --- a/lustre/tests/fsx.c +++ b/lustre/tests/fsx.c @@ -122,15 +122,15 @@ off_t biggest = 0; char state[256]; unsigned long testcalls = 0; /* calls to function "test" */ -unsigned long simulatedopcount = 0; /* -b flag */ +long simulatedopcount = 0; /* -b flag */ int closeprob = 0; /* -c flag */ int debug = 0; /* -d flag */ -unsigned long debugstart = 0; /* -D flag */ -unsigned long maxfilelen = 256 * 1024; /* -l flag */ +long debugstart = 0; /* -D flag */ +long maxfilelen = 256 * 1024; /* -l flag */ int sizechecks = 1; /* -n flag disables them */ int maxoplen = 64 * 1024; /* -o flag */ int quiet = 0; /* -q flag */ -unsigned long progressinterval = 0; /* -p flag */ +long progressinterval = 0; /* -p flag */ int readbdy = 1; /* -r flag */ int style = 0; /* -s flag */ int truncbdy = 1; /* -t flag */ diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index d464faa..13fe862 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -241,7 +241,7 @@ int llapi_stripe_limit_check(unsigned long long stripe_size, int stripe_offset, "larger than expected (%u)", page_size, LOV_MIN_STRIPE_SIZE); } - if (stripe_size < 0 || (stripe_size & (LOV_MIN_STRIPE_SIZE - 1))) { + if ((stripe_size & (LOV_MIN_STRIPE_SIZE - 1))) { rc = -EINVAL; llapi_error(LLAPI_MSG_ERROR, rc, "error: bad stripe_size %lu, " "must be an even multiple of %d bytes", @@ -1418,8 +1418,6 @@ static int get_lmd_info(char *path, DIR *parent, DIR *dir, /* retrieve needed file info */ strncpy((char *)lmd, fname, lumlen); ret = ioctl(dirfd(parent), IOC_MDC_GETFILEINFO, (void *)lmd); - } else { - return ret; } if (ret) { @@ -2630,12 +2628,10 @@ static int check_mdt_match(struct find_param *param) return 0; /* FIXME: For striped dir, we should get stripe information and check */ - for (i = 0; i < param->num_mdts; i++) { - if (param->mdtindexes[i] == param->file_mdtindex) - if (param->exclude_mdt) - return 0; - return 1; - } + for (i = 0; i < param->num_mdts; i++) { + if (param->mdtindexes[i] == param->file_mdtindex) + return !param->exclude_mdt; + } if (param->exclude_mdt) return 1; -- 1.8.3.1