hfs/hfxplus: use kzalloc_flex()
Subsystems (3)
PATCH 1/1 hfs/hfxplus: use kzalloc_flex()
Instead of doing the math manually, use kzalloc_flex() which does it in a cleaner way.
Also clarifies which is the flexible array member.
Signed-off-by Rosen Penev <[email protected]>
--- fs/hfs/bnode.c | 6 ++---- fs/hfsplus/bnode.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-)
fs/hfs/bnode.c +2 -4
@@ -344,7 +344,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)struct hfs_bnode *node, *node2;struct address_space *mapping;struct page *page; -int size, block, i, hash; +int block, i, hash;loff_t off;if (cnid >= tree->node_count) {
@@ -352,9 +352,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)return NULL ; } - size =sizeof (struct hfs_bnode ) + tree->pages_per_bnode * -sizeof (struct page *); - node =kzalloc (size,GFP_KERNEL ); + node =kzalloc_flex (*node, page, tree->pages_per_bnode,GFP_KERNEL );if (!node)return NULL ; node->tree = tree;
fs/hfsplus/bnode.c +2 -4
@@ -455,7 +455,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)struct hfs_bnode *node, *node2;struct address_space *mapping;struct page *page; -int size, block, i, hash; +int block, i, hash;loff_t off;if (cnid >= tree->node_count) {
@@ -464,9 +464,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)return NULL ; } - size =sizeof (struct hfs_bnode ) + tree->pages_per_bnode * -sizeof (struct page *); - node =kzalloc (size,GFP_KERNEL ); + node =kzalloc_flex (*node, page, tree->pages_per_bnode);if (!node)return NULL ; node->tree = tree;
Signature · 1 line
2.54.0
Quoted 49 lines · Rosen Penev
Instead of doing the math manually, use
kzalloc_flex()which does it in a cleaner way.Also clarifies which is the flexible array member.
Signed-off-by Rosen Penev <[email protected]>--- fs/hfs/bnode.c | 6 ++---- fs/hfsplus/bnode.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-)fs/hfs/bnode.c +2
-4@@ -344,7 +344,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)struct hfs_bnode *node, *node2;struct address_space *mapping;struct page *page; -int size, block, i, hash; +int block, i, hash;loff_t off;if (cnid >= tree->node_count) {@@ -352,9 +352,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)return NULL ; } - size =sizeof (struct hfs_bnode ) + tree->pages_per_bnode * -sizeof (struct page *); - node =kzalloc (size,GFP_KERNEL ); + node =kzalloc_flex (*node, page, tree->pages_per_bnode,GFP_KERNEL );if (!node)return NULL ; node->tree = tree;fs/hfsplus/bnode.c +1
-1@@ -455,7 +455,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)struct hfs_bnode *node, *node2;struct address_space *mapping;struct page *page; -int size, block, i, hash; +int block, i, hash;loff_t off;if (cnid >= tree->node_count) {
fs/hfsplus/bnode.c static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid) · line 470
Quoted 10 lines
fs/hfsplus/bnode.c +1
-3@@ -464,9 +464,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)return NULL ; } - size =sizeof (struct hfs_bnode ) + tree->pages_per_bnode * -sizeof (struct page *); - node =kzalloc (size,GFP_KERNEL ); + node =kzalloc_flex (*node, page, tree->pages_per_bnode);if (!node)return NULL ; node->tree = tree;
Makes sense.
Reviewed-by Viacheslav Dubeyko <[email protected]>
Thanks,
Slava.