Re: [PATCH] s6-ps: fix compilation on clang

2018-09-27 Thread Laurent Bercot

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


 Ah, yes. I didn't catch this one because my only clang test
machine is a FreeBSD, which s6-linux-utils obviously doesn't
build on. I'll add a linux/clang build somewhere.
Thanks for the report, will apply this weekend or something.
I should use the opportunity to change the avltreeb API so the
problem is fixed everywhere.

--
 Laurent



[PATCH] s6-ps: fix compilation on clang

2018-09-27 Thread John Regan
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
@@ -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