Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing #include <sys/types.h> in ccan/ccan/fdpass/fdpass.c for compilation on FreeBSD #7758

Open
21M4TW opened this issue Oct 21, 2024 · 3 comments
Assignees

Comments

@21M4TW
Copy link

21M4TW commented Oct 21, 2024

Hi,

In order for ccan/ccan/fdpass/fdpass.c to compile on FreeBSD, sys/types.h must be included for u_long to be declared.

Thanks!

@vincenzopalazzo
Copy link
Contributor

It is possible to report the compilation stactrace?

Would be good for people that do not have access to Freebsd to patch there problem

@21M4TW
Copy link
Author

21M4TW commented Oct 21, 2024

It is possible to report the compilation stactrace?

Would be good for people that do not have access to Freebsd to patch there problem

Here we go

cc ccan/ccan/fdpass/fdpass.c
ccan/ccan/fdpass/fdpass.c:16:12: error: use of undeclared identifier 'u_long'; did you mean 'long'?
                char buf[CMSG_SPACE(sizeof(fd))];
                         ^
/usr/include/sys/socket.h:577:25: note: expanded from macro 'CMSG_SPACE'
#define CMSG_SPACE(l)           (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:16:12: error: use of undeclared identifier 'u_long'
/usr/include/sys/socket.h:577:25: note: expanded from macro 'CMSG_SPACE'
#define CMSG_SPACE(l)           (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:16:12: error: use of undeclared identifier 'u_long'; did you mean 'long'?
/usr/include/sys/socket.h:577:58: note: expanded from macro 'CMSG_SPACE'
#define CMSG_SPACE(l)           (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
                                                                  ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:16:12: error: use of undeclared identifier 'u_long'
/usr/include/sys/socket.h:577:58: note: expanded from macro 'CMSG_SPACE'
#define CMSG_SPACE(l)           (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
                                                                  ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:26:19: error: use of undeclared identifier 'u_long'; did you mean 'long'?
        cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
                         ^
/usr/include/sys/socket.h:578:23: note: expanded from macro 'CMSG_LEN'
#define CMSG_LEN(l)             (_ALIGN(sizeof(struct cmsghdr)) + (l))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:26:19: error: use of undeclared identifier 'u_long'
        cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
                         ^
/usr/include/sys/socket.h:578:23: note: expanded from macro 'CMSG_LEN'
#define CMSG_LEN(l)             (_ALIGN(sizeof(struct cmsghdr)) + (l))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:26:19: error: use of undeclared identifier 'u_long'
/usr/include/sys/socket.h:578:23: note: expanded from macro 'CMSG_LEN'
#define CMSG_LEN(l)             (_ALIGN(sizeof(struct cmsghdr)) + (l))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:27:9: error: use of undeclared identifier 'u_long'; did you mean 'long'?
        memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
               ^
/usr/include/sys/socket.h:554:6: note: expanded from macro 'CMSG_DATA'
                                 _ALIGN(sizeof(struct cmsghdr)))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:27:9: error: use of undeclared identifier 'u_long'
/usr/include/sys/socket.h:554:6: note: expanded from macro 'CMSG_DATA'
                                 _ALIGN(sizeof(struct cmsghdr)))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:53:12: error: use of undeclared identifier 'u_long'; did you mean 'long'?
                char buf[CMSG_SPACE(sizeof(fd))];
                         ^
/usr/include/sys/socket.h:577:25: note: expanded from macro 'CMSG_SPACE'
#define CMSG_SPACE(l)           (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:53:12: error: use of undeclared identifier 'u_long'
/usr/include/sys/socket.h:577:25: note: expanded from macro 'CMSG_SPACE'
#define CMSG_SPACE(l)           (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:53:12: error: use of undeclared identifier 'u_long'; did you mean 'long'?
/usr/include/sys/socket.h:577:58: note: expanded from macro 'CMSG_SPACE'
#define CMSG_SPACE(l)           (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l))
                                                                  ^                                                                                                                                                                    
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:74:27: error: use of undeclared identifier 'u_long'; did you mean 'long'?
            || cmsg->cmsg_len != CMSG_LEN(sizeof(fd))
                                 ^
/usr/include/sys/socket.h:578:23: note: expanded from macro 'CMSG_LEN'
#define CMSG_LEN(l)             (_ALIGN(sizeof(struct cmsghdr)) + (l))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:74:27: error: use of undeclared identifier 'u_long'
/usr/include/sys/socket.h:578:23: note: expanded from macro 'CMSG_LEN'
#define CMSG_LEN(l)             (_ALIGN(sizeof(struct cmsghdr)) + (l))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:81:14: error: use of undeclared identifier 'u_long'; did you mean 'long'?
        memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd));
                    ^
/usr/include/sys/socket.h:554:6: note: expanded from macro 'CMSG_DATA'
                                 _ALIGN(sizeof(struct cmsghdr)))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
ccan/ccan/fdpass/fdpass.c:81:14: error: use of undeclared identifier 'u_long'
/usr/include/sys/socket.h:554:6: note: expanded from macro 'CMSG_DATA'
                                 _ALIGN(sizeof(struct cmsghdr)))
                                 ^
/usr/include/machine/_align.h:45:22: note: expanded from macro '_ALIGN'
#define _ALIGN(p)       (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
                           ^
16 errors generated.
gmake: *** [Makefile:994: ccan-fdpass.o] Error 1


This is what I did to fix it:
diff --git a/ccan/ccan/fdpass/fdpass.c b/ccan/ccan/fdpass/fdpass.c
index 7331468f9..af1a7fdb9 100644
--- a/ccan/ccan/fdpass/fdpass.c
+++ b/ccan/ccan/fdpass/fdpass.c
@@ -3,6 +3,7 @@
 #include <sys/socket.h>
 #include <errno.h>
 #include <string.h>
+#include <sys/types.h>
 
 bool fdpass_send(int sockout, int fd)
 {

@grubles
Copy link
Contributor

grubles commented Feb 28, 2025

Hitting this with v25.02rc3 on ARM64 FreeBSD.

Can confirm the patch suggested above works:

diff --git a/ccan/ccan/fdpass/fdpass.c b/ccan/ccan/fdpass/fdpass.c
index 7331468f9..af1a7fdb9 100644
--- a/ccan/ccan/fdpass/fdpass.c
+++ b/ccan/ccan/fdpass/fdpass.c
@@ -3,6 +3,7 @@
 #include <sys/socket.h>
 #include <errno.h>
 #include <string.h>
+#include <sys/types.h>
 
 bool fdpass_send(int sockout, int fd)
 {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants