Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1407651
| From | Jiri Olsa <jolsa@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] perf ctf: Convert invalid chars in a string before set value |
| Date | 2016-05-26 20:20 +0200 |
| Message-ID | <rD82Z-1j7-5@gated-at.bofh.it> (permalink) |
| References | <rCExX-8n2-1@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] perf ctf: Convert invalid chars in a string before set value Wang Nan <wangnan0@huawei.com> - 2016-05-25 12:50 +0200 Re: [PATCH] perf ctf: Convert invalid chars in a string before set value Jiri Olsa <jolsa@redhat.com> - 2016-05-26 20:20 +0200
csiph-web