0010-Use-alloca-instead-of-VLA-when-VLA-is-not-available.patch (1403B)
- From e4114a995209c39d5a65aa2114d82b195ced17b2 Mon Sep 17 00:00:00 2001
- From: Michael Forney <mforney@mforney.org>
- Date: Mon, 24 Jun 2019 16:48:56 -0700
- Subject: [PATCH] Use alloca instead of VLA when VLA is not available
- ---
- ip/ipaddress.c | 14 ++++++++++++--
- 1 file changed, 12 insertions(+), 2 deletions(-)
- diff --git a/ip/ipaddress.c b/ip/ipaddress.c
- index 9f062217..3c195bb8 100644
- --- a/ip/ipaddress.c
- +++ b/ip/ipaddress.c
- @@ -245,7 +245,12 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
- lu = get_link_kind(kind);
- if (lu && lu->print_opt) {
- - struct rtattr *attr[lu->maxattr+1], **data = NULL;
- +#ifdef __STDC_NO_VLA__
- + struct rtattr **attr = alloca((lu->maxattr+1)*sizeof(attr[0]));
- +#else
- + struct rtattr *attr[lu->maxattr+1];
- +#endif
- + struct rtattr **data = NULL;
- if (linkinfo[IFLA_INFO_DATA]) {
- parse_rtattr_nested(attr, lu->maxattr,
- @@ -279,7 +284,12 @@ static void print_linktype(FILE *fp, struct rtattr *tb)
- slave_lu = get_link_kind(slave);
- if (slave_lu && slave_lu->print_opt) {
- - struct rtattr *attr[slave_lu->maxattr+1], **data = NULL;
- +#ifdef __STDC_NO_VLA__
- + struct rtattr **attr = alloca((slave_lu->maxattr+1)*sizeof(attr[0]));
- +#else
- + struct rtattr *attr[slave_lu->maxattr+1];
- +#endif
- + struct rtattr **data = NULL;
- if (linkinfo[IFLA_INFO_SLAVE_DATA]) {
- parse_rtattr_nested(attr, slave_lu->maxattr,
- --
- 2.44.0