Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5115068rwl; Tue, 11 Apr 2023 00:14:03 -0700 (PDT) X-Google-Smtp-Source: AKy350b/EpOeRJG6TyWHw1I4mtGip/4pP9xZmN9IPLaUmsE3Decr8tHHsoEKD7j6686r0TvTxYFk X-Received: by 2002:a17:903:41c5:b0:1a5:180d:c317 with SMTP id u5-20020a17090341c500b001a5180dc317mr16884954ple.43.1681197242829; Tue, 11 Apr 2023 00:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681197242; cv=none; d=google.com; s=arc-20160816; b=ReIM2m0jZoo4Ty4yuFsBlE2WbMcewvvEef4AhZn+4jKwHIE8c+EmJo0tBUCTCkemYU CIYJ1GL+Nc91bIN4IlRLuHdMFccRe4WZfOCYvm8yfeLHZYwmbE7Eul9wvJTBexDuI+k1 Yfa+Nr4MjCXdBC8Z1xVS/UALFUU8HFyNZ5pIhCLw6RbjX4hRUCTBeDWiHVKSJsa6Y983 jNwueL0LmDDNWfdPb7krZ4Kry8pmurONFiGUG5fk6utzSOxOlRtg3YQBCAqg84pfLX0C WMWUsHbcFRAdSn4+EIrWw/XRKxZPLQd5V5Sz+Loc+c0wc+lqCNda2xYGwHNHnbUJ5AE2 EqZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=twBJzZ5sXX0WNW8nCx/MrDWE4nuVx9hec7idwJTxyFY=; b=otEqj8/nAe2qIqWiKZ7hQinaZ03cTvLLCYO5HiJ0Tri4UxG8q/ZUQPaAl7FopEADLC xDI2HK2GytJC66abBsL8fAx4Gf2XFYl/CxnQY2cz+llBlJirLNBDqamBPHSRpYxVW/HA djwCi74mOgaGi+hfcPIlaFWkvrnaFNK9K5d25uzMKq0KpnWmQWyTVRntUPaq++8Wr0yb a59jHGed8vvYdiWwMYjvFHEihC8OwV8Ic4pLNHx6ejWSbg/ir3RgaGLAx40ZjCp+qqIL 1ceWeLIxOkcreci9mNEJCtokmWscNZ2s7CPFuLShD+SHj3bxCQYiujKlK4iX7xQTp1ur Bvxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uih8j8Xi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t17-20020a170902d29100b001a51634cab9si9770495plc.547.2023.04.11.00.13.51; Tue, 11 Apr 2023 00:14:02 -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=@kernel.org header.s=k20201202 header.b=uih8j8Xi; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbjDKHK6 (ORCPT + 99 others); Tue, 11 Apr 2023 03:10:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230071AbjDKHKz (ORCPT ); Tue, 11 Apr 2023 03:10:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CAB22D66; Tue, 11 Apr 2023 00:10:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B81CE6223F; Tue, 11 Apr 2023 07:10:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3F59C4339E; Tue, 11 Apr 2023 07:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681197053; bh=MCcu2L3rtcfTV+OZljKLRwOcSdgy7kjk2D3O8GnMt4s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uih8j8Xibt5ZIW9rOv4ApSnJC434b/7Q39A6DJF9HYTM34gKgqiDpX2IgNa6Akaxp w9WX1uuGTBlZ7TjUa0apjlkJqIOapsQ+AtcCBFDkgwNa0cnPYB4X4wOEbS5SJdApSi Cj+kGWhtx3L5iiOtkILAO8wU7dbVG5On1ZKD/6OFkgntI9CpX71eaTzAxT3uZYuKJ4 56r7cJJCPfMso1XY8YDqyBlvs9DUwbfg+Q+kuVsCJ8NpjXxtV/gZr1eBKNIG+IGJcP 0QbDw1e8VJNOgscydiv01YJKwui2AcphZUbW1a2rNdI3pGcikt7lE+iY6Fk+UHGxDF G6MzwYpwWXxtw== From: Simon Horman Date: Tue, 11 Apr 2023 09:10:40 +0200 Subject: [PATCH nf-next v2 2/4] ipvs: Consistently use array_size() in ip_vs_conn_init() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230409-ipvs-cleanup-v2-2-204cd17da708@kernel.org> References: <20230409-ipvs-cleanup-v2-0-204cd17da708@kernel.org> In-Reply-To: <20230409-ipvs-cleanup-v2-0-204cd17da708@kernel.org> To: Julian Anastasov Cc: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , netdev@vger.kernel.org, "David S. Miller" , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , lvs-devel@vger.kernel.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 Consistently use array_size() to calculate the size of ip_vs_conn_tab in bytes. Flagged by Coccinelle: WARNING: array_size is already used (line 1498) to compute the same size No functional change intended. Compile tested only. Signed-off-by: Simon Horman --- v2 * Retain division by 1024, which was lost in v1 --- net/netfilter/ipvs/ip_vs_conn.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index 13534e02346c..84d273a84dc8 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c @@ -1481,6 +1481,7 @@ void __net_exit ip_vs_conn_net_cleanup(struct netns_ipvs *ipvs) int __init ip_vs_conn_init(void) { + size_t tab_array_size; int idx; /* Compute size and mask */ @@ -1494,8 +1495,9 @@ int __init ip_vs_conn_init(void) /* * Allocate the connection hash table and initialize its list heads */ - ip_vs_conn_tab = vmalloc(array_size(ip_vs_conn_tab_size, - sizeof(*ip_vs_conn_tab))); + tab_array_size = array_size(ip_vs_conn_tab_size, + sizeof(*ip_vs_conn_tab)); + ip_vs_conn_tab = vmalloc(tab_array_size); if (!ip_vs_conn_tab) return -ENOMEM; @@ -1508,10 +1510,8 @@ int __init ip_vs_conn_init(void) return -ENOMEM; } - pr_info("Connection hash table configured " - "(size=%d, memory=%ldKbytes)\n", - ip_vs_conn_tab_size, - (long)(ip_vs_conn_tab_size*sizeof(*ip_vs_conn_tab))/1024); + pr_info("Connection hash table configured (size=%d, memory=%zdKbytes)\n", + ip_vs_conn_tab_size / 1024, tab_array_size); IP_VS_DBG(0, "Each connection entry needs %zd bytes at least\n", sizeof(struct ip_vs_conn)); -- 2.30.2