From b93656182e02c22bb2f447dfd3dc460500d7e1c7 Mon Sep 17 00:00:00 2001 From: Bhumika Goyal Date: Thu, 25 Feb 2016 23:03:47 +0530 Subject: [PATCH] Staging: lustre: lov: Use list_for_each_entry instead of list_for_each Use list_for_each_entry instead of list_for_each and list_entry as it simplifies the code. Done using coccinelle: @@ type T,T2; identifier I1,I2; expression e1,e2; iterator name list_for_each_entry; iterator name list_for_each; @@ - T *I1; ... - list_for_each(I1,e1) + list_for_each_entry(I2,e1,e2) { ...when!=T *I1; - I2=list_entry(I1,T2,e2); ... } ...when!=I2; @@ type T,T2,T3; identifier I1,I2,I3; expression e1,e2; @@ - T *I1; + T3 *I3; ... - list_for_each(I1,e1) + list_for_each_entry(I3,e1,e2) { ...when!=T *I1; - T3 *I3=list_entry(I1,T2,e2); ... } ...when!=I3; Signed-off-by: Bhumika Goyal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/lustre/lustre/lov/lov_obd.c | 19 ++++--------------- .../staging/lustre/lustre/lov/lov_request.c | 5 +---- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 846683bfe302..7ba670a546cf 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -1073,7 +1073,6 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp, struct lov_request_set *set; struct obd_info oinfo; struct lov_request *req; - struct list_head *pos; struct lov_obd *lov; int rc = 0, err = 0; @@ -1093,9 +1092,7 @@ static int lov_destroy(const struct lu_env *env, struct obd_export *exp, if (rc) goto out; - list_for_each(pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); - + list_for_each_entry(req, &set->set_list, rq_link) { if (oa->o_valid & OBD_MD_FLCOOKIE) oti->oti_logcookies = set->set_cookies + req->rq_stripe; @@ -1140,7 +1137,6 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, { struct lov_request_set *lovset; struct lov_obd *lov; - struct list_head *pos; struct lov_request *req; int rc = 0, err; @@ -1160,9 +1156,7 @@ static int lov_getattr_async(struct obd_export *exp, struct obd_info *oinfo, POSTID(&oinfo->oi_md->lsm_oi), oinfo->oi_md->lsm_stripe_count, oinfo->oi_md->lsm_stripe_size); - list_for_each(pos, &lovset->set_list) { - req = list_entry(pos, struct lov_request, rq_link); - + list_for_each_entry(req, &lovset->set_list, rq_link) { CDEBUG(D_INFO, "objid " DOSTID "[%d] has subobj " DOSTID " at idx%u\n", POSTID(&oinfo->oi_oa->o_oi), req->rq_stripe, POSTID(&req->rq_oi.oi_oa->o_oi), req->rq_idx); @@ -1214,7 +1208,6 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, { struct lov_request_set *set; struct lov_request *req; - struct list_head *pos; struct lov_obd *lov; int rc = 0; @@ -1238,9 +1231,7 @@ static int lov_setattr_async(struct obd_export *exp, struct obd_info *oinfo, oinfo->oi_md->lsm_stripe_count, oinfo->oi_md->lsm_stripe_size); - list_for_each(pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); - + list_for_each_entry(req, &set->set_list, rq_link) { if (oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE) oti->oti_logcookies = set->set_cookies + req->rq_stripe; @@ -1335,7 +1326,6 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, struct obd_device *obd = class_exp2obd(exp); struct lov_request_set *set; struct lov_request *req; - struct list_head *pos; struct lov_obd *lov; int rc = 0; @@ -1346,8 +1336,7 @@ static int lov_statfs_async(struct obd_export *exp, struct obd_info *oinfo, if (rc) return rc; - list_for_each(pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); + list_for_each_entry(req, &set->set_list, rq_link) { rc = obd_statfs_async(lov->lov_tgts[req->rq_idx]->ltd_exp, &req->rq_oi, max_age, rqset); if (rc) diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index 5408eef045f2..42660f2c83c1 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -190,7 +190,6 @@ out: static int common_attr_done(struct lov_request_set *set) { - struct list_head *pos; struct lov_request *req; struct obdo *tmp_oa; int rc = 0, attrset = 0; @@ -207,9 +206,7 @@ static int common_attr_done(struct lov_request_set *set) goto out; } - list_for_each(pos, &set->set_list) { - req = list_entry(pos, struct lov_request, rq_link); - + list_for_each_entry(req, &set->set_list, rq_link) { if (!req->rq_complete || req->rq_rc) continue; if (req->rq_oi.oi_oa->o_valid == 0) /* inactive stripe */ -- 2.39.5