[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141019113920.3f0fa575@uryu.home.lan>
Date: Sun, 19 Oct 2014 11:39:20 +0530
From: Stephen Hemminger <stephen@...workplumber.org>
To: Vadim Kochan <vadim4j@...il.com>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH iproute2] ss: Refactor to use macro for define diag nl
request
On Sun, 19 Oct 2014 02:50:29 +0300
Vadim Kochan <vadim4j@...il.com> wrote:
> Signed-off-by: Vadim Kochan <vadim4j@...il.com>
> ---
> misc/ss.c | 57 ++++++++++++++++++---------------------------------------
> 1 file changed, 18 insertions(+), 39 deletions(-)
>
> diff --git a/misc/ss.c b/misc/ss.c
> index 2420b51..261847b 100644
> --- a/misc/ss.c
> +++ b/misc/ss.c
> @@ -41,6 +41,20 @@
> #include <linux/packet_diag.h>
> #include <linux/netlink_diag.h>
>
> +#define DIAG_REQUEST(_req, _r) \
> + struct { \
> + struct nlmsghdr nlh; \
> + _r; \
> + } _req = { \
> + .nlh = { \
> + .nlmsg_type = SOCK_DIAG_BY_FAMILY, \
> + .nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST,\
> + .nlmsg_seq = 123456, \
> + .nlmsg_len = sizeof(_req), \
> + .nlmsg_pid = 0, \
> + }, \
> + }
No need to initialize to zero.
Not a big fan of macro's but it does make the code more readable in this case.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists