All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ceph: Use kcalloc for allocating multiple elements
@ 2022-08-19  5:42 Kenneth Lee
  2022-08-19  6:15 ` Xiubo Li
  0 siblings, 1 reply; 2+ messages in thread
From: Kenneth Lee @ 2022-08-19  5:42 UTC (permalink / raw)
  To: xiubli, idryomov, jlayton; +Cc: ceph-devel, Kenneth Lee

Prefer using kcalloc(a, b) over kzalloc(a * b) as this improves
semantics since kcalloc is intended for allocating an array of memory.

Signed-off-by: Kenneth Lee <klee33@uw.edu>
---
 fs/ceph/caps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 53cfe026b3ea..1eb2ff0f6bd8 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2285,7 +2285,7 @@ static int flush_mdlog_and_wait_inode_unsafe_requests(struct inode *inode)
 		struct ceph_mds_request *req;
 		int i;
 
-		sessions = kzalloc(max_sessions * sizeof(s), GFP_KERNEL);
+		sessions = kcalloc(max_sessions, sizeof(s), GFP_KERNEL);
 		if (!sessions) {
 			err = -ENOMEM;
 			goto out;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ceph: Use kcalloc for allocating multiple elements
  2022-08-19  5:42 [PATCH] ceph: Use kcalloc for allocating multiple elements Kenneth Lee
@ 2022-08-19  6:15 ` Xiubo Li
  0 siblings, 0 replies; 2+ messages in thread
From: Xiubo Li @ 2022-08-19  6:15 UTC (permalink / raw)
  To: Kenneth Lee, idryomov, jlayton; +Cc: ceph-devel


On 8/19/22 1:42 PM, Kenneth Lee wrote:
> Prefer using kcalloc(a, b) over kzalloc(a * b) as this improves
> semantics since kcalloc is intended for allocating an array of memory.
>
> Signed-off-by: Kenneth Lee <klee33@uw.edu>
> ---
>   fs/ceph/caps.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index 53cfe026b3ea..1eb2ff0f6bd8 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -2285,7 +2285,7 @@ static int flush_mdlog_and_wait_inode_unsafe_requests(struct inode *inode)
>   		struct ceph_mds_request *req;
>   		int i;
>   
> -		sessions = kzalloc(max_sessions * sizeof(s), GFP_KERNEL);
> +		sessions = kcalloc(max_sessions, sizeof(s), GFP_KERNEL);
>   		if (!sessions) {
>   			err = -ENOMEM;
>   			goto out;

Merged into the testing branch. Thanks Kenneth!

-- Xiubo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-19  6:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-19  5:42 [PATCH] ceph: Use kcalloc for allocating multiple elements Kenneth Lee
2022-08-19  6:15 ` Xiubo Li

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.