From 101dda690541c7c48ffa11813b762c054d45e08c Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Sat, 16 Dec 2023 10:41:01 +0100 Subject: [PATCH] ccan: fix compilation error about const types This commit fixes the following build error ccan/ccan/fdpass/fdpass.c:16:8: error: variable length array folded to constant array as an extension [-Werror,-Wgnu-folding-constant] char buf[CMSG_SPACE(sizeof(fd))]; This is strange from a UNIX proxpective because the macros return a size_t and the size_t is a unsigned integer type that should be compatible with the array declaration. But for some plaform/or compiler this looks like not true? Signed-off-by: Vincenzo Palazzo --- ccan/ccan/fdpass/fdpass.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ccan/ccan/fdpass/fdpass.c b/ccan/ccan/fdpass/fdpass.c index 7331468f98f5..5ab19ef45e33 100644 --- a/ccan/ccan/fdpass/fdpass.c +++ b/ccan/ccan/fdpass/fdpass.c @@ -4,6 +4,8 @@ #include #include +#define BUF_SIZE CMSG_SPACE(sizeof(fd)) + bool fdpass_send(int sockout, int fd) { /* From the cmsg(3) manpage: */ @@ -13,7 +15,7 @@ bool fdpass_send(int sockout, int fd) char c = 0; union { /* Ancillary data buffer, wrapped in a union in order to ensure it is suitably aligned */ - char buf[CMSG_SPACE(sizeof(fd))]; + char buf[BUF_SIZE]; struct cmsghdr align; } u; @@ -50,7 +52,7 @@ int fdpass_recv(int sockin) char c; union { /* Ancillary data buffer, wrapped in a union in order to ensure it is suitably aligned */ - char buf[CMSG_SPACE(sizeof(fd))]; + char buf[BUF_SIZE]; struct cmsghdr align; } u;