Skip to content

Commit 892ab4b

Browse files
kilobytetorvalds
authored andcommitted
mm/damon: don't use strnlen() with known-bogus source length
gcc knows the true length too, and rightfully complains. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Adam Borowski <[email protected]> Cc: SeongJae Park <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent fa360be commit 892ab4b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

mm/damon/dbgfs-test.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,57 +20,57 @@ static void damon_dbgfs_test_str_to_target_ids(struct kunit *test)
2020
ssize_t nr_integers = 0, i;
2121

2222
question = "123";
23-
answers = str_to_target_ids(question, strnlen(question, 128),
23+
answers = str_to_target_ids(question, strlen(question),
2424
&nr_integers);
2525
KUNIT_EXPECT_EQ(test, (ssize_t)1, nr_integers);
2626
KUNIT_EXPECT_EQ(test, 123ul, answers[0]);
2727
kfree(answers);
2828

2929
question = "123abc";
30-
answers = str_to_target_ids(question, strnlen(question, 128),
30+
answers = str_to_target_ids(question, strlen(question),
3131
&nr_integers);
3232
KUNIT_EXPECT_EQ(test, (ssize_t)1, nr_integers);
3333
KUNIT_EXPECT_EQ(test, 123ul, answers[0]);
3434
kfree(answers);
3535

3636
question = "a123";
37-
answers = str_to_target_ids(question, strnlen(question, 128),
37+
answers = str_to_target_ids(question, strlen(question),
3838
&nr_integers);
3939
KUNIT_EXPECT_EQ(test, (ssize_t)0, nr_integers);
4040
kfree(answers);
4141

4242
question = "12 35";
43-
answers = str_to_target_ids(question, strnlen(question, 128),
43+
answers = str_to_target_ids(question, strlen(question),
4444
&nr_integers);
4545
KUNIT_EXPECT_EQ(test, (ssize_t)2, nr_integers);
4646
for (i = 0; i < nr_integers; i++)
4747
KUNIT_EXPECT_EQ(test, expected[i], answers[i]);
4848
kfree(answers);
4949

5050
question = "12 35 46";
51-
answers = str_to_target_ids(question, strnlen(question, 128),
51+
answers = str_to_target_ids(question, strlen(question),
5252
&nr_integers);
5353
KUNIT_EXPECT_EQ(test, (ssize_t)3, nr_integers);
5454
for (i = 0; i < nr_integers; i++)
5555
KUNIT_EXPECT_EQ(test, expected[i], answers[i]);
5656
kfree(answers);
5757

5858
question = "12 35 abc 46";
59-
answers = str_to_target_ids(question, strnlen(question, 128),
59+
answers = str_to_target_ids(question, strlen(question),
6060
&nr_integers);
6161
KUNIT_EXPECT_EQ(test, (ssize_t)2, nr_integers);
6262
for (i = 0; i < 2; i++)
6363
KUNIT_EXPECT_EQ(test, expected[i], answers[i]);
6464
kfree(answers);
6565

6666
question = "";
67-
answers = str_to_target_ids(question, strnlen(question, 128),
67+
answers = str_to_target_ids(question, strlen(question),
6868
&nr_integers);
6969
KUNIT_EXPECT_EQ(test, (ssize_t)0, nr_integers);
7070
kfree(answers);
7171

7272
question = "\n";
73-
answers = str_to_target_ids(question, strnlen(question, 128),
73+
answers = str_to_target_ids(question, strlen(question),
7474
&nr_integers);
7575
KUNIT_EXPECT_EQ(test, (ssize_t)0, nr_integers);
7676
kfree(answers);

0 commit comments

Comments
 (0)