[PATCH] lib: add type casting for nla_for_each_nested macro

Przemyslaw Szczerbik przemekszczerbik at gmail.com
Thu Feb 25 10:01:20 PST 2016


g++ is unable to compile code with nla_for_each_nested macro due to
implicit type conversion from void* to nlattr*. This patch adds type
casting for nla_for_each_nested macro to address this issue.

Signed-off-by: Przemyslaw Szczerbik <przemek.szczerbik at gmail.com>
---
 include/netlink/attr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/netlink/attr.h b/include/netlink/attr.h
index b84b62e..3963782 100644
--- a/include/netlink/attr.h
+++ b/include/netlink/attr.h
@@ -274,7 +274,7 @@ extern int		nla_is_nested(const struct nlattr *);
  * @arg rem	initialized to len, holds bytes currently remaining in stream
  */
 #define nla_for_each_nested(pos, nla, rem) \
-	for (pos = nla_data(nla), rem = nla_len(nla); \
+	for (pos = (struct nlattr *) nla_data(nla), rem = nla_len(nla); \
 	     nla_ok(pos, rem); \
 	     pos = nla_next(pos, &(rem)))
 
-- 
1.9.1




More information about the libnl mailing list