Commit ee102584 authored by Zhengyuan Liu's avatar Zhengyuan Liu Committed by David Howells

fs/afs: use struct_size() in kzalloc()

As Gustavo said in other patches doing the same replace, we can now
use the new struct_size() helper to avoid leaving these open-coded and
prone to type mistake.
Signed-off-by: default avatarZhengyuan Liu <liuzhengyuan@kylinos.cn>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent 45218193
...@@ -242,8 +242,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key) ...@@ -242,8 +242,7 @@ static struct afs_read *afs_read_dir(struct afs_vnode *dvnode, struct key *key)
if (nr_inline > (PAGE_SIZE - sizeof(*req)) / sizeof(struct page *)) if (nr_inline > (PAGE_SIZE - sizeof(*req)) / sizeof(struct page *))
nr_inline = 0; nr_inline = 0;
req = kzalloc(sizeof(*req) + sizeof(struct page *) * nr_inline, req = kzalloc(struct_size(req, array, nr_inline), GFP_KERNEL);
GFP_KERNEL);
if (!req) if (!req)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
...@@ -314,8 +314,7 @@ int afs_page_filler(void *data, struct page *page) ...@@ -314,8 +314,7 @@ int afs_page_filler(void *data, struct page *page)
/* fall through */ /* fall through */
default: default:
go_on: go_on:
req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *), req = kzalloc(struct_size(req, array, 1), GFP_KERNEL);
GFP_KERNEL);
if (!req) if (!req)
goto enomem; goto enomem;
...@@ -465,8 +464,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping, ...@@ -465,8 +464,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
n++; n++;
} }
req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *) * n, req = kzalloc(struct_size(req, array, n), GFP_NOFS);
GFP_NOFS);
if (!req) if (!req)
return -ENOMEM; return -ENOMEM;
......
...@@ -48,8 +48,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key, ...@@ -48,8 +48,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
return 0; return 0;
} }
req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *), req = kzalloc(struct_size(req, array, 1), GFP_KERNEL);
GFP_KERNEL);
if (!req) if (!req)
return -ENOMEM; return -ENOMEM;
......
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