mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:41:42 +00:00
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: Zhengyuan Liu <liuzhengyuan@kylinos.cn> Signed-off-by: David Howells <dhowells@redhat.com>
This commit is contained in:
parent
4521819369
commit
ee102584ef
@ -242,8 +242,7 @@ retry:
|
||||
if (nr_inline > (PAGE_SIZE - sizeof(*req)) / sizeof(struct page *))
|
||||
nr_inline = 0;
|
||||
|
||||
req = kzalloc(sizeof(*req) + sizeof(struct page *) * nr_inline,
|
||||
GFP_KERNEL);
|
||||
req = kzalloc(struct_size(req, array, nr_inline), GFP_KERNEL);
|
||||
if (!req)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
|
@ -314,8 +314,7 @@ int afs_page_filler(void *data, struct page *page)
|
||||
/* fall through */
|
||||
default:
|
||||
go_on:
|
||||
req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *),
|
||||
GFP_KERNEL);
|
||||
req = kzalloc(struct_size(req, array, 1), GFP_KERNEL);
|
||||
if (!req)
|
||||
goto enomem;
|
||||
|
||||
@ -465,8 +464,7 @@ static int afs_readpages_one(struct file *file, struct address_space *mapping,
|
||||
n++;
|
||||
}
|
||||
|
||||
req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *) * n,
|
||||
GFP_NOFS);
|
||||
req = kzalloc(struct_size(req, array, n), GFP_NOFS);
|
||||
if (!req)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -48,8 +48,7 @@ static int afs_fill_page(struct afs_vnode *vnode, struct key *key,
|
||||
return 0;
|
||||
}
|
||||
|
||||
req = kzalloc(sizeof(struct afs_read) + sizeof(struct page *),
|
||||
GFP_KERNEL);
|
||||
req = kzalloc(struct_size(req, array, 1), GFP_KERNEL);
|
||||
if (!req)
|
||||
return -ENOMEM;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user