Skip to content

Commit

Permalink
ccan: fix compilation error about const types
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
vincenzopalazzo committed Dec 16, 2023
1 parent 09c1cfd commit 101dda6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ccan/ccan/fdpass/fdpass.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <errno.h>
#include <string.h>

#define BUF_SIZE CMSG_SPACE(sizeof(fd))

bool fdpass_send(int sockout, int fd)
{
/* From the cmsg(3) manpage: */
Expand All @@ -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;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 101dda6

Please sign in to comment.