Skip to content

Commit 1738108

Browse files
Mehdi Ben Hadj Khelifakdave
authored andcommitted
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 <[email protected]> Signed-off-by: Mehdi Ben Hadj Khelifa <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 3177499 commit 1738108

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

fs/btrfs/volumes.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6076,12 +6076,7 @@ struct btrfs_io_context *alloc_btrfs_io_context(struct btrfs_fs_info *fs_info,
60766076
{
60776077
struct btrfs_io_context *bioc;
60786078

6079-
bioc = kzalloc(
6080-
/* The size of btrfs_io_context */
6081-
sizeof(struct btrfs_io_context) +
6082-
/* Plus the variable array for the stripes */
6083-
sizeof(struct btrfs_io_stripe) * (total_stripes),
6084-
GFP_NOFS);
6079+
bioc = kzalloc(struct_size(bioc, stripes, total_stripes), GFP_NOFS);
60856080

60866081
if (!bioc)
60876082
return NULL;

0 commit comments

Comments
 (0)