From nobody Wed Jun 12 21:55:22 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Vzzqb2Dkmz5NXSS; Wed, 12 Jun 2024 21:55:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Vzzqb0PTRz4Q0j; Wed, 12 Jun 2024 21:55:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718229323; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=P4m+/GAfadgXjNvhqq7S2lpAMnul8meoufl/ogIm5SI=; b=bgM4EyoT94ji2Iq4DX0epxjnYeN0Kf3OBlmFigC6V7RXeJQwMlV6u7G6AvaUqJQ1IJBLBa T0eKkGlJz5g4FoElb+4pcrmlOoLxfM8E2Yrv1IVaLKrDNI1w594IwPOltYBcQJQ1+BDKa0 k6MFGPg5zMAv+bpDk7fe2Hr10jGQ+S9Fx2DpORiqcBN2kHKsUn28Pr+QKVqjsVPP3mUEj/ VQdcUm9hp339cXE39GPmShtdPKnKWDJJ9OsdssxyCotKK0MYohhZWELYAXAt9VjnR7GZwy hT1jZ7i9V+/O3ScpyUQkuy14pCSls6AreUb6JJFu1do+wqA6/t6uO8he0kRUdQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718229323; a=rsa-sha256; cv=none; b=WjaYaRQS1zdrEl45i9U001O4/ZQVwIjSbyUPLAk8tNXdu99pz43wkwLglz4aLwOPSOgtTi 15+/3wkav2JU8FosJbxyuhWtYhFf1o2KfNotIlh8e0rD/8r6ECw4Etd0b5Ooipqlp4E6GF gyFgoSF98eRtsBDiwvt58NEj6J3iIwpsGzYCCe0CjLwfnK40EY5xHz5Nfyqn1gKGAf+c/D to9YCWiADQecKlx3BuoGdWhI04oqrnI3Qym3QeW99kRux85e13L3an9bi52ZN85Lx4BNTu 5Lq1TVWiyavDyADL3PONrbXJyekUpXD4/2pq/2PVZeAXQnKBv2nGZqJnX++uBA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718229323; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=P4m+/GAfadgXjNvhqq7S2lpAMnul8meoufl/ogIm5SI=; b=bE/acnY62tWShTgmfQMe1YGC1udoJBQMwz1r/q6NxinNlL1U6vz0hdSxOpRNPKMjEMVAtd Y0YP+LZp/6JqeY1BpZYB/6Dxs0eXM3p+hioOolsjesAYXNRtTHsjK163EHcg4C1zipnGzr fUCmcqEOmvY63p2j8a7I+rpsfyJNPmkq6DyKRHgusQkMNsF0xwE7GJO/CjjN/tu7+K6/5E AxbLoHcZGlgqcL/AXC6kYjZ7PRDSyc9HPvVqdvxRIMlwyIAUpVJ1en3zEQ7bgDl4tlYHqI sLaPibMOyg6s4iGF5j/FN8y0naia9YvWpn4fsCrggK9KQu8UkwKKNZpGo4CLlA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Vzzqb01hMz199n; Wed, 12 Jun 2024 21:55:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45CLtMV6075407; Wed, 12 Jun 2024 21:55:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45CLtMjV075404; Wed, 12 Jun 2024 21:55:22 GMT (envelope-from git) Date: Wed, 12 Jun 2024 21:55:22 GMT Message-Id: <202406122155.45CLtMjV075404@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 484c2ce9752f - stable/14 - netlink: Fix C++ compile errors List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 484c2ce9752f610ab082a002341a290d683b8343 Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=484c2ce9752f610ab082a002341a290d683b8343 commit 484c2ce9752f610ab082a002341a290d683b8343 Author: cnbatch AuthorDate: 2024-05-17 13:09:44 +0000 Commit: Warner Losh CommitDate: 2024-06-12 21:46:24 +0000 netlink: Fix C++ compile errors Allow these files to be included in C++ programs with careful casting to the proper type, like C++ wants (and in a way that also works for C). MFC After: 1 week Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1245 (cherry picked from commit ff92493a4f6504c49a6c84ec65053f493ff5d708) --- sys/netlink/netlink_snl.h | 33 +++++++++++++++++---------------- sys/netlink/netlink_snl_route.h | 2 +- sys/netlink/netlink_snl_route_parsers.h | 10 +++++----- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/sys/netlink/netlink_snl.h b/sys/netlink/netlink_snl.h index f8387132f78a..03f2b7dc5c38 100644 --- a/sys/netlink/netlink_snl.h +++ b/sys/netlink/netlink_snl.h @@ -63,7 +63,7 @@ #define _NLA_END(_start, _len) ((char *)(_start) + (_len)) #define NLA_FOREACH(_attr, _start, _len) \ - for (_attr = (_start); \ + for (_attr = (struct nlattr *)(_start); \ ((char *)_attr < _NLA_END(_start, _len)) && \ ((char *)NLA_NEXT(_attr) <= _NLA_END(_start, _len)); \ _attr = NLA_NEXT(_attr)) @@ -80,7 +80,7 @@ struct linear_buffer { static inline struct linear_buffer * lb_init(uint32_t size) { - struct linear_buffer *lb = calloc(1, size); + struct linear_buffer *lb = (struct linear_buffer *)calloc(1, size); if (lb != NULL) { lb->base = (char *)(lb + 1); @@ -102,7 +102,7 @@ lb_allocz(struct linear_buffer *lb, int len) len = roundup2(len, alignof(__max_align_t)); if (lb->offset + len > lb->size) return (NULL); - void *data = (void *)(lb->base + lb->offset); + char *data = (lb->base + lb->offset); lb->offset += len; return (data); } @@ -275,7 +275,7 @@ snl_init(struct snl_state *ss, int netlink_family) } ss->bufsize = rcvbuf; - ss->buf = malloc(ss->bufsize); + ss->buf = (char *)malloc(ss->bufsize); if (ss->buf == NULL) { snl_free(ss); return (false); @@ -495,7 +495,8 @@ snl_parse_header(struct snl_state *ss, void *hdr, int len, struct nlattr *nla_head; /* Extract fields first (if any) */ - snl_parse_fields(ss, hdr, parser->in_hdr_size, parser->fp, parser->fp_size, target); + snl_parse_fields(ss, (struct nlmsghdr *)hdr, parser->in_hdr_size, + parser->fp, parser->fp_size, target); nla_head = (struct nlattr *)(void *)((char *)hdr + parser->in_hdr_size); bool result = snl_parse_attrs_raw(ss, nla_head, len - parser->in_hdr_size, @@ -616,7 +617,7 @@ snl_attr_get_stringn(struct snl_state *ss, struct nlattr *nla, { int maxlen = NLA_DATA_LEN(nla); - char *buf = snl_allocz(ss, maxlen + 1); + char *buf = (char *)snl_allocz(ss, maxlen + 1); if (buf == NULL) return (false); buf[maxlen] = '\0'; @@ -633,7 +634,7 @@ snl_attr_copy_string(struct snl_state *ss, struct nlattr *nla, char *tmp; if (snl_attr_get_string(ss, nla, NULL, &tmp)) { - strlcpy(target, tmp, (size_t)arg); + strlcpy((char *)target, tmp, (size_t)arg); return (true); } return (false); @@ -646,7 +647,7 @@ snl_attr_dup_string(struct snl_state *ss __unused, struct nlattr *nla, size_t maxlen = NLA_DATA_LEN(nla); if (strnlen((char *)NLA_DATA(nla), maxlen) < maxlen) { - char *buf = snl_allocz(ss, maxlen); + char *buf = (char *)snl_allocz(ss, maxlen); if (buf == NULL) return (false); memcpy(buf, NLA_DATA(nla), maxlen); @@ -675,14 +676,14 @@ snl_attr_get_parray_sz(struct snl_state *ss, struct nlattr *container_nla, uint32_t start_size, const void *arg, void *target) { const struct snl_hdr_parser *p = (const struct snl_hdr_parser *)arg; - struct snl_parray *array = target; + struct snl_parray *array = (struct snl_parray *)target; struct nlattr *nla; uint32_t count = 0, size = start_size; if (p->out_size == 0) return (false); - array->items = snl_allocz(ss, size * sizeof(void *)); + array->items = (void **)snl_allocz(ss, size * sizeof(void *)); if (array->items == NULL) return (false); @@ -712,7 +713,7 @@ snl_attr_get_parray_sz(struct snl_state *ss, struct nlattr *container_nla, if (count == size) { uint32_t new_size = size * 2; - void **new_array = snl_allocz(ss, new_size *sizeof(void *)); + void **new_array = (void **)snl_allocz(ss, new_size *sizeof(void *)); memcpy(new_array, array->items, size * sizeof(void *)); array->items = new_array; @@ -825,7 +826,7 @@ static const struct snl_attr_parser _nla_p_bitset[] = { static inline bool _cb_p_bitset(struct snl_state *ss __unused, void *_target) { - struct snl_attr_bitset *target = _target; + struct snl_attr_bitset *target = (struct snl_attr_bitset *)_target; uint32_t sz_bytes = _roundup2(target->nla_bitset_size, 32) / 8; @@ -861,7 +862,7 @@ snl_attr_get_bitset_c(struct snl_state *ss, struct nlattr *nla, const void *arg __unused, void *_target) { const struct snl_hdr_parser *p = &_nla_bitset_parser; - struct snl_attr_bitset *target = _target; + struct snl_attr_bitset *target = (struct snl_attr_bitset *)_target; /* Assumes target points to the beginning of the structure */ if (!snl_parse_header(ss, NLA_DATA(nla), NLA_DATA_LEN(nla), p, _target)) @@ -981,7 +982,7 @@ parse_cmsg(struct snl_state *ss, const struct msghdr *msg, struct snl_msg_info * int len = cmsg->cmsg_len - ((char *)data - (char *)cmsg); const struct snl_hdr_parser *ps = &snl_msg_info_parser; - return (snl_parse_attrs_raw(ss, data, len, ps->np, ps->np_size, attrs)); + return (snl_parse_attrs_raw(ss, (struct nlattr *)data, len, ps->np, ps->np_size, attrs)); } return (false); @@ -1023,7 +1024,7 @@ static inline void snl_init_writer(struct snl_state *ss, struct snl_writer *nw) { nw->size = SNL_WRITER_BUFFER_SIZE; - nw->base = snl_allocz(ss, nw->size); + nw->base = (char *)snl_allocz(ss, nw->size); if (nw->base == NULL) { nw->error = true; nw->size = 0; @@ -1061,7 +1062,7 @@ snl_realloc_msg_buffer(struct snl_writer *nw, size_t sz) nw->hdr = (struct nlmsghdr *) (void *)((char *)new_base + hdr_off); } - nw->base = new_base; + nw->base = (char *)new_base; } return (true); diff --git a/sys/netlink/netlink_snl_route.h b/sys/netlink/netlink_snl_route.h index 619e769b1496..62055b2db417 100644 --- a/sys/netlink/netlink_snl_route.h +++ b/sys/netlink/netlink_snl_route.h @@ -100,7 +100,7 @@ snl_attr_get_ip(struct snl_state *ss, struct nlattr *nla, static inline struct sockaddr * parse_rta_via(struct snl_state *ss, struct rtattr *rta, int *perror) { - struct rtvia *via = NL_RTA_DATA(rta); + struct rtvia *via = (struct rtvia *)NL_RTA_DATA(rta); switch (via->rtvia_family) { case AF_INET: diff --git a/sys/netlink/netlink_snl_route_parsers.h b/sys/netlink/netlink_snl_route_parsers.h index 7e4bcad4010b..256edfec297d 100644 --- a/sys/netlink/netlink_snl_route_parsers.h +++ b/sys/netlink/netlink_snl_route_parsers.h @@ -78,7 +78,7 @@ static const struct snl_field_parser _fp_p_mp_nh[] = { static inline bool _cb_p_mp_nh(struct snl_state *ss __unused, void *_target) { - struct rta_mpath_nh *target = _target; + struct rta_mpath_nh *target = (struct rta_mpath_nh *)_target; finalize_sockaddr(target->gw, target->ifindex); return (true); @@ -158,7 +158,7 @@ static const struct snl_field_parser _fp_p_route[] = { static inline bool _cb_p_route(struct snl_state *ss __unused, void *_target) { - struct snl_parsed_route *target = _target; + struct snl_parsed_route *target = (struct snl_parsed_route *)_target; finalize_sockaddr(target->rta_dst, target->rta_oif); finalize_sockaddr(target->rta_gw, target->rta_oif); @@ -277,7 +277,7 @@ static struct snl_field_parser _fp_p_neigh_s[] = { static inline bool _cb_p_neigh(struct snl_state *ss __unused, void *_target) { - struct snl_parsed_neigh *target = _target; + struct snl_parsed_neigh *target = (struct snl_parsed_neigh *)_target; finalize_sockaddr(target->nda_dst, target->nda_ifindex); return (true); @@ -326,7 +326,7 @@ static const struct snl_field_parser _fp_p_addr_s[] = { static inline bool _cb_p_addr(struct snl_state *ss __unused, void *_target) { - struct snl_parsed_addr *target = _target; + struct snl_parsed_addr *target = (struct snl_parsed_addr *)_target; finalize_sockaddr(target->ifa_address, target->ifa_index); finalize_sockaddr(target->ifa_local, target->ifa_index); @@ -379,7 +379,7 @@ static const struct snl_attr_parser _nla_p_nh[] = { static inline bool _cb_p_nh(struct snl_state *ss __unused, void *_target) { - struct snl_parsed_nhop *target = _target; + struct snl_parsed_nhop *target = (struct snl_parsed_nhop *)_target; finalize_sockaddr(target->nha_gw, target->nha_oif); return (true);