[PATCH] s6-ps: fix compilation on clang

From: John Regan <john_at_jrjrtech.com>
Date: Thu, 27 Sep 2018 09:46:43 -0400

s6-ps fails to compile under clang due to using a variable
length array in a structure. This is gcc-specific behavior.

This patch instead creates variable-length arrays, then a
structure with references to those variable-length arrays.
---
 src/minutils/s6-ps.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/minutils/s6-ps.c b/src/minutils/s6-ps.c
index bba973b..28a7898 100644
--- a/src/minutils/s6-ps.c
+++ b/src/minutils/s6-ps.c
_at_@ -286,7 +286,15 @@ int main (int argc, char const *const *argv)
     /* Order the processes for display */
 
     {
-      AVLTREEB_TYPE(n+1) pidtree ;
+      avlnode storage[n+1] ;
+      uint32_t freelist[n+1] ;
+
+      struct {
+        avlnode *storage ;
+        uint32_t *freelist ;
+        avltreen info ;
+      } pidtree = { .storage = storage, .freelist = freelist } ;
+
       avltreeb_init(&pidtree, n+1, &pid_dtok, &uint32_cmp, p) ;
       for (i = 0 ; i < n ; i++)
       {
-- 
1.8.3.1
Received on Thu Sep 27 2018 - 13:46:43 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC