[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <5b7c72bdb52703bbfa5511ed500aed4babde1308.1716109606.git.christophe.jaillet@wanadoo.fr>
Date: Sun, 19 May 2024 11:09:58 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Ilya Dryomov <idryomov@...il.com>,
Xiubo Li <xiubli@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
ceph-devel@...r.kernel.org,
netdev@...r.kernel.org
Subject: [PATCH 1/2 net-next] libceph: Use sruct_size() in ceph_create_snap_context()
Use sruct_size() instead of hand-writing it.
This makes the code more readable and safer.
Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
Compile tested only
---
net/ceph/snapshot.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/net/ceph/snapshot.c b/net/ceph/snapshot.c
index e24315937c45..7363ccebee99 100644
--- a/net/ceph/snapshot.c
+++ b/net/ceph/snapshot.c
@@ -28,11 +28,8 @@ struct ceph_snap_context *ceph_create_snap_context(u32 snap_count,
gfp_t gfp_flags)
{
struct ceph_snap_context *snapc;
- size_t size;
- size = sizeof (struct ceph_snap_context);
- size += snap_count * sizeof (snapc->snaps[0]);
- snapc = kzalloc(size, gfp_flags);
+ snapc = kzalloc(sruct_size(snapc, snaps, snap_count), gfp_flags);
if (!snapc)
return NULL;
--
2.45.1
Powered by blists - more mailing lists