Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Feb 2023 12:17:31 GMT
From:      "Alexander V. Chernikov" <melifaro@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 6d7da7c8490f - main - Revert "netlink: make netlink_snl(3) c++ friendly."
Message-ID:  <202302121217.31CCHVof039899@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by melifaro:

URL: https://cgit.FreeBSD.org/src/commit/?id=6d7da7c8490f625642faad93b890354cc749f5ae

commit 6d7da7c8490f625642faad93b890354cc749f5ae
Author:     Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2023-02-12 12:16:58 +0000
Commit:     Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2023-02-12 12:17:05 +0000

    Revert "netlink: make netlink_snl(3) c++ friendly."
    
    Was pushed accidentally.
    
    This reverts commit 629d9219d931e63dc49ef046332b2a360e42a5f6.
---
 sys/netlink/netlink_snl.h       | 22 +++++++++-------------
 sys/netlink/netlink_snl_route.h |  6 +-----
 2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/sys/netlink/netlink_snl.h b/sys/netlink/netlink_snl.h
index 586cab391046..6e2c4b89a7c4 100644
--- a/sys/netlink/netlink_snl.h
+++ b/sys/netlink/netlink_snl.h
@@ -44,7 +44,6 @@
 #include <sys/socket.h>
 #include <netlink/netlink.h>
 
-__BEGIN_DECLS
 
 #define _roundup2(x, y)         (((x)+((y)-1))&(~((y)-1)))
 
@@ -84,7 +83,7 @@ lb_allocz(struct linear_buffer *lb, int len)
 		return (NULL);
 	void *data = (void *)(lb->base + lb->offset);
 	lb->offset += len;
-	return ((char *)data);
+	return (data);
 }
 
 static inline void
@@ -133,10 +132,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_size = NL_ARRAY_LEN(_fp),			\
-	.np_size = NL_ARRAY_LEN(_np),			\
 	.fp = &((_fp)[0]),				\
 	.np = &((_np)[0]),				\
+	.fp_size = NL_ARRAY_LEN(_fp),			\
+	.np_size = NL_ARRAY_LEN(_np),			\
 }
 
 #define	SNL_DECLARE_ATTR_PARSER(_name, _np)		\
@@ -176,14 +175,14 @@ snl_init(struct snl_state *ss, int netlink_family)
 	}
 
 	ss->bufsize = rcvbuf;
-	ss->buf = (char *)malloc(ss->bufsize);
+	ss->buf = malloc(ss->bufsize);
 	if (ss->buf == NULL) {
 		snl_free(ss);
 		return (false);
 	}
 
 	ss->lb.size = SCRATCH_BUFFER_SIZE;
-	ss->lb.base = (char *)calloc(1, ss->lb.size);
+	ss->lb.base = calloc(1, ss->lb.size);
 	if (ss->lb.base == NULL) {
 		snl_free(ss);
 		return (false);
@@ -361,7 +360,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 *)NL_RTA_DATA_CONST(nla));
+		*((uint16_t *)target) = *((const uint16_t *)NLA_DATA_CONST(nla));
 		return (true);
 	}
 	return (false);
@@ -372,7 +371,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 *)NL_RTA_DATA_CONST(nla));
+		*((uint32_t *)target) = *((const uint32_t *)NLA_DATA_CONST(nla));
 		return (true);
 	}
 	return (false);
@@ -397,7 +396,7 @@ snl_attr_get_stringn(struct snl_state *ss, struct nlattr *nla,
 {
 	int maxlen = NLA_DATA_LEN(nla);
 
-	char *buf = (char *)snl_allocz(ss, maxlen + 1);
+	char *buf = snl_allocz(ss, maxlen + 1);
 	if (buf == NULL)
 		return (false);
 	buf[maxlen] = '\0';
@@ -417,8 +416,7 @@ 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,
-    const void *arg __unused, void *target)
+snl_attr_get_nla(struct snl_state *ss __unused, struct nlattr *nla, void *target)
 {
 	*((struct nlattr **)target) = nla;
 	return (true);
@@ -442,6 +440,4 @@ 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 19841bdd2f50..4adb3d697ecd 100644
--- a/sys/netlink/netlink_snl_route.h
+++ b/sys/netlink/netlink_snl_route.h
@@ -31,8 +31,6 @@
 #include <netlink/netlink_route.h>
 #include <netinet/in.h>
 
-__BEGIN_DECLS
-
 /*
  * Simple Netlink Library - NETLINK_ROUTE helpers
  */
@@ -102,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 = (struct rtvia *)NL_RTA_DATA(rta);
+	struct rtvia *via = NL_RTA_DATA(rta);
 
 	switch (via->rtvia_family) {
 	case AF_INET:
@@ -129,6 +127,4 @@ snl_attr_get_ipvia(struct snl_state *ss, struct nlattr *nla,
 	return (false);
 }
 
-__END_DECLS
-
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202302121217.31CCHVof039899>