From nobody Sun Feb 12 11:46:49 2023 X-Original-To: dev-commits-src-main@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 4PF5Kk28H0z3pDPk; Sun, 12 Feb 2023 11:46:50 +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 4PF5Kk1Ss7z41KG; Sun, 12 Feb 2023 11:46:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676202410; 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=YU45OO3K2R3h4jRMtQ1BPBZI+RdW5YMVq2kI6m4tAdQ=; b=ps/SAbWEMVujgdSdPrqO/8DkjfM9a49Fq2JUxhRZOmzu+5lu8hDLgrvmghdf4aNWCq3M4l hmylh7nL4jQf+E8UZyBN3xsckyb9RX+R8gWVYbxTqxEwL/c8R1kSoVB3muvvhtyx8L77LQ lVuhJKmflurnxW8Y+cCWYfKClkwrziwmBZaVMpzV1Fjo1nyIv3NsZU2wbl2if7la2vMHFi 95C0arBgwx2WEzHOldpbJAqLkXx1lxbXBtYqETVom/rk6JDYUbL32/6HwiNBJgJKhYjAkH gNtAm5ft/GxCVCELpjJeYGmCUbvaffTFimeGddhC6jXZrXk2SzEPwCHiGi89aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676202410; 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=YU45OO3K2R3h4jRMtQ1BPBZI+RdW5YMVq2kI6m4tAdQ=; b=NtsJ9erGkzGzYhH71PO+RljFpoN16b6xDT6F3pBb7OQAIJa2fA/GRPi5XBErC64mO1lWHt WX21E9t9WEVl/RGk7Lg3BIFvDu3yCHU31IxRXvA9vj/dxvT4sqZRl2sCova18Rs9yBgxxr rdQDO4E27lgj+BjEBIDhwURwKnMEvu+GlADUVxrQuu1dUq4VQpPlTxcWS2Aj3cpabwTD/N hdvGVB1gWbve29wv3n7r12lKZNuAwDbE8PHXM6T9gAobNMaAQLrc9oy91g/PP24VyzB6wc 9iU7H5FHWpnMmpzULuDSryS9bzCwyk0HrzwoC8QPmVlc8Tl+DDM/Fbev1EiXvQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676202410; a=rsa-sha256; cv=none; b=EWWBRXNap8UCWBcq5QDIz2QTtAo9hlAWP07JspS9JWBBIrvS/lssWgEmvZqkGJC73FBy4Z rXBrypEhtPTq+733aGGnF+mHimaxwyrXN0w0QfgoEVsCrfg6UIPxXQlDqGCvgL66ztEZRh XTVIRxV7p6wwqqJ9qFgGSJm2VQ2CH5WNyLcVET8qM9uXoN72IGkoVdfWzqt97H33PyIeHH 417h1Rb1x++HKH0W3oUuA9Zpqme5t+9lm7hhg/7dPjhWxaNwz5FJQoMiry9MwJ+rfdC8vZ bZbHPreXGq7QL82847FDMUSBycXzQd/qDeBB8sCSPJKNwrO4ri8fhGmPrtw++A== 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 4PF5Kk0Qcfzd6V; Sun, 12 Feb 2023 11:46:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31CBknlp096364; Sun, 12 Feb 2023 11:46:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31CBknWF096363; Sun, 12 Feb 2023 11:46:49 GMT (envelope-from git) Date: Sun, 12 Feb 2023 11:46:49 GMT Message-Id: <202302121146.31CBknWF096363@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 629d9219d931 - main - netlink: make netlink_snl(3) c++ friendly. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 629d9219d931e63dc49ef046332b2a360e42a5f6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=629d9219d931e63dc49ef046332b2a360e42a5f6 commit 629d9219d931e63dc49ef046332b2a360e42a5f6 Author: Alexander V. Chernikov AuthorDate: 2023-02-10 20:19:09 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-02-12 11:46:38 +0000 netlink: make netlink_snl(3) c++ friendly. --- sys/netlink/netlink_snl.h | 22 +++++++++++++--------- sys/netlink/netlink_snl_route.h | 6 +++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/sys/netlink/netlink_snl.h b/sys/netlink/netlink_snl.h index 6e2c4b89a7c4..586cab391046 100644 --- a/sys/netlink/netlink_snl.h +++ b/sys/netlink/netlink_snl.h @@ -44,6 +44,7 @@ #include #include +__BEGIN_DECLS #define _roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) @@ -83,7 +84,7 @@ lb_allocz(struct linear_buffer *lb, int len) return (NULL); void *data = (void *)(lb->base + lb->offset); lb->offset += len; - return (data); + return ((char *)data); } static inline void @@ -132,10 +133,10 @@ struct snl_hdr_parser { #define SNL_DECLARE_PARSER(_name, _t, _fp, _np) \ static const struct snl_hdr_parser _name = { \ .hdr_off = sizeof(_t), \ - .fp = &((_fp)[0]), \ - .np = &((_np)[0]), \ .fp_size = NL_ARRAY_LEN(_fp), \ .np_size = NL_ARRAY_LEN(_np), \ + .fp = &((_fp)[0]), \ + .np = &((_np)[0]), \ } #define SNL_DECLARE_ATTR_PARSER(_name, _np) \ @@ -175,14 +176,14 @@ 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); } ss->lb.size = SCRATCH_BUFFER_SIZE; - ss->lb.base = calloc(1, ss->lb.size); + ss->lb.base = (char *)calloc(1, ss->lb.size); if (ss->lb.base == NULL) { snl_free(ss); return (false); @@ -360,7 +361,7 @@ snl_attr_get_uint16(struct snl_state *ss __unused, struct nlattr *nla, const void *arg __unused, void *target) { if (NLA_DATA_LEN(nla) == sizeof(uint16_t)) { - *((uint16_t *)target) = *((const uint16_t *)NLA_DATA_CONST(nla)); + *((uint16_t *)target) = *((const uint16_t *)NL_RTA_DATA_CONST(nla)); return (true); } return (false); @@ -371,7 +372,7 @@ snl_attr_get_uint32(struct snl_state *ss __unused, struct nlattr *nla, const void *arg __unused, void *target) { if (NLA_DATA_LEN(nla) == sizeof(uint32_t)) { - *((uint32_t *)target) = *((const uint32_t *)NLA_DATA_CONST(nla)); + *((uint32_t *)target) = *((const uint32_t *)NL_RTA_DATA_CONST(nla)); return (true); } return (false); @@ -396,7 +397,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'; @@ -416,7 +417,8 @@ snl_attr_get_nested(struct snl_state *ss, struct nlattr *nla, const void *arg, v } static inline bool -snl_attr_get_nla(struct snl_state *ss __unused, struct nlattr *nla, void *target) +snl_attr_get_nla(struct snl_state *ss __unused, struct nlattr *nla, + const void *arg __unused, void *target) { *((struct nlattr **)target) = nla; return (true); @@ -440,4 +442,6 @@ snl_field_get_uint32(struct snl_state *ss __unused, void *src, void *target) *((uint32_t *)target) = *((uint32_t *)src); } +__END_DECLS + #endif diff --git a/sys/netlink/netlink_snl_route.h b/sys/netlink/netlink_snl_route.h index 4adb3d697ecd..19841bdd2f50 100644 --- a/sys/netlink/netlink_snl_route.h +++ b/sys/netlink/netlink_snl_route.h @@ -31,6 +31,8 @@ #include #include +__BEGIN_DECLS + /* * Simple Netlink Library - NETLINK_ROUTE helpers */ @@ -100,7 +102,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: @@ -127,4 +129,6 @@ snl_attr_get_ipvia(struct snl_state *ss, struct nlattr *nla, return (false); } +__END_DECLS + #endif