Whamcloud - gitweb
LU-3068 build: fix 'incorrect expression' errors
authorSebastien Buisson <sebastien.buisson@bull.net>
Fri, 29 Mar 2013 13:30:48 +0000 (14:30 +0100)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 31 Mar 2013 21:02:29 +0000 (17:02 -0400)
Fix 'program hangs' defects found by Coverity version 6.5.1:
Array compared against 0 (NO_EFFECT)
Comparing an array to null is not useful.
Copy-paste error (COPY_PASTE_ERROR)
This line looks like a copy-paste error.
Self assignment (NO_EFFECT)
Assignment operation has no effect.
Side effect in assertion (ASSERT_SIDE_EFFECT)
Assignment has a side effect. This code will work differently in a
non-debug build. You might have intended to use a comparison instead.
Wrong sizeof argument (SIZEOF_MISMATCH)
Passing argument is suspicious.

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Change-Id: Icf6ea9632da6159beca0fd9fd3ff9bb57effc305
Reviewed-on: http://review.whamcloud.com/5887
Tested-by: Hudson
Reviewed-by: John Hammond <johnlockwoodhammond@gmail.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/fld/fld_index.c
lustre/llite/llite_lib.c
lustre/lmv/lmv_obd.c
lustre/lod/lod_lov.c
lustre/lod/lod_object.c
lustre/mdd/mdd_lfsck.c
lustre/obdclass/genops.c
lustre/obdclass/lprocfs_status.c
lustre/ptlrpc/lproc_ptlrpc.c
lustre/ptlrpc/service.c
lustre/tests/openunlink.c

index cbe8300..a6f9be5 100644 (file)
@@ -331,7 +331,7 @@ int fld_index_init(const struct lu_env *env, struct lu_server_fld *fld,
        if (attr == NULL)
                RETURN(-ENOMEM);
 
-       memset(attr, 0, sizeof(attr));
+       memset(attr, 0, sizeof(*attr));
        attr->la_valid = LA_MODE;
        attr->la_mode = S_IFREG | 0666;
        dof.dof_type = DFT_INDEX;
index a96f878..43da149 100644 (file)
@@ -2074,15 +2074,15 @@ void ll_umount_begin(struct super_block *sb)
         obd->obd_force = 1;
 
         OBD_ALLOC_PTR(ioc_data);
-        if (ioc_data) {
-                obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp,
-                              sizeof ioc_data, ioc_data, NULL);
+       if (ioc_data) {
+               obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_md_exp,
+                             sizeof *ioc_data, ioc_data, NULL);
 
-                obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp,
-                              sizeof ioc_data, ioc_data, NULL);
+               obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp,
+                             sizeof *ioc_data, ioc_data, NULL);
 
-                OBD_FREE_PTR(ioc_data);
-        }
+               OBD_FREE_PTR(ioc_data);
+       }
 
 
         /* Really, we'd like to wait until there are no requests outstanding,
index d4284e6..e55f4a0 100644 (file)
@@ -2309,10 +2309,10 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
         meap->mea_count = cpu_to_le32(lsmp->mea_count);
         meap->mea_master = cpu_to_le32(lsmp->mea_master);
 
-        for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
-                meap->mea_ids[i] = meap->mea_ids[i];
-                fid_cpu_to_le(&meap->mea_ids[i], &meap->mea_ids[i]);
-        }
+       for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
+               meap->mea_ids[i] = lsmp->mea_ids[i];
+               fid_cpu_to_le(&meap->mea_ids[i], &lsmp->mea_ids[i]);
+       }
 
         RETURN(mea_size);
 }
index 37a5809..9a9eec1 100644 (file)
@@ -266,7 +266,7 @@ int lod_add_device(const struct lu_env *env, struct lod_device *lod,
        }
 
        LASSERT(obd->obd_lu_dev);
-       LASSERT(obd->obd_lu_dev->ld_site = lod->lod_dt_dev.dd_lu_dev.ld_site);
+       LASSERT(obd->obd_lu_dev->ld_site == lod->lod_dt_dev.dd_lu_dev.ld_site);
 
        ldev = obd->obd_lu_dev;
        d = lu2dt_dev(ldev);
index dbed5eb..070b2b6 100644 (file)
@@ -433,7 +433,7 @@ static int lod_declare_xattr_set(const struct lu_env *env,
                        if (rc)
                                RETURN(rc);
                } else {
-                       memset(attr, 0, sizeof(attr));
+                       memset(attr, 0, sizeof(*attr));
                        attr->la_valid = LA_TYPE | LA_MODE;
                        attr->la_mode = S_IFREG;
                }
index bca6ce1..f012418 100644 (file)
@@ -484,7 +484,7 @@ static int mdd_lfsck_bookmark_init(const struct lu_env *env,
        struct lfsck_bookmark *mb = &lfsck->ml_bookmark_ram;
        int rc;
 
-       memset(mb, 0, sizeof(mb));
+       memset(mb, 0, sizeof(*mb));
        mb->lb_magic = LFSCK_BOOKMARK_MAGIC;
        mb->lb_version = LFSCK_VERSION_V2;
        mutex_lock(&lfsck->ml_mutex);
index cd1443c..436aa4d 100644 (file)
@@ -315,8 +315,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name)
         for (i = 0; i < class_devno_max(); i++) {
                 struct obd_device *obd = class_num2obd(i);
 
-                if (obd && obd->obd_name &&
-                    (strcmp(name, obd->obd_name) == 0)) {
+               if (obd && (strcmp(name, obd->obd_name) == 0)) {
                         CERROR("Device %s already exists at %d, won't add\n",
                                name, i);
                         if (result) {
@@ -397,7 +396,7 @@ int class_name2dev(const char *name)
         for (i = 0; i < class_devno_max(); i++) {
                 struct obd_device *obd = class_num2obd(i);
 
-                if (obd && obd->obd_name && strcmp(name, obd->obd_name) == 0) {
+               if (obd && strcmp(name, obd->obd_name) == 0) {
                         /* Make sure we finished attaching before we give
                            out any references */
                         LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
index 173ad85..117eb50 100644 (file)
@@ -590,7 +590,6 @@ int lprocfs_rd_name(char *page, char **start, off_t off, int count,
         struct obd_device *dev = data;
 
         LASSERT(dev != NULL);
-        LASSERT(dev->obd_name != NULL);
         *eof = 1;
         return snprintf(page, count, "%s\n", dev->obd_name);
 }
index 03ed9b9..c68bcaf 100644 (file)
@@ -370,7 +370,6 @@ ptlrpc_lprocfs_rd_threads_started(char *page, char **start, off_t off,
        int     total = 0;
        int     i;
 
-       LASSERT(svc->srv_parts != NULL);
        ptlrpc_service_for_each_part(svcpt, i, svc)
                total += svcpt->scp_nthrs_running;
 
@@ -1024,8 +1023,6 @@ static int ptlrpc_lprocfs_rd_timeouts(char *page, char **start, off_t off,
        int                             rc = 0;
        int                             i;
 
-       LASSERT(svc->srv_parts != NULL);
-
        if (AT_OFF) {
                rc += snprintf(page + rc, count - rc,
                               "adaptive timeouts off, using obd_timeout %u\n",
index 6278f7b..5b2a77f 100644 (file)
@@ -3195,7 +3195,7 @@ ptlrpc_service_health_check(struct ptlrpc_service *svc)
        struct ptlrpc_service_part      *svcpt;
        int                             i;
 
-       if (svc == NULL || svc->srv_parts == NULL)
+       if (svc == NULL)
                return 0;
 
        ptlrpc_service_for_each_part(svcpt, i, svc) {
index 64a3eeb..c471e3b 100644 (file)
@@ -90,10 +90,10 @@ int main(int argc, char **argv)
         }
 
         fprintf(stderr, "accessing (1)\n");
-        if (access(fname, F_OK) == 0) {
-                fprintf(stderr, "%s still exists\n", fname2);
-                exit(1);
-        }
+       if (access(fname, F_OK) == 0) {
+               fprintf(stderr, "%s still exists\n", fname);
+               exit(1);
+       }
 
         fprintf(stderr, "seeking (1)\n");
         rc = lseek(fd, 0, SEEK_SET);