[PATCH v4 04/11] tests: introduce NLATTR macro

JingPiao Chen chenjingpiao at gmail.com
Thu Jul 6 01:57:30 UTC 2017


Now we can not use TEST_NLATTR macro directly, we need to know nla.

* tests/test_nlattr.h (TEST_NLATTR_): Replace nla with NLATTR.
---
 tests/test_nlattr.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tests/test_nlattr.h b/tests/test_nlattr.h
index 2b49b5a..9c15c33 100644
--- a/tests/test_nlattr.h
+++ b/tests/test_nlattr.h
@@ -55,6 +55,8 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type)
 	printf(", {{nla_len=%u, nla_type=%s}, ", nla_len, nla_type);
 }
 
+#define NLATTR nla
+
 #define TEST_NLATTR_(fd_, nlh0_, hdrlen_,				\
 		     init_msg_, print_msg_,				\
 		     nla_type_, nla_type_str_,				\
@@ -62,14 +64,15 @@ print_nlattr(const unsigned int nla_len, const char *const nla_type)
 	do {								\
 		struct nlmsghdr *const nlh =				\
 			(nlh0_) - (NLA_HDRLEN + (slen_));		\
-		struct nlattr *const nla = NLMSG_ATTR(nlh, (hdrlen_));	\
+		struct nlattr *const NLATTR =				\
+			NLMSG_ATTR(nlh, (hdrlen_));			\
 		const unsigned int nla_len =				\
 			NLA_HDRLEN + (nla_data_len_);			\
 		const unsigned int msg_len =				\
 			NLMSG_SPACE(hdrlen_) + nla_len;			\
 									\
 		(init_msg_)(nlh, msg_len);				\
-		init_nlattr(nla, nla_len, (nla_type_),			\
+		init_nlattr(NLATTR, nla_len, (nla_type_),		\
 			   (src_), (slen_));				\
 									\
 		const char *const errstr =				\
-- 
2.7.4





More information about the Strace-devel mailing list