Commit 2346b966 authored by Mehdi Ben Hadj Khelifa's avatar Mehdi Ben Hadj Khelifa Committed by David Sterba
Browse files

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: default avatarQu Wenruo <wqu@suse.com>
Signed-off-by: default avatarMehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent aebe2bb0
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -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;