[PATCH] ubifs: Move update of cnt in get_znodes_to_commit
Waqar Hameed
waqar.hameed at axis.com
Wed Nov 6 08:48:17 PST 2024
On Fri, Oct 18, 2024 at 09:24 +0800 Zhihao Cheng <chengzhihao1 at huawei.com> wrote:
> 在 2024/10/18 2:41, Waqar Hameed 写道:
>> There is no need to update `cnt` for the first dirty node just before
>> the loop, and then again update it at the end of each iteration for the
>> next dirty nodes. Just update `cnt` at the beginning of each iteration
>> instead. This way, the first iteration will count the first dirty node
>> and any subsequent iterations will count the next dirty nodes.
>
> Well, from my own view, I prefer the orignal style because it looks more
> readable.
> c->cnext = find_first_dirty(c->zroot.znode);
> znode = c->enext = c->cnext;
> cnt += 1; // We get the first one.
>
> while (1) {
> cnext = find_next_dirty(znode);
> znode = cnext;
> cnt += 1; // We get another one.
> }
>
> After applying this patch, the intention of 'cnt' updating is not so obviously.
> However, it does reduce the duplicated codes. I will add an acked-by to let
> Richard determine whether or not apply this patch.
>
> Acked-by: Zhihao Cheng <chengzhihao1 at huawei.com>
[...]
As you say, there could be a subjective argument here (for me it was the
other way around :) ), and that the objective argument is that it
reduces the code.
I'm fine with either! Richard, you decide then.
More information about the linux-mtd
mailing list