All of lore.kernel.org
 help / color / mirror / Atom feed
* [libmnl PATCH] include: libmnl.h: Add explicit casts to macros for C++
@ 2026-11-11 15:30 Phil Sutter
  2026-11-11 18:27 ` Florian Westphal
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Sutter @ 2026-11-11 15:30 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel, Yaron Shragai

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++.

Reported-by: Yaron Shragai <yshragai.firmware@gmail.com>
Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1156
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 include/libmnl/libmnl.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/libmnl/libmnl.h b/include/libmnl/libmnl.h
index 9c032807097f7..2c18e50e6026d 100644
--- a/include/libmnl/libmnl.h
+++ b/include/libmnl/libmnl.h
@@ -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))
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [libmnl PATCH] include: libmnl.h: Add explicit casts to macros for C++
  2026-11-11 15:30 [libmnl PATCH] include: libmnl.h: Add explicit casts to macros for C++ Phil Sutter
@ 2026-11-11 18:27 ` Florian Westphal
  2026-11-11 18:49   ` Phil Sutter
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Westphal @ 2026-11-11 18:27 UTC (permalink / raw)
  To: Phil Sutter; +Cc: Pablo Neira Ayuso, netfilter-devel, Yaron Shragai

Phil Sutter <phil@nwl.cc> wrote:
> 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 <fw@strlen.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [libmnl PATCH] include: libmnl.h: Add explicit casts to macros for C++
  2026-11-11 18:27 ` Florian Westphal
@ 2026-11-11 18:49   ` Phil Sutter
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Sutter @ 2026-11-11 18:49 UTC (permalink / raw)
  To: Florian Westphal; +Cc: Pablo Neira Ayuso, netfilter-devel, Yaron Shragai

On Wed, Nov 11, 2026 at 07:27:35PM +0100, Florian Westphal wrote:
> Phil Sutter <phil@nwl.cc> wrote:
> > 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 <fw@strlen.de>

Applied after dropping the redundant "needed" up there. Thanks for your
review!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-11 18:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 15:30 [libmnl PATCH] include: libmnl.h: Add explicit casts to macros for C++ Phil Sutter
2026-11-11 18:27 ` Florian Westphal
2026-11-11 18:49   ` Phil Sutter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.