btrfs: clean up header members offsets in write helpers
authorDavid Sterba <dsterba@suse.com>
Mon, 21 Sep 2020 20:07:14 +0000 (22:07 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jun 2021 13:19:06 +0000 (15:19 +0200)
Move header offsetof() to the expression that calculates the address so
it's part of get_eb_offset_in_page where the 2nd parameter is the member
offset.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c

index 2b250c6..2e924f6 100644 (file)
@@ -6519,9 +6519,10 @@ void write_extent_buffer_chunk_tree_uuid(const struct extent_buffer *eb,
        char *kaddr;
 
        assert_eb_page_uptodate(eb, eb->pages[0]);
-       kaddr = page_address(eb->pages[0]) + get_eb_offset_in_page(eb, 0);
-       memcpy(kaddr + offsetof(struct btrfs_header, chunk_tree_uuid), srcv,
-                       BTRFS_FSID_SIZE);
+       kaddr = page_address(eb->pages[0]) +
+               get_eb_offset_in_page(eb, offsetof(struct btrfs_header,
+                                                  chunk_tree_uuid));
+       memcpy(kaddr, srcv, BTRFS_FSID_SIZE);
 }
 
 void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *srcv)
@@ -6529,9 +6530,9 @@ void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *srcv)
        char *kaddr;
 
        assert_eb_page_uptodate(eb, eb->pages[0]);
-       kaddr = page_address(eb->pages[0]) + get_eb_offset_in_page(eb, 0);
-       memcpy(kaddr + offsetof(struct btrfs_header, fsid), srcv,
-                       BTRFS_FSID_SIZE);
+       kaddr = page_address(eb->pages[0]) +
+               get_eb_offset_in_page(eb, offsetof(struct btrfs_header, fsid));
+       memcpy(kaddr, srcv, BTRFS_FSID_SIZE);
 }
 
 void write_extent_buffer(const struct extent_buffer *eb, const void *srcv,