mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
btrfs: refactor allocation size calculation in alloc_btrfs_io_context()
Use struct_size() to replace the open-coded calculation, remove the comment as use of the helper is self explanatory. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
committed by
David Sterba
parent
aebe2bb0b8
commit
2346b966c6
@@ -6076,12 +6076,7 @@ struct btrfs_io_context *alloc_btrfs_io_context(struct btrfs_fs_info *fs_info,
|
||||
{
|
||||
struct btrfs_io_context *bioc;
|
||||
|
||||
bioc = kzalloc(
|
||||
/* The size of btrfs_io_context */
|
||||
sizeof(struct btrfs_io_context) +
|
||||
/* Plus the variable array for the stripes */
|
||||
sizeof(struct btrfs_io_stripe) * (total_stripes),
|
||||
GFP_NOFS);
|
||||
bioc = kzalloc(struct_size(bioc, stripes, total_stripes), GFP_NOFS);
|
||||
|
||||
if (!bioc)
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user