Commit 56e6f268 authored by David Sterba's avatar David Sterba

btrfs: constify parameters of write_eb_member() and its users

Reported by 'gcc -Wcast-qual', the argument from which write_extent_buffer()
reads data to write to the eb should be const. In addition the const
needs to be also added to __write_extent_buffer() local buffers.

All callers of write_eb_member() can now be updated to use const for the
input buffer structure or type.
Reviewed-by: default avatarBoris Burkov <boris@bur.io>
Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
Reviewed-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 840a97bd
...@@ -48,8 +48,8 @@ static inline void put_unaligned_le8(u8 val, void *p) ...@@ -48,8 +48,8 @@ static inline void put_unaligned_le8(u8 val, void *p)
offsetof(type, member), \ offsetof(type, member), \
sizeof_field(type, member))) sizeof_field(type, member)))
#define write_eb_member(eb, ptr, type, member, result) (\ #define write_eb_member(eb, ptr, type, member, source) ( \
write_extent_buffer(eb, (char *)(result), \ write_extent_buffer(eb, (const char *)(source), \
((unsigned long)(ptr)) + \ ((unsigned long)(ptr)) + \
offsetof(type, member), \ offsetof(type, member), \
sizeof_field(type, member))) sizeof_field(type, member)))
...@@ -353,7 +353,7 @@ static inline void btrfs_tree_block_key(const struct extent_buffer *eb, ...@@ -353,7 +353,7 @@ static inline void btrfs_tree_block_key(const struct extent_buffer *eb,
static inline void btrfs_set_tree_block_key(const struct extent_buffer *eb, static inline void btrfs_set_tree_block_key(const struct extent_buffer *eb,
struct btrfs_tree_block_info *item, struct btrfs_tree_block_info *item,
struct btrfs_disk_key *key) const struct btrfs_disk_key *key)
{ {
write_eb_member(eb, item, struct btrfs_tree_block_info, key, key); write_eb_member(eb, item, struct btrfs_tree_block_info, key, key);
} }
...@@ -446,7 +446,7 @@ void btrfs_node_key(const struct extent_buffer *eb, ...@@ -446,7 +446,7 @@ void btrfs_node_key(const struct extent_buffer *eb,
struct btrfs_disk_key *disk_key, int nr); struct btrfs_disk_key *disk_key, int nr);
static inline void btrfs_set_node_key(const struct extent_buffer *eb, static inline void btrfs_set_node_key(const struct extent_buffer *eb,
struct btrfs_disk_key *disk_key, int nr) const struct btrfs_disk_key *disk_key, int nr)
{ {
unsigned long ptr; unsigned long ptr;
...@@ -512,7 +512,7 @@ static inline void btrfs_item_key(const struct extent_buffer *eb, ...@@ -512,7 +512,7 @@ static inline void btrfs_item_key(const struct extent_buffer *eb,
} }
static inline void btrfs_set_item_key(struct extent_buffer *eb, static inline void btrfs_set_item_key(struct extent_buffer *eb,
struct btrfs_disk_key *disk_key, int nr) const struct btrfs_disk_key *disk_key, int nr)
{ {
struct btrfs_item *item = btrfs_item_nr(eb, nr); struct btrfs_item *item = btrfs_item_nr(eb, nr);
......
...@@ -4606,7 +4606,7 @@ static void __write_extent_buffer(const struct extent_buffer *eb, ...@@ -4606,7 +4606,7 @@ static void __write_extent_buffer(const struct extent_buffer *eb,
size_t cur; size_t cur;
size_t offset; size_t offset;
char *kaddr; char *kaddr;
char *src = (char *)srcv; const char *src = (const char *)srcv;
unsigned long i = get_eb_folio_index(eb, start); unsigned long i = get_eb_folio_index(eb, start);
/* For unmapped (dummy) ebs, no need to check their uptodate status. */ /* For unmapped (dummy) ebs, no need to check their uptodate status. */
const bool check_uptodate = !test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags); const bool check_uptodate = !test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment