damon: vaddr-test: tweak code to make the logic clearer
Subsystems (2)
PATCH 1/1 damon: vaddr-test: tweak code to make the logic clearer
Move these two lines into the damon_for_each_region loop, it is always for testing the last region. And also avoid to use a list iterator 'r' outside the loop which is considered harmful[1].
[1]: https://lkml.org/lkml/2022/2/17/1032
Signed-off-by Xiaomeng Tong <[email protected]>
--- mm/damon/vaddr-test.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
mm/damon/vaddr-test.h +5 -3
@@ -281,14 +281,16 @@ static void damon_test_split_evenly_succ(struct kunit *test,KUNIT_EXPECT_EQ (test,damon_nr_regions (t), nr_pieces);damon_for_each_region (r, t) { -if (i == nr_pieces -1 ) +if (i == nr_pieces -1 ) { +KUNIT_EXPECT_EQ (test, + r->ar.start, start + i * expected_width); +KUNIT_EXPECT_EQ (test, r->ar.end, end);break ; + }KUNIT_EXPECT_EQ (test, r->ar.start, start + i++ * expected_width);KUNIT_EXPECT_EQ (test, r->ar.end, start + i * expected_width); } -KUNIT_EXPECT_EQ (test, r->ar.start, start + i * expected_width); -KUNIT_EXPECT_EQ (test, r->ar.end, end);damon_free_target (t); }
Signature · 1 line
2.17.1
Quoted 5 lines · On Mon, 28 Mar 2022 19:29:30 +0800 Xiaomeng Tong <[email protected]> wrote:
Move these two lines into the
damon_for_each_regionloop, it is always for testing the last region. And also avoid to use a list iterator 'r' outside the loop which is considered harmful[1].
Let's have one empty line here[1].
[1] https://www.kernel.org/doc/html/v4.17/process/submitting-patches.html#the-canonical-patch-format
Quoted 1 line
Signed-off-by Xiaomeng Tong <[email protected]>
Other than the above trivial nit,
Reviewed-by SeongJae Park <[email protected]>
Thanks,
SJ
Quoted 30 lines
--- mm/damon/vaddr-test.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)mm/damon/vaddr-test.h +5
-3@@ -281,14 +281,16 @@ static void damon_test_split_evenly_succ(struct kunit *test,KUNIT_EXPECT_EQ (test,damon_nr_regions (t), nr_pieces);damon_for_each_region (r, t) { -if (i == nr_pieces -1 ) +if (i == nr_pieces -1 ) { +KUNIT_EXPECT_EQ (test, + r->ar.start, start + i * expected_width); +KUNIT_EXPECT_EQ (test, r->ar.end, end);break ; + }KUNIT_EXPECT_EQ (test, r->ar.start, start + i++ * expected_width);KUNIT_EXPECT_EQ (test, r->ar.end, start + i * expected_width); } -KUNIT_EXPECT_EQ (test, r->ar.start, start + i * expected_width); -KUNIT_EXPECT_EQ (test, r->ar.end, end);damon_free_target (t); }Signature · 1 line
2.17.1