Whamcloud - gitweb
LU-3097 build: fix 'no effect' errors 66/7166/5
authorSebastien Buisson <sebastien.buisson@bull.net>
Mon, 29 Jul 2013 15:23:48 +0000 (17:23 +0200)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 3 Sep 2013 05:20:31 +0000 (05:20 +0000)
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 <sebastien.buisson@bull.net>
Change-Id: Ic832e990c428ba674dcb8ba0f04c2bbf78fa8ee9
Reviewed-on: http://review.whamcloud.com/7166
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/xattr.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c
lustre/mdd/mdd_dir.c
lustre/mdd/mdd_object.c
lustre/mdt/mdt_lproc.c
lustre/ptlrpc/sec_bulk.c
lustre/tests/fsx.c
lustre/utils/liblustreapi.c

index 67ab229..c6b9cfb 100644 (file)
@@ -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;
 
index 88452be..61fe8bd 100644 (file)
@@ -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)
index 4df99ef..20b14e5 100644 (file)
@@ -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];
index 71d7443..8048d11 100644 (file)
@@ -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);
index 5d688cc..ea03362 100644 (file)
@@ -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);
 
index fd2b92d..90d0c85 100644 (file)
@@ -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;
index a3314d9..77fdaee 100644 (file)
@@ -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));
index 49f476d..b467333 100644 (file)
@@ -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 */
index d464faa..13fe862 100644 (file)
@@ -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;