From: Ryota Sakamoto Date: Tue, 27 Jan 2026 14:23:23 +0000 (+0900) Subject: ext4: replace KUnit tests for memcmp() with KUNIT_ASSERT_MEMEQ() X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=4bdba812279bb1fd64450cf575f58f3546aa7e9e;p=thirdparty%2Flinux.git ext4: replace KUnit tests for memcmp() with KUNIT_ASSERT_MEMEQ() Replace KUnit tests for memcmp() with KUNIT_ASSERT_MEMEQ() to improve debugging that prints the hex dump of the buffers when the assertion fails, whereas memcmp() only returns an integer difference. Signed-off-by: Ryota Sakamoto Link: https://patch.msgid.link/20260127-fix-fs_ext4-memcmp-v1-1-5c269ae906b6@gmail.com Signed-off-by: Theodore Ts'o --- diff --git a/fs/ext4/mballoc-test.c b/fs/ext4/mballoc-test.c index 90ed505fa4b1a..3bd8ef087b287 100644 --- a/fs/ext4/mballoc-test.c +++ b/fs/ext4/mballoc-test.c @@ -714,8 +714,7 @@ do_test_generate_buddy(struct kunit *test, struct super_block *sb, void *bitmap, ext4_mb_generate_buddy_test(sb, ext4_buddy, bitmap, TEST_GOAL_GROUP, ext4_grp); - KUNIT_ASSERT_EQ(test, memcmp(mbt_buddy, ext4_buddy, sb->s_blocksize), - 0); + KUNIT_ASSERT_MEMEQ(test, mbt_buddy, ext4_buddy, sb->s_blocksize); mbt_validate_group_info(test, mbt_grp, ext4_grp); } @@ -776,8 +775,7 @@ test_mb_mark_used_range(struct kunit *test, struct ext4_buddy *e4b, grp->bb_counters[i] = 0; ext4_mb_generate_buddy_test(sb, buddy, bitmap, 0, grp); - KUNIT_ASSERT_EQ(test, memcmp(buddy, e4b->bd_buddy, sb->s_blocksize), - 0); + KUNIT_ASSERT_MEMEQ(test, buddy, e4b->bd_buddy, sb->s_blocksize); mbt_validate_group_info(test, grp, e4b->bd_info); } @@ -841,8 +839,7 @@ test_mb_free_blocks_range(struct kunit *test, struct ext4_buddy *e4b, grp->bb_counters[i] = 0; ext4_mb_generate_buddy_test(sb, buddy, bitmap, 0, grp); - KUNIT_ASSERT_EQ(test, memcmp(buddy, e4b->bd_buddy, sb->s_blocksize), - 0); + KUNIT_ASSERT_MEMEQ(test, buddy, e4b->bd_buddy, sb->s_blocksize); mbt_validate_group_info(test, grp, e4b->bd_info); }