Whamcloud - gitweb
LU-3069 build: fix 'integer handling' issues 88/5888/15
authorSebastien Buisson <sebastien.buisson@bull.net>
Fri, 29 Mar 2013 15:21:15 +0000 (16:21 +0100)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 10 Aug 2013 04:35:28 +0000 (04:35 +0000)
Fix 'program hangs' defects found by Coverity version 6.5.1:
Improper use of negative value (NEGATIVE_RETURNS)
Variable is passed to a parameter that cannot be negative.
Macro compares unsigned to 0 (NO_EFFECT)
This comparison is always true.
Operands don't affect result (CONSTANT_EXPRESSION_RESULT)
Test is always false regardless of the values of its operands.
Wrong operator used (CONSTANT_EXPRESSION_RESULT)
Test is always true regardless of the values of its operand.

Signed-off-by: Sebastien Buisson <sebastien.buisson@bull.net>
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: I687a05aaffad13caaebe16edbc4f93ef7ca3413f
Reviewed-on: http://review.whamcloud.com/5888
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/ldlm/ldlm_lockd.c
lustre/llite/rw.c
lustre/llite/xattr.c
lustre/lod/lod_dev.c
lustre/mdt/mdt_handler.c
lustre/obdclass/llog_ioctl.c
lustre/osp/osp_dev.c
lustre/utils/liblustreapi.c

index b98c76f..2f7fb32 100644 (file)
@@ -1401,11 +1401,17 @@ existing_lock:
                                         req, lock);
                                buflen = req_capsule_get_size(&req->rq_pill,
                                                &RMF_DLM_LVB, RCL_SERVER);
                                         req, lock);
                                buflen = req_capsule_get_size(&req->rq_pill,
                                                &RMF_DLM_LVB, RCL_SERVER);
-                               buflen = ldlm_lvbo_fill(lock, buf, buflen);
-                               if (buflen >= 0)
-                                       req_capsule_shrink(&req->rq_pill,
-                                                          &RMF_DLM_LVB,
-                                                          buflen, RCL_SERVER);
+                               if (buflen >= 0) {
+                                       buflen = ldlm_lvbo_fill(lock, buf,
+                                                               buflen);
+                                       if (buflen >= 0)
+                                               req_capsule_shrink(
+                                                       &req->rq_pill,
+                                                       &RMF_DLM_LVB,
+                                                       buflen, RCL_SERVER);
+                                       else
+                                               rc = buflen;
+                               }
                                else
                                        rc = buflen;
                        }
                                else
                                        rc = buflen;
                        }
index b6eb577..7e1e29d 100644 (file)
@@ -815,7 +815,6 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io,
         ret = ll_read_ahead_pages(env, io, queue,
                                   ria, &reserved, mapping, &ra_end);
 
         ret = ll_read_ahead_pages(env, io, queue,
                                   ria, &reserved, mapping, &ra_end);
 
-        LASSERTF(reserved >= 0, "reserved %lu\n", reserved);
         if (reserved != 0)
                 ll_ra_count_put(ll_i2sbi(inode), reserved);
 
         if (reserved != 0)
                 ll_ra_count_put(ll_i2sbi(inode), reserved);
 
index 5a4985c..093f60d 100644 (file)
@@ -169,11 +169,12 @@ int ll_setxattr_common(struct inode *inode, const char *name,
                         }
                         ee_free(ee);
                 } else if (rce->rce_ops == RMT_RSETFACL) {
                         }
                         ee_free(ee);
                 } else if (rce->rce_ops == RMT_RSETFACL) {
-                        size = lustre_posix_acl_xattr_filter(
-                                                (posix_acl_xattr_header *)value,
-                                                size, &new_value);
-                        if (unlikely(size < 0))
-                                RETURN(size);
+                       int acl_size = lustre_posix_acl_xattr_filter(
+                                               (posix_acl_xattr_header *)value,
+                                               size, &new_value);
+                       if (unlikely(acl_size < 0))
+                               RETURN(acl_size);
+                       size = acl_size;
 
                         pv = (const char *)new_value;
                 } else
 
                         pv = (const char *)new_value;
                 } else
index 69e2ae2..2315222 100644 (file)
@@ -176,7 +176,7 @@ static int lod_cleanup_desc_tgts(const struct lu_env *env,
        return rc;
 }
 
        return rc;
 }
 
-static int lodname2mdt_index(char *lodname, int *index)
+static int lodname2mdt_index(char *lodname, long *index)
 {
        char *ptr, *tmp;
 
 {
        char *ptr, *tmp;
 
@@ -360,10 +360,13 @@ static int lod_process_config(const struct lu_env *env,
                        if (mdt == NULL) {
                                mdt_index = 0;
                        } else {
                        if (mdt == NULL) {
                                mdt_index = 0;
                        } else {
+                               long long_index;
                                rc = lodname2mdt_index(
                                rc = lodname2mdt_index(
-                                       lustre_cfg_string(lcfg, 0), &mdt_index);
+                                       lustre_cfg_string(lcfg, 0),
+                                       &long_index);
                                if (rc != 0)
                                        GOTO(out, rc);
                                if (rc != 0)
                                        GOTO(out, rc);
+                               mdt_index = long_index;
                        }
                        rc = lod_add_device(env, lod, arg1, index, gen,
                                            mdt_index, LUSTRE_OSC_NAME, 1);
                        }
                        rc = lod_add_device(env, lod, arg1, index, gen,
                                            mdt_index, LUSTRE_OSC_NAME, 1);
index c9dee86..f5ca000 100644 (file)
@@ -4843,7 +4843,7 @@ static int mdt_init0(const struct lu_env *env, struct mdt_device *m,
         const char                *identity_upcall = "NONE";
         struct md_device          *next;
         int                        rc;
         const char                *identity_upcall = "NONE";
         struct md_device          *next;
         int                        rc;
-        int                        node_id;
+       long                       node_id;
         mntopt_t                   mntopts;
         ENTRY;
 
         mntopt_t                   mntopts;
         ENTRY;
 
index 44dae4a..9de449f 100644 (file)
@@ -91,7 +91,8 @@ static int llog_check_cb(const struct lu_env *env, struct llog_handle *handle,
                         struct llog_rec_hdr *rec, void *data)
 {
         struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data;
                         struct llog_rec_hdr *rec, void *data)
 {
         struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data;
-        static int l, remains, from, to;
+       static int l, remains;
+       static long from, to;
         static char *out;
         char *endp;
         int cur_index, rc = 0;
         static char *out;
         char *endp;
         int cur_index, rc = 0;
@@ -177,7 +178,8 @@ static int llog_print_cb(const struct lu_env *env, struct llog_handle *handle,
                         struct llog_rec_hdr *rec, void *data)
 {
         struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data;
                         struct llog_rec_hdr *rec, void *data)
 {
         struct obd_ioctl_data *ioc_data = (struct obd_ioctl_data *)data;
-        static int l, remains, from, to;
+       static int l, remains;
+       static long from, to;
         static char *out;
         char *endp;
         int cur_index;
         static char *out;
         char *endp;
         int cur_index;
index 52ad482..2c391d6 100644 (file)
@@ -539,7 +539,8 @@ static int osp_init0(const struct lu_env *env, struct osp_device *m,
        struct obd_import       *imp;
        class_uuid_t            uuid;
        char                    *src, *tgt, *mdt, *osdname = NULL;
        struct obd_import       *imp;
        class_uuid_t            uuid;
        char                    *src, *tgt, *mdt, *osdname = NULL;
-       int                     rc, idx;
+       int                     rc;
+       long                    idx;
 
        ENTRY;
 
 
        ENTRY;
 
@@ -600,7 +601,7 @@ static int osp_init0(const struct lu_env *env, struct osp_device *m,
        } else {
                /* New OSC name fsname-OSTXXXX-osc-MDTXXXX */
                if (strncmp(tgt, "-MDT", 4) != 0 &&
        } else {
                /* New OSC name fsname-OSTXXXX-osc-MDTXXXX */
                if (strncmp(tgt, "-MDT", 4) != 0 &&
-                        strncmp(tgt, "-OST", 4) != 0) {
+                   strncmp(tgt, "-OST", 4) != 0) {
                        CERROR("%s: invalid target name %s\n",
                               m->opd_obd->obd_name, lustre_cfg_string(cfg, 0));
                        RETURN(-EINVAL);
                        CERROR("%s: invalid target name %s\n",
                               m->opd_obd->obd_name, lustre_cfg_string(cfg, 0));
                        RETURN(-EINVAL);
index cd9e094..05e9929 100644 (file)
@@ -1829,7 +1829,8 @@ static int setup_indexes(DIR *dir, char *path, struct obd_uuid *obduuids,
                          int num_obds, int **obdindexes, int *obdindex,
                          enum tgt_type type)
 {
                          int num_obds, int **obdindexes, int *obdindex,
                          enum tgt_type type)
 {
-        int ret, obdcount, obd_valid = 0, obdnum, i;
+       int ret, obdcount, obd_valid = 0, obdnum;
+       long i;
         struct obd_uuid *uuids = NULL;
         char buf[16];
         int *indexes;
         struct obd_uuid *uuids = NULL;
         char buf[16];
         int *indexes;
@@ -3793,7 +3794,8 @@ int root_ioctl(const char *mdtname, int opc, void *data, int *mdtidxp,
 {
         char fsname[20];
         char *ptr;
 {
         char fsname[20];
         char *ptr;
-        int fd, index, rc;
+       int fd, rc;
+       long index;
 
         /* Take path, fsname, or MDTname.  Assume MDT0000 in the former cases.
          Open root and parse mdt index. */
 
         /* Take path, fsname, or MDTname.  Assume MDT0000 in the former cases.
          Open root and parse mdt index. */
@@ -4013,7 +4015,7 @@ int llapi_changelog_free(struct changelog_ext_rec **rech)
 int llapi_changelog_clear(const char *mdtname, const char *idstr,
                           long long endrec)
 {
 int llapi_changelog_clear(const char *mdtname, const char *idstr,
                           long long endrec)
 {
-        int id;
+       long id;
 
         if (endrec < 0) {
                 llapi_err_noerrno(LLAPI_MSG_ERROR,
 
         if (endrec < 0) {
                 llapi_err_noerrno(LLAPI_MSG_ERROR,