[PATCH 3/3] btrfs: Simplify dump_eb_and_memory_contents()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Remove the casting from folio back to page and remove the use of memcmp
for a single byte.  Change the type to u8 so we can do direct array
arithmetic instead of doing complicated casts.

Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
---
 fs/btrfs/tests/extent-io-tests.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
index 36720b77b440..f5f6accbdc21 100644
--- a/fs/btrfs/tests/extent-io-tests.c
+++ b/fs/btrfs/tests/extent-io-tests.c
@@ -664,17 +664,17 @@ static int test_find_first_clear_extent_bit(void)
 	return ret;
 }
 
-static void dump_eb_and_memory_contents(struct extent_buffer *eb, void *memory,
-					const char *test_name)
+static void dump_eb_and_memory_contents(const struct extent_buffer *eb,
+		const u8 *memory, const char *test_name)
 {
 	for (int i = 0; i < eb->len; i++) {
-		struct page *page = folio_page(eb->folios[i >> PAGE_SHIFT], 0);
-		void *addr = page_address(page) + offset_in_page(i);
+		struct folio *folio = eb->folios[i / PAGE_SIZE];
+		u8 *addr = folio_address(folio) + i % PAGE_SIZE;
 
-		if (memcmp(addr, memory + i, 1) != 0) {
+		if (*addr != memory[i]) {
 			test_err("%s failed", test_name);
 			test_err("eb and memory diffs at byte %u, eb has 0x%02x memory has 0x%02x",
-				 i, *(u8 *)addr, *(u8 *)(memory + i));
+				 i, *addr, memory[i]);
 			return;
 		}
 	}
-- 
2.47.2





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux