[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20160526181027.GA21342@krava>
Date: Thu, 26 May 2016 20:10:27 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Wang Nan <wangnan0@...wei.com>
Cc: acme@...nel.org, pi3orama@....com, linux-kernel@...r.kernel.org,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Jiri Olsa <jolsa@...nel.org>
Subject: Re: [PATCH] perf ctf: Convert invalid chars in a string before set
value
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@...nel.org>
thanks,
jirka
Powered by blists - more mailing lists