From 7e5966d3960623fc0ca94bf401eb928ca0cac80f Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Mon, 19 Aug 2013 14:00:24 +0400 Subject: [PATCH] LU-3775 build: build error with gcc 4.7.0 20110509 Fixed the error: 'tgt' and 'nf' may be used uninitialized in this function. Also fixed comparison signed and unsigned indexes. Signed-off-by: Dmitry Eremin Change-Id: I733e3f6456ce2926dfc6f3c5e9ac8f860566c121 Reviewed-on: http://review.whamcloud.com/7382 Tested-by: Hudson Reviewed-by: John L. Hammond Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- libcfs/libcfs/nidstrings.c | 2 +- lustre/lmv/lmv_obd.c | 133 +++++++++++++++++++++++---------------------- 2 files changed, 70 insertions(+), 65 deletions(-) diff --git a/libcfs/libcfs/nidstrings.c b/libcfs/libcfs/nidstrings.c index f06c77e..b49376b 100644 --- a/libcfs/libcfs/nidstrings.c +++ b/libcfs/libcfs/nidstrings.c @@ -459,7 +459,7 @@ libcfs_nid2str(lnet_nid_t nid) static struct netstrfns * libcfs_str2net_internal(const char *str, __u32 *net) { - struct netstrfns *nf; + struct netstrfns *nf = NULL; int nob; int netnum; int i; diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 3bcc81f..8fb7e68 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -77,17 +77,18 @@ static void lmv_activate_target(struct lmv_obd *lmv, * -ENOTCONN: The UUID is found, but the target connection is bad (!) * -EBADF : The UUID is found, but the OBD of the wrong type (!) */ -static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, - int activate) -{ - struct lmv_tgt_desc *tgt; - struct obd_device *obd; - int i; - int rc = 0; - ENTRY; +static int lmv_set_mdc_active(struct lmv_obd *lmv, + const struct obd_uuid *uuid, + int activate) +{ + struct lmv_tgt_desc *tgt = NULL; + struct obd_device *obd; + __u32 i; + int rc = 0; + ENTRY; - CDEBUG(D_INFO, "Searching in lmv %p for uuid %s (activate=%d)\n", - lmv, uuid->uuid, activate); + CDEBUG(D_INFO, "Searching in lmv %p for uuid %s (activate=%d)\n", + lmv, uuid->uuid, activate); spin_lock(&lmv->lmv_lock); for (i = 0; i < lmv->desc.ld_tgt_count; i++) { @@ -267,9 +268,9 @@ static int lmv_connect(const struct lu_env *env, static void lmv_set_timeouts(struct obd_device *obd) { - struct lmv_tgt_desc *tgt; - struct lmv_obd *lmv; - int i; + struct lmv_tgt_desc *tgt; + struct lmv_obd *lmv; + __u32 i; lmv = &obd->u.lmv; if (lmv->server_timeout == 0) @@ -291,12 +292,12 @@ static void lmv_set_timeouts(struct obd_device *obd) static int lmv_init_ea_size(struct obd_export *exp, int easize, int def_easize, int cookiesize) { - struct obd_device *obd = exp->exp_obd; - struct lmv_obd *lmv = &obd->u.lmv; - int i; - int rc = 0; - int change = 0; - ENTRY; + struct obd_device *obd = exp->exp_obd; + struct lmv_obd *lmv = &obd->u.lmv; + __u32 i; + int rc = 0; + int change = 0; + ENTRY; if (lmv->max_easize < easize) { lmv->max_easize = easize; @@ -555,12 +556,12 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp, int lmv_check_connect(struct obd_device *obd) { - struct lmv_obd *lmv = &obd->u.lmv; - struct lmv_tgt_desc *tgt; - int i; - int rc; - int easize; - ENTRY; + struct lmv_obd *lmv = &obd->u.lmv; + struct lmv_tgt_desc *tgt; + __u32 i; + int rc; + int easize; + ENTRY; if (lmv->connected) RETURN(0); @@ -681,14 +682,14 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) static int lmv_disconnect(struct obd_export *exp) { - struct obd_device *obd = class_exp2obd(exp); + struct obd_device *obd = class_exp2obd(exp); #ifdef __KERNEL__ - struct proc_dir_entry *lmv_proc_dir; + struct proc_dir_entry *lmv_proc_dir; #endif - struct lmv_obd *lmv = &obd->u.lmv; - int rc; - int i; - ENTRY; + struct lmv_obd *lmv = &obd->u.lmv; + int rc; + __u32 i; + ENTRY; if (!lmv->tgts) goto out_local; @@ -816,8 +817,9 @@ static int lmv_hsm_req_count(struct lmv_obd *lmv, const struct hsm_user_request *hur, const struct lmv_tgt_desc *tgt_mds) { - int i, nr = 0; - struct lmv_tgt_desc *curr_tgt; + __u32 i; + int nr = 0; + struct lmv_tgt_desc *curr_tgt; /* count how many requests must be sent to the given target */ for (i = 0; i < hur->hur_request.hr_itemcount; i++) { @@ -833,8 +835,8 @@ static void lmv_hsm_req_build(struct lmv_obd *lmv, const struct lmv_tgt_desc *tgt_mds, struct hsm_user_request *hur_out) { - int i, nr_out; - struct lmv_tgt_desc *curr_tgt; + __u32 i, nr_out; + struct lmv_tgt_desc *curr_tgt; /* build the hsm_user_request for the given target */ hur_out->hur_request = hur_in->hur_request; @@ -856,7 +858,8 @@ static void lmv_hsm_req_build(struct lmv_obd *lmv, static int lmv_hsm_ct_unregister(struct lmv_obd *lmv, unsigned int cmd, int len, struct lustre_kernelcomm *lk, void *uarg) { - int i, rc = 0; + __u32 i; + int rc; ENTRY; /* unregister request (call from llapi_hsm_copytool_fini) */ @@ -878,8 +881,8 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, struct lustre_kernelcomm *lk, void *uarg) { struct file *filp; - int i, j, err; - int rc = 0; + __u32 i, j; + int err, rc; bool any_set = false; ENTRY; @@ -935,13 +938,13 @@ static int lmv_hsm_ct_register(struct lmv_obd *lmv, unsigned int cmd, int len, static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, int len, void *karg, void *uarg) { - struct obd_device *obddev = class_exp2obd(exp); - struct lmv_obd *lmv = &obddev->u.lmv; - int i = 0; - int rc = 0; - int set = 0; - int count = lmv->desc.ld_tgt_count; - ENTRY; + struct obd_device *obddev = class_exp2obd(exp); + struct lmv_obd *lmv = &obddev->u.lmv; + __u32 i = 0; + int rc = 0; + int set = 0; + __u32 count = lmv->desc.ld_tgt_count; + ENTRY; if (count == 0) RETURN(-ENOTTY); @@ -1460,12 +1463,12 @@ out: static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *osfs, __u64 max_age, __u32 flags) { - struct obd_device *obd = class_exp2obd(exp); - struct lmv_obd *lmv = &obd->u.lmv; - struct obd_statfs *temp; - int rc = 0; - int i; - ENTRY; + struct obd_device *obd = class_exp2obd(exp); + struct lmv_obd *lmv = &obd->u.lmv; + struct obd_statfs *temp; + int rc = 0; + __u32 i; + ENTRY; rc = lmv_check_connect(obd); if (rc) @@ -1612,7 +1615,7 @@ static int lmv_null_inode(struct obd_export *exp, const struct lu_fid *fid) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - int i; + __u32 i; int rc; ENTRY; @@ -1641,7 +1644,7 @@ static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid, { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - int i; + __u32 i; int rc; ENTRY; @@ -2484,7 +2487,7 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, struct lmv_stripe_md *meap; struct lmv_stripe_md *lsmp; int mea_size; - int i; + __u32 i; ENTRY; mea_size = lmv_get_easize(lmv); @@ -2533,7 +2536,7 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, struct lmv_stripe_md *mea = (struct lmv_stripe_md *)lmm; struct lmv_obd *lmv = &obd->u.lmv; int mea_size; - int i; + __u32 i; __u32 magic; ENTRY; @@ -2588,7 +2591,7 @@ static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid, struct lmv_obd *lmv = &obd->u.lmv; int rc = 0; int err; - int i; + __u32 i; ENTRY; LASSERT(fid != NULL); @@ -2625,7 +2628,7 @@ ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags, struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; ldlm_mode_t rc; - int i; + __u32 i; ENTRY; CDEBUG(D_INODE, "Lock match for "DFID"\n", PFID(fid)); @@ -2809,7 +2812,8 @@ int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, struct obd_device *obd = class_exp2obd(exp); struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt = lmv->tgts[0]; - int rc = 0, i; + int rc = 0; + __u32 i; __u64 curspace, curinodes; ENTRY; @@ -2854,14 +2858,15 @@ int lmv_quotactl(struct obd_device *unused, struct obd_export *exp, int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp, struct obd_quotactl *oqctl) { - struct obd_device *obd = class_exp2obd(exp); - struct lmv_obd *lmv = &obd->u.lmv; - struct lmv_tgt_desc *tgt; - int i, rc = 0; - ENTRY; + struct obd_device *obd = class_exp2obd(exp); + struct lmv_obd *lmv = &obd->u.lmv; + struct lmv_tgt_desc *tgt; + __u32 i; + int rc = 0; + ENTRY; for (i = 0; i < lmv->desc.ld_tgt_count; i++) { - int err; + int err; tgt = lmv->tgts[i]; if (tgt == NULL || tgt->ltd_exp == NULL || !tgt->ltd_active) { CERROR("lmv idx %d inactive\n", i); -- 1.8.3.1