master hovercats/oakiss / pkg / iproute2 / patch / 0010-Use-alloca-instead-of-VLA-when-VLA-is-not-available.patch
 1From e4114a995209c39d5a65aa2114d82b195ced17b2 Mon Sep 17 00:00:00 2001
 2From: Michael Forney <mforney@mforney.org>
 3Date: Mon, 24 Jun 2019 16:48:56 -0700
 4Subject: [PATCH] Use alloca instead of VLA when VLA is not available
 5
 6---
 7 ip/ipaddress.c | 14 ++++++++++++--
 8 1 file changed, 12 insertions(+), 2 deletions(-)
 9
10diff --git a/ip/ipaddress.c b/ip/ipaddress.c
11index 9f062217..3c195bb8 100644
12--- a/ip/ipaddress.c
13+++ b/ip/ipaddress.c
14@@ -245,7 +245,12 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
15 
16 		lu = get_link_kind(kind);
17 		if (lu && lu->print_opt) {
18-			struct rtattr *attr[lu->maxattr+1], **data = NULL;
19+#ifdef __STDC_NO_VLA__
20+			struct rtattr **attr = alloca((lu->maxattr+1)*sizeof(attr[0]));
21+#else
22+			struct rtattr *attr[lu->maxattr+1];
23+#endif
24+			struct rtattr **data = NULL;
25 
26 			if (linkinfo[IFLA_INFO_DATA]) {
27 				parse_rtattr_nested(attr, lu->maxattr,
28@@ -279,7 +284,12 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
29 
30 		slave_lu = get_link_kind(slave);
31 		if (slave_lu && slave_lu->print_opt) {
32-			struct rtattr *attr[slave_lu->maxattr+1], **data = NULL;
33+#ifdef __STDC_NO_VLA__
34+			struct rtattr **attr = alloca((slave_lu->maxattr+1)*sizeof(attr[0]));
35+#else
36+			struct rtattr *attr[slave_lu->maxattr+1];
37+#endif
38+			struct rtattr **data = NULL;
39 
40 			if (linkinfo[IFLA_INFO_SLAVE_DATA]) {
41 				parse_rtattr_nested(attr, slave_lu->maxattr,
42-- 
432.44.0
44