From: Sebastien Buisson Date: Fri, 29 Mar 2013 15:21:15 +0000 (+0100) Subject: LU-3069 build: fix 'integer handling' issues X-Git-Tag: 2.4.90~1 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=233576b564b713ad765d908629b5b290acdabc1e LU-3069 build: fix 'integer handling' issues 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 Signed-off-by: Dmitry Eremin Change-Id: I687a05aaffad13caaebe16edbc4f93ef7ca3413f Reviewed-on: http://review.whamcloud.com/5888 Tested-by: Hudson Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index b98c76f..2f7fb32 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -1401,11 +1401,17 @@ existing_lock: 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; } diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index b6eb577..7e1e29d 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -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); - LASSERTF(reserved >= 0, "reserved %lu\n", reserved); if (reserved != 0) ll_ra_count_put(ll_i2sbi(inode), reserved); diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c index 5a4985c..093f60d 100644 --- a/lustre/llite/xattr.c +++ b/lustre/llite/xattr.c @@ -169,11 +169,12 @@ int ll_setxattr_common(struct inode *inode, const char *name, } 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 diff --git a/lustre/lod/lod_dev.c b/lustre/lod/lod_dev.c index 69e2ae2..2315222 100644 --- a/lustre/lod/lod_dev.c +++ b/lustre/lod/lod_dev.c @@ -176,7 +176,7 @@ static int lod_cleanup_desc_tgts(const struct lu_env *env, return rc; } -static int lodname2mdt_index(char *lodname, int *index) +static int lodname2mdt_index(char *lodname, long *index) { char *ptr, *tmp; @@ -360,10 +360,13 @@ static int lod_process_config(const struct lu_env *env, if (mdt == NULL) { mdt_index = 0; } else { + long long_index; rc = lodname2mdt_index( - lustre_cfg_string(lcfg, 0), &mdt_index); + lustre_cfg_string(lcfg, 0), + &long_index); 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); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index c9dee86..f5ca000 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -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; - int node_id; + long node_id; mntopt_t mntopts; ENTRY; diff --git a/lustre/obdclass/llog_ioctl.c b/lustre/obdclass/llog_ioctl.c index 44dae4a..9de449f 100644 --- a/lustre/obdclass/llog_ioctl.c +++ b/lustre/obdclass/llog_ioctl.c @@ -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; - static int l, remains, from, to; + static int l, remains; + static long from, to; 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; - static int l, remains, from, to; + static int l, remains; + static long from, to; static char *out; char *endp; int cur_index; diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index 52ad482..2c391d6 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -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; - int rc, idx; + int rc; + long idx; 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 && - 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); diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index cd9e094..05e9929 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -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 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; @@ -3793,7 +3794,8 @@ int root_ioctl(const char *mdtname, int opc, void *data, int *mdtidxp, { 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. */ @@ -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 id; + long id; if (endrec < 0) { llapi_err_noerrno(LLAPI_MSG_ERROR,