]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Staging: lustre: lov: Use list_for_each_entry instead of list_for_each
authorBhumika Goyal <bhumirks@gmail.com>
Thu, 25 Feb 2016 17:33:47 +0000 (23:03 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Feb 2016 06:21:20 +0000 (22:21 -0800)
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 <bhumirks@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/lov/lov_obd.c
drivers/staging/lustre/lustre/lov/lov_request.c

index 846683bfe302be5dd081a7c75a96b4d0cc727df4..7ba670a546cfa280691ebf6dfa1f08cd4cdad974 100644 (file)
@@ -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)
index 5408eef045f214aae1b345c04ef708c85fcceb5e..42660f2c83c1eb404e9e166ab277673d8e0f2a5c 100644 (file)
@@ -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 */