All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: David Ahern <dsahern@gmail.com>
Cc: acme@ghostprotocols.net, linux-kernel@vger.kernel.org,
	Jiri Olsa <jolsa@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] tools lib traceevent: Add support for IP address formats
Date: Thu, 18 Dec 2014 13:26:32 +0900	[thread overview]
Message-ID: <20141218042632.GB20215@sejong> (raw)
In-Reply-To: <1418848148-35919-1-git-send-email-dsahern@gmail.com>

Hi David,

On Wed, Dec 17, 2014 at 01:29:08PM -0700, David Ahern wrote:
> Adds helper for following kernel formats:
>   %pi4 print an IPv4 address with leading zeros
>   %pI4 print an IPv4 address without leading zeros
>   %pi6 print an IPv6 address without colons
>   %pI6 print an IPv6 address with colons
>   %pI6c print an IPv6 address with colons
>   %pISpc print an IP address from a sockaddr
> 
> Allows these formats to be used in tracepoints.
> 
> Quite a bit of this is adapted from code in lib/vsprintf.c.
> 
> Signed-off-by: David Ahern <dsahern@gmail.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> ---

[SNIP]
> +static int print_ip_arg(struct trace_seq *s, const char *ptr,
> +			void *data, int size, struct event_format *event,
> +			struct print_arg *arg)
> +{
> +	char i = *(ptr + 1);  /* 'i' or 'I' */

It'd be better if we do it like below..

	char i = *ptr++;

Why not passing ptr + 1 to print_ip_arg()?


> +	char ver;
> +	int rc = 0;
> +
> +	ptr++;
> +	rc++;
> +
> +	ver = *(ptr + 1);

Ditto.


> +	ptr++;
> +	rc++;
> +
> +	switch (ver) {
> +	case '4':
> +		rc += print_ipv4_arg(s, ptr, i, data, size, event, arg);
> +		break;
> +	case '6':
> +		rc += print_ipv6_arg(s, ptr, i, data, size, event, arg);
> +		break;
> +	case 'S':
> +		rc += print_ipsa_arg(s, ptr, i, data, size, event, arg);
> +		break;
> +	default:
> +		return 0;
> +	}
> +
> +	return rc;
> +}
> +
>  static int is_printable_array(char *p, unsigned int len)
>  {
>  	unsigned int i;
> @@ -4337,6 +4644,15 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
>  					ptr++;
>  					arg = arg->next;
>  					break;
> +				} else if (*(ptr+1) == 'I' || *(ptr+1) == 'i') {
> +					int n;
> +
> +					n = print_ip_arg(s, ptr, data, size, event, arg);

Here..

Thanks,
Namhyung


> +					if (n > 0) {
> +						ptr += n;
> +						arg = arg->next;
> +						break;
> +					}
>  				}
>  
>  				/* fall through */
> -- 
> 1.9.3 (Apple Git-50)
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

  reply	other threads:[~2014-12-18  4:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-17 20:29 [PATCH] tools lib traceevent: Add support for IP address formats David Ahern
2014-12-18  4:26 ` Namhyung Kim [this message]
2014-12-18  4:32   ` David Ahern
2014-12-18  5:04     ` Namhyung Kim
  -- strict thread matches above, loose matches on Subject: below --
2014-12-18 15:10 David Ahern
2014-12-18 15:52 ` Arnaldo Carvalho de Melo
2014-12-18 15:59   ` David Ahern
2014-12-18 16:27   ` Steven Rostedt
2014-12-18 22:16     ` Arnaldo Carvalho de Melo
2014-12-18 22:50       ` David Ahern
2014-12-18 21:45 ` Valdis.Kletnieks
2014-12-18 22:13   ` David Ahern
2014-12-19  1:41     ` David Ahern
2014-12-22 17:01       ` Jiri Olsa
2014-12-22 17:10         ` David Ahern
2014-12-22 17:28           ` Jiri Olsa

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=20141218042632.GB20215@sejong \
    --to=namhyung@kernel.org \
    --cc=acme@ghostprotocols.net \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.