Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1865970lqo; Sun, 19 May 2024 02:20:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX69AJv05jxb9dd/T12C5MaRNQTxXEd5fiDDlcnN8JX8yRKI7PWDlbQQUM9gsRyVaX8aYo2hd0ALW2Yg08N+/lBnHnNw+8BdyK6lj7OMQ== X-Google-Smtp-Source: AGHT+IGwLNmPezSWY+Ndz1NCn+pdSmxg63v6oMLzYQnADn6tvntpz+MVAazT5HgapdK5Tyz3MVY4 X-Received: by 2002:a17:902:c3c5:b0:1e5:3684:617e with SMTP id d9443c01a7336-1ef43f4d23emr245984615ad.52.1716110409143; Sun, 19 May 2024 02:20:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716110409; cv=pass; d=google.com; s=arc-20160816; b=Uf567UZTQKOOOgdWSsr0eJhOkvUkXJc+yGesev1tqk/0+ehr22bRrrpOms+7E5saBr 2QEOat/Ej/wo/JIqpqNQYdfbNBhSvgzGX7qdjd/X+3Q3JgrCwA1TgrD0lFY3meyyaoiO 9r5A6Lb3q5SJa/t4pClXfqaAIwBtiKt3aWlqW6PgPHOH/eof6PBn+0V5RDPtrdwGEoxm USAKtgrqzqMGzSzQXPdnMrqnCp8Etmlm/VypIezrBAO32QCe6icD0bikckDJU0HfYxLe IA0QEVXRR0qt+LabMx3n2zUhA4fw7E8hAX7QdwgdhlbLY9iDOy4yVMln7zRfld/S/1O6 MiQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=ZiwYqa/OT+egvt96+ug0V0xJ+qb/MMnvIJ/vMwb2q84=; fh=8LkL0RjtN6U0+2NvtfxCmLMvqVy6GJ2/ZKmSYz8X5Bc=; b=xorU6d2zbZaKLNN0/q8krT1xrisWi4oZ2AQ905Q/V4F0SEyRMGFfzmsxYU010/p5mK GXZOGDzha7KQ1lSwhmTH/R86MePxcvtaByH1uLt2B7C6+IIGZlucWhEn+GEuRXHtbE1P z2dnS7LIWJwvOA9kxirN63FMHSezVX4xcSBXnzXAk60lH1WzMoR9VYCJ2ba76QVasdqF jBGY0UHaHBvujXx4gEBLL3Pg3THPv7kk0NFGBVNsJQN/vDI4ctwVJwV5B9ZfhXSaUmDi H0xjslo+wnmJDrb0Kd8ZrkSgQJGggikpC3MtB69yCVa7mA5lrNulr0NEoreCnqTY8yhb nJmQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=Fwg2QKOm; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-183076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f2f51ac638si15443615ad.81.2024.05.19.02.20.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 02:20:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=Fwg2QKOm; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-183076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 005CBB20FA6 for ; Sun, 19 May 2024 09:19:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B1CDE38F87; Sun, 19 May 2024 09:19:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="Fwg2QKOm" Received: from smtp.smtpout.orange.fr (smtp-21.smtpout.orange.fr [80.12.242.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C19CC125; Sun, 19 May 2024 09:19:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.21 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716110380; cv=none; b=KxAm2z1uayq2t7cefKCxAQ0b3wZVD0MQvkt8o4SO6p4tGhOXk36DZ+bTdVyUVE+jKDkVGA+TAHMEPjEMCM4zUZXyvB0g8YIOm9y2rs9AnmzpxrQVqwBT0ZTk6S8+f8bHM1YkhlPv56GTG9TCB84/HXrptEYi5hvGQQjFWf8UFcM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716110380; c=relaxed/simple; bh=2Io+Fz92zJ104X+y+nqXRgFvu2MtCDcDNZhKBzNDC5E=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HlTqm7ne3SVbGwY+Vqhe/YliMdLZGhZ9+EyY4B5BIPSbyqmzc3vAaJz881EI5c0TpKLjicJa/cr5PNIiSPRJ0jTPBsDGjikB3/0pZZhwhYWG5PqEmO1vO/xTlASeHne6LsZeVlL0xJJWRJYuBw5V+KDRjPTjGu/JnH8onV2HqYo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=Fwg2QKOm; arc=none smtp.client-ip=80.12.242.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from localhost.localdomain ([86.243.17.157]) by smtp.orange.fr with ESMTPA id 8cYSsFC8hNQ4U8cYSspY8i; Sun, 19 May 2024 11:10:10 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1716109810; bh=ZiwYqa/OT+egvt96+ug0V0xJ+qb/MMnvIJ/vMwb2q84=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Fwg2QKOmzOVxipJAi1QrNN07ZhrxdXAZDJsyPMcP9DtpkEFUPxtXBpRk2xkAqvwkz rVaYBKpWurpPvr706qcDKnWpCc6dudb6EWXjESZSpzjlUr/uW1/ONwJHb9DhESSTQK 9mkuAvDOhMHVXLZ4JTLwdzUaNc2LaxmSDTv+7jx+ZhI36EJgOkVJq29ig3RP10BDao LIZ3f1GRX1jfan4mcTyNvRfxWOO7pjr5VY5dXRXXLAou+aJdYnP+f5UsXfnAoOfFjG G8uhXfYL/Hy7U/KqVMRsK0AeTaqeBwydUR/VkfbagFHmAn+F2nXSvUP+jr5Qf8fU6s mdzzUL+H1IN9Q== X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 19 May 2024 11:10:10 +0200 X-ME-IP: 86.243.17.157 From: Christophe JAILLET To: Ilya Dryomov , Xiubo Li , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , ceph-devel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 1/2 net-next] libceph: Use sruct_size() in ceph_create_snap_context() Date: Sun, 19 May 2024 11:09:58 +0200 Message-ID: <5b7c72bdb52703bbfa5511ed500aed4babde1308.1716109606.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use sruct_size() instead of hand-writing it. This makes the code more readable and safer. Signed-off-by: Christophe JAILLET --- 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