gfs2: replace 'found' with dedicated list iterator variable
To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body. To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable instead of a found boolean [1]. This removes the need to use a found variable and simply checking if the variable was set, can determine if the break/goto was hit. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1] Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:
Родитель
d928e8f3af
Коммит
b846f2d7e2
|
@ -443,9 +443,8 @@ static int qd_check_sync(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd,
|
|||
|
||||
static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp)
|
||||
{
|
||||
struct gfs2_quota_data *qd = NULL;
|
||||
struct gfs2_quota_data *qd = NULL, *iter;
|
||||
int error;
|
||||
int found = 0;
|
||||
|
||||
*qdp = NULL;
|
||||
|
||||
|
@ -454,14 +453,12 @@ static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp)
|
|||
|
||||
spin_lock(&qd_lock);
|
||||
|
||||
list_for_each_entry(qd, &sdp->sd_quota_list, qd_list) {
|
||||
found = qd_check_sync(sdp, qd, &sdp->sd_quota_sync_gen);
|
||||
if (found)
|
||||
list_for_each_entry(iter, &sdp->sd_quota_list, qd_list) {
|
||||
if (qd_check_sync(sdp, iter, &sdp->sd_quota_sync_gen)) {
|
||||
qd = iter;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
qd = NULL;
|
||||
}
|
||||
|
||||
spin_unlock(&qd_lock);
|
||||
|
||||
|
|
|
@ -55,17 +55,16 @@ int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
|
|||
int gfs2_revoke_add(struct gfs2_jdesc *jd, u64 blkno, unsigned int where)
|
||||
{
|
||||
struct list_head *head = &jd->jd_revoke_list;
|
||||
struct gfs2_revoke_replay *rr;
|
||||
int found = 0;
|
||||
struct gfs2_revoke_replay *rr = NULL, *iter;
|
||||
|
||||
list_for_each_entry(rr, head, rr_list) {
|
||||
if (rr->rr_blkno == blkno) {
|
||||
found = 1;
|
||||
list_for_each_entry(iter, head, rr_list) {
|
||||
if (iter->rr_blkno == blkno) {
|
||||
rr = iter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
if (rr) {
|
||||
rr->rr_where = where;
|
||||
return 0;
|
||||
}
|
||||
|
@ -83,18 +82,17 @@ int gfs2_revoke_add(struct gfs2_jdesc *jd, u64 blkno, unsigned int where)
|
|||
|
||||
int gfs2_revoke_check(struct gfs2_jdesc *jd, u64 blkno, unsigned int where)
|
||||
{
|
||||
struct gfs2_revoke_replay *rr;
|
||||
struct gfs2_revoke_replay *rr = NULL, *iter;
|
||||
int wrap, a, b, revoke;
|
||||
int found = 0;
|
||||
|
||||
list_for_each_entry(rr, &jd->jd_revoke_list, rr_list) {
|
||||
if (rr->rr_blkno == blkno) {
|
||||
found = 1;
|
||||
list_for_each_entry(iter, &jd->jd_revoke_list, rr_list) {
|
||||
if (iter->rr_blkno == blkno) {
|
||||
rr = iter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
if (!rr)
|
||||
return 0;
|
||||
|
||||
wrap = (rr->rr_where < jd->jd_replay_tail);
|
||||
|
|
Загрузка…
Ссылка в новой задаче