include: libmnl.h: Add explicit casts to macros for C++
Phil Sutter
reviewerPATCH 1/1 include: libmnl.h: Add explicit casts to macros for C++
C++ does not like implicit casts of void pointers, make them explicit there. After adjusting similar cases in example source files, these are the only needed header adjustments needed to compile them with g++.
--- include/libmnl/libmnl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/libmnl/libmnl.h +2 -2
@@ -146,12 +146,12 @@ extern bool mnl_attr_ok(const struct nlattr *attr, int len);extern struct nlattr *mnl_attr_next (const struct nlattr *attr);#define mnl_attr_for_each (attr, nlh, offset) \ - for ((attr) = mnl_nlmsg_get_payload_offset((nlh), (offset)); \ + for ((attr) = (struct nlattr *)mnl_nlmsg_get_payload_offset((nlh), (offset)); \ mnl_attr_ok((attr), (char *)mnl_nlmsg_get_payload_tail(nlh) - (char *)(attr)); \ (attr) = mnl_attr_next(attr))#define mnl_attr_for_each_nested (attr, nest) \ - for ((attr) = mnl_attr_get_payload(nest); \ + for ((attr) = (struct nlattr *)mnl_attr_get_payload(nest); \ mnl_attr_ok((attr), (char *)mnl_attr_get_payload(nest) + mnl_attr_get_payload_len(nest) - (char *)(attr)); \ (attr) = mnl_attr_next(attr))
Signature · 1 line
2.54.0
Quoted 3 lines · Phil Sutter
C++ does not like implicit casts of void pointers, make them explicit there. After adjusting similar cases in example source files, these are the only needed header adjustments needed to compile them with g++.
Phil Sutter
reviewerQuoted 6 lines · Florian Westphal
Quoted 3 lines · Phil Sutter
C++ does not like implicit casts of void pointers, make them explicit there. After adjusting similar cases in example source files, these are the only needed header adjustments needed to compile them with g++.
Reviewed-by Florian Westphal <[email protected]>
Applied after dropping the redundant "needed" up there. Thanks for your review!