Skip to content

Commit 2806549

Browse files
hormsummakynes
authored andcommitted
ipvs: Consistently use array_size() in ip_vs_conn_init()
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 <[email protected]> Reviewed-by: Horatiu Vultur <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent e3478c6 commit 2806549

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

net/netfilter/ipvs/ip_vs_conn.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,7 @@ void __net_exit ip_vs_conn_net_cleanup(struct netns_ipvs *ipvs)
14811481

14821482
int __init ip_vs_conn_init(void)
14831483
{
1484+
size_t tab_array_size;
14841485
int idx;
14851486

14861487
/* Compute size and mask */
@@ -1494,8 +1495,9 @@ int __init ip_vs_conn_init(void)
14941495
/*
14951496
* Allocate the connection hash table and initialize its list heads
14961497
*/
1497-
ip_vs_conn_tab = vmalloc(array_size(ip_vs_conn_tab_size,
1498-
sizeof(*ip_vs_conn_tab)));
1498+
tab_array_size = array_size(ip_vs_conn_tab_size,
1499+
sizeof(*ip_vs_conn_tab));
1500+
ip_vs_conn_tab = vmalloc(tab_array_size);
14991501
if (!ip_vs_conn_tab)
15001502
return -ENOMEM;
15011503

@@ -1508,10 +1510,8 @@ int __init ip_vs_conn_init(void)
15081510
return -ENOMEM;
15091511
}
15101512

1511-
pr_info("Connection hash table configured "
1512-
"(size=%d, memory=%ldKbytes)\n",
1513-
ip_vs_conn_tab_size,
1514-
(long)(ip_vs_conn_tab_size*sizeof(*ip_vs_conn_tab))/1024);
1513+
pr_info("Connection hash table configured (size=%d, memory=%zdKbytes)\n",
1514+
ip_vs_conn_tab_size, tab_array_size / 1024);
15151515
IP_VS_DBG(0, "Each connection entry needs %zd bytes at least\n",
15161516
sizeof(struct ip_vs_conn));
15171517

0 commit comments

Comments
 (0)