Date: Fri, 17 May 2024 10:59:00 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 279054] Compile failure when #include <netlink/netlink_snl.h> in C++ code Message-ID: <bug-279054-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D279054 Bug ID: 279054 Summary: Compile failure when #include <netlink/netlink_snl.h> in C++ code Product: Base System Version: 14.0-STABLE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: misc Assignee: bugs@FreeBSD.org Reporter: cnbatch@gmail.com Both FreeBSD 14 and 15 generated the same errors.=20 C++ Codes: ``` #include <netlink/netlink_snl.h> int main() { snl_state st{}; return 0; } ``` Errors: In file included from main.cpp:1: /usr/include/netlink/netlink_snl.h:83:24: error: cannot initialize a variab= le of type 'struct linear_buffer *' with an rvalue of type 'void *' 83 | struct linear_buffer *lb =3D calloc(1, size); | ^ ~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:107:9: error: cannot initialize return object of type 'char *' with an lvalue of type 'void *' 107 | return (data); | ^~~~~~ /usr/include/netlink/netlink_snl.h:278:12: error: assigning to 'char *' from incompatible type 'void *' 278 | ss->buf =3D malloc(ss->bufsize); | ^~~~~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:498:2: error: no matching function for c= all to 'snl_parse_fields' 498 | snl_parse_fields(ss, hdr, parser->in_hdr_size, parser->fp, parser->fp_size, target); | ^~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:479:1: note: candidate function not viab= le: cannot convert argument of incomplete type 'void *' to 'struct nlmsghdr *' = for 2nd argument 479 | snl_parse_fields(struct snl_state *ss, struct nlmsghdr *hdr, int hd= rlen __unused, | ^ ~~~~~~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:619:8: error: cannot initialize a variab= le of type 'char *' with an rvalue of type 'void *' 619 | char *buf =3D snl_allocz(ss, maxlen + 1); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:636:3: error: no matching function for c= all to 'strlcpy' 636 | strlcpy(target, tmp, (size_t)arg); | ^~~~~~~ /usr/include/string.h:98:9: note: candidate function not viable: cannot con= vert argument of incomplete type 'void *' to 'char *__restrict' for 1st argument 98 | size_t strlcpy(char * __restrict, const char * __restrict, size_t= ); | ^ ~~~~~~ In file included from main.cpp:1: /usr/include/netlink/netlink_snl.h:649:9: error: cannot initialize a variab= le of type 'char *' with an rvalue of type 'void *' 649 | char *buf =3D snl_allocz(ss, maxlen); | ^ ~~~~~~~~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:678:21: error: cannot initialize a varia= ble of type 'struct snl_parray *' with an lvalue of type 'void *' 678 | struct snl_parray *array =3D target; | ^ ~~~~~~ /usr/include/netlink/netlink_snl.h:685:17: error: assigning to 'void **' fr= om incompatible type 'void *' 685 | array->items =3D snl_allocz(ss, size * sizeof(void *)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:701:2: error: assigning to 'struct nlatt= r *' from incompatible type 'void *' 701 | NLA_FOREACH(nla, NLA_DATA(container_nla), NLA_DATA_LEN(container_nla)) { |=20=20=20=20=20=20=20=20 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:66:22: note: expanded from macro 'NLA_FOREACH' 66 | for (_attr =3D (_start); \ | ^~~~~~~~ /usr/include/netlink/netlink_snl.h:715:11: error: cannot initialize a varia= ble of type 'void **' with an rvalue of type 'void *' 715 | void **new_array =3D snl_allocz(ss, new_size *sizeof(void *)); | ^=20=20=20=20=20=20=20=20=20=20 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:828:26: error: cannot initialize a varia= ble of type 'struct snl_attr_bitset *' with an lvalue of type 'void *' 828 | struct snl_attr_bitset *target =3D _target; | ^ ~~~~~~~ /usr/include/netlink/netlink_snl.h:864:26: error: cannot initialize a varia= ble of type 'struct snl_attr_bitset *' with an lvalue of type 'void *' 864 | struct snl_attr_bitset *target =3D _target; | ^ ~~~~~~~ /usr/include/netlink/netlink_snl.h:984:11: error: no matching function for = call to 'snl_parse_attrs_raw' 984 | return (snl_parse_attrs_raw(ss, data, len, ps->np, ps->np_size, attrs)); | ^~~~~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:448:1: note: candidate function not viab= le: cannot convert argument of incomplete type 'void *' to 'struct nlattr *' for 2nd argument 448 | snl_parse_attrs_raw(struct snl_state *ss, struct nlattr *nla_head, = int len, | ^ ~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:1026:13: error: assigning to 'char *' fr= om incompatible type 'void *' 1026 | nw->base =3D snl_allocz(ss, nw->size); | ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/netlink/netlink_snl.h:1064:14: error: assigning to 'char *' fr= om incompatible type 'void *' 1064 | nw->base =3D new_base; | ^~~~~~~~ 16 errors generated. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-279054-227>