logo

oasis

Own branch of Oasis Linux (upstream: <https://git.sr.ht/~mcf/oasis/>) git clone https://anongit.hacktivis.me/git/oasis.git

0010-Use-alloca-instead-of-VLA-when-VLA-is-not-available.patch (1403B)


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