aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2023-02-12 12:16:58 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2023-02-12 12:17:05 +0000
commit6d7da7c8490f625642faad93b890354cc749f5ae (patch)
tree7c7bc6bc0ab6e0313071d52c37816458c5166555
parent69e7d9b7e6b369b760e1f189af2e25587b56a102 (diff)
downloadsrc-6d7da7c8490f625642faad93b890354cc749f5ae.tar.gz
src-6d7da7c8490f625642faad93b890354cc749f5ae.zip
Revert "netlink: make netlink_snl(3) c++ friendly."
Was pushed accidentally. This reverts commit 629d9219d931e63dc49ef046332b2a360e42a5f6.
-rw-r--r--sys/netlink/netlink_snl.h22
-rw-r--r--sys/netlink/netlink_snl_route.h6
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