From patchwork Sat May 6 16:04:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 90780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1135289vqo; Sat, 6 May 2023 09:08:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ukbtHbdgG6aiJb9fiZwHSUc3rqUeqQ1T6nKXQE6ZK5HjI1TeaJ1VGSx34yj7SNKjCNQ3w X-Received: by 2002:a05:6a21:168f:b0:ef:7d7b:433a with SMTP id np15-20020a056a21168f00b000ef7d7b433amr5285843pzb.47.1683389300943; Sat, 06 May 2023 09:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683389300; cv=none; d=google.com; s=arc-20160816; b=V4RMiMa4wgFiugrJEWF8aNq3BSFN3iMMF3D4oic9NEXsp1OZVPzeeyuOqGqswTtLBO 3KmRns3yAFNKJ6ebdE1exUaeNGa5MSWGiDZd7M0ZD6P4lZ5aaOgN5o/+kwaYLzd39VTD p4SDxRl/izX9xmqyo8lpE0ubFxZohg7mpxY/cBXtjv0+4JmWXNqCyg2m0T/EQRi7ZHPh jrS8BRiV5bZX5eusXFmnYKuBHkbC7n/KbuFbzHEcXT4CYvvWVDD0Xx8W6cSHR/JxtiTx dcU+mDHvO6KBzeksz+/Ub3yUadcMYD33XMAAL8WDrVN6JV+RGftyYecCCE5Hq7za8+lR d1cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=0FotBQHha+qZRI5XXIk6G0iRigNGwWlnzMiCXh1rLH4=; b=kwJ4MJmc+uaegZ+X64/vmnpNdmKzZVukyiokfKV6rzZJf19BirXSEO03sdQrE121hh gY1A8s6MXprX69ZaFcWrSk84O9NsA28m3h1b4WekO/pGjMwf3gzJ5u15RBsnX2fIXzCw DdTuYNpQkaXel3zn19S/58/0LAWVnf1cCaOE0nDVuvpoL3RG/FnUrbJuw2WOV9xsBhhb OR7tQVAbGxo6c895ksyTblBeznnVYtGMOWI67d/xcMseimOCu6L/BFyk/UdM6+8trqS3 IzmuctBCUoljIu0WzFV+sK7EX+e+Uvq0PcMnnbCd/Dh/rmrJwn+Nktc53ieB/MjhRUKT cTgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=hzhoxFp4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020aa79d82000000b0063f24efaf7bsi4470566pfq.390.2023.05.06.09.08.05; Sat, 06 May 2023 09:08:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=hzhoxFp4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229446AbjEFQEZ (ORCPT + 99 others); Sat, 6 May 2023 12:04:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjEFQEX (ORCPT ); Sat, 6 May 2023 12:04:23 -0400 Received: from smtp.smtpout.orange.fr (smtp-12.smtpout.orange.fr [80.12.242.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7B3510DE for ; Sat, 6 May 2023 09:04:21 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id vKOPpaWk2Mk9uvKOQpAa5h; Sat, 06 May 2023 18:04:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1683389060; bh=0FotBQHha+qZRI5XXIk6G0iRigNGwWlnzMiCXh1rLH4=; h=From:To:Cc:Subject:Date; b=hzhoxFp4qyXukAuHJwGCYHcARfYcqtaflHFyYmnwCigie8I9Dkr0YB30gX/hsHSDH 82HIL/wNNcR/7rkugu9UBXo4MG0m+SFLSc/luFK5VbaQzEqA6fnbEUwvVBcqKu+eSQ FsaUvN9pb0a311jkTEzOvsokL9rtmSS6VNoslvbPgEeMx1PVIjJhepH3BqegU5+TKA RH7zhU2aND9zTSbmOi38vS3auJLVG/tdPEg2wceGnLS1Jh3TKzgQVrQgApvUvAFHMA p/XH7iws/UBPoiW5cZmJun5f2YIZ+pZME0lKx4ast4MF3UZg51mUydDGsqpZ2q6bqC 2vGIF8YaYvSDQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 06 May 2023 18:04:20 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Pravin B Shelar , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org, dev@openvswitch.org Subject: [PATCH net-next] net: openvswitch: Use struct_size() Date: Sat, 6 May 2023 18:04:16 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765161619866611502?= X-GMAIL-MSGID: =?utf-8?q?1765161619866611502?= Use struct_size() instead of hand writing it. This is less verbose and more informative. Signed-off-by: Christophe JAILLET Acked-by: Eelco Chaudron --- It will also help scripts when __counted_by macro will be added. See [1]. [1]: https://lore.kernel.org/all/6453f739.170a0220.62695.7785@mx.google.com/ --- net/openvswitch/meter.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c index f2698d2316df..c4ebf810e4b1 100644 --- a/net/openvswitch/meter.c +++ b/net/openvswitch/meter.c @@ -69,9 +69,7 @@ static struct dp_meter_instance *dp_meter_instance_alloc(const u32 size) { struct dp_meter_instance *ti; - ti = kvzalloc(sizeof(*ti) + - sizeof(struct dp_meter *) * size, - GFP_KERNEL); + ti = kvzalloc(struct_size(ti, dp_meters, size), GFP_KERNEL); if (!ti) return NULL;