netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Vadim Kochan <vadim4j@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] ss: Refactor to use macro for define diag nl request
Date: Sun, 19 Oct 2014 11:39:20 +0530	[thread overview]
Message-ID: <20141019113920.3f0fa575@uryu.home.lan> (raw)
In-Reply-To: <1413676229-23258-1-git-send-email-vadim4j@gmail.com>

On Sun, 19 Oct 2014 02:50:29 +0300
Vadim Kochan <vadim4j@gmail.com> wrote:

> Signed-off-by: Vadim Kochan <vadim4j@gmail.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.

  reply	other threads:[~2014-10-19  6:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-18 23:50 [PATCH iproute2] ss: Refactor to use macro for define diag nl request Vadim Kochan
2014-10-19  6:09 ` Stephen Hemminger [this message]
2014-10-19  7:09   ` vadim4j

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141019113920.3f0fa575@uryu.home.lan \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    --cc=vadim4j@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).