From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f193.google.com ([209.85.128.193]:35233 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932448AbeCHAT6 (ORCPT ); Wed, 7 Mar 2018 19:19:58 -0500 Received: by mail-wr0-f193.google.com with SMTP id l43so3962993wrc.2 for ; Wed, 07 Mar 2018 16:19:57 -0800 (PST) Date: Thu, 8 Mar 2018 01:19:53 +0100 From: Laszlo Toth To: "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , netdev@vger.kernel.org Subject: [PATCH] net: remove VLA usage Message-ID: <20180308001953.GA2190@laszlth> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: netdev-owner@vger.kernel.org List-ID: Separated snmp_seq_show_tcp_udp() to tcp and udp variants, so the usage of max_t() for the array size can be emitted. Signed-off-by: Laszlo Toth --- net/ipv4/proc.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index dc5edc8..67f7d76 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -46,8 +46,6 @@ #include #include -#define TCPUDP_MIB_MAX max_t(u32, UDP_MIB_MAX, TCP_MIB_MAX) - /* * Report socket allocation statistics [mea@utu.fi] */ @@ -398,13 +396,13 @@ static int snmp_seq_show_ipstats(struct seq_file *seq, void *v) return 0; } -static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) +static int snmp_seq_show_tcp(struct seq_file *seq, void *v) { - unsigned long buff[TCPUDP_MIB_MAX]; + unsigned long buff[TCP_MIB_MAX]; struct net *net = seq->private; int i; - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + memset(buff, 0, TCP_MIB_MAX * sizeof(unsigned long)); seq_puts(seq, "\nTcp:"); for (i = 0; snmp4_tcp_list[i].name; i++) @@ -421,7 +419,16 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) seq_printf(seq, " %lu", buff[i]); } - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + return 0; +} + +static int snmp_seq_show_udp(struct seq_file *seq, void *v) +{ + unsigned long buff[UDP_MIB_MAX]; + struct net *net = seq->private; + int i; + + memset(buff, 0, UDP_MIB_MAX * sizeof(unsigned long)); snmp_get_cpu_field_batch(buff, snmp4_udp_list, net->mib.udp_statistics); @@ -432,7 +439,7 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) for (i = 0; snmp4_udp_list[i].name; i++) seq_printf(seq, " %lu", buff[i]); - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + memset(buff, 0, UDP_MIB_MAX * sizeof(unsigned long)); /* the UDP and UDP-Lite MIBs are the same */ seq_puts(seq, "\nUdpLite:"); @@ -455,7 +462,8 @@ static int snmp_seq_show(struct seq_file *seq, void *v) icmp_put(seq); /* RFC 2011 compatibility */ icmpmsg_put(seq); - snmp_seq_show_tcp_udp(seq, v); + snmp_seq_show_tcp(seq, v); + snmp_seq_show_udp(seq, v); return 0; } -- 2.7.4