public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Wang Nan <wangnan0@huawei.com>
Cc: acme@kernel.org, pi3orama@163.com, linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH] perf ctf: Convert invalid chars in a string before set value
Date: Thu, 26 May 2016 20:10:27 +0200	[thread overview]
Message-ID: <20160526181027.GA21342@krava> (raw)
In-Reply-To: <1464172761-173095-1-git-send-email-wangnan0@huawei.com>

On Wed, May 25, 2016 at 10:39:21AM +0000, Wang Nan wrote:

SNIP

>  
> +static int string_set_value(struct bt_ctf_field *field, const char *string)
> +{
> +	char *buffer;
> +	size_t len = strlen(string), i, p;
> +	int err;
> +
> +	buffer = zalloc(len * 4 + 2);
> +	if (!buffer)
> +		return bt_ctf_field_string_set_value(field, string);

hope dies last ;-)

> +
> +	for (i = p = 0; i < len; i++) {
> +		if (isprint(string[i])) {
> +			buffer[p++] = string[i];
> +		} else {
> +			char numstr[5];
> +
> +			snprintf(numstr, sizeof(numstr), "\\x%02x",
> +				(unsigned int)(string[i]) & 0xff);
> +			strncat(buffer, numstr, 4);
> +			p = strlen(buffer);

			p += 4; instead ^^^ ?

other than that:

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka

      reply	other threads:[~2016-05-26 18:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-25 10:39 [PATCH] perf ctf: Convert invalid chars in a string before set value Wang Nan
2016-05-26 18:10 ` Jiri Olsa [this message]

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=20160526181027.GA21342@krava \
    --to=jolsa@redhat.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pi3orama@163.com \
    --cc=wangnan0@huawei.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