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

Dmitry V. Levin ldv at altlinux.org
Thu Jul 6 11:47:12 UTC 2017


On Thu, Jul 06, 2017 at 09:57:30AM +0800, JingPiao Chen wrote:
> 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_));				\

NLATTR is too short and too generic, even for test_nlattr.h;
let's give it a longer name, e.g. TEST_NLATTR_nla.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170706/8fb41c6e/attachment.bin>


More information about the Strace-devel mailing list