Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf data ctf: Add value_set_string() helper

There are many value_set_##x helper for integer, but only for integer.
This patch adds value_set_string() helper to help following commits
create string fields.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1466767332-114472-2-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Wang Nan and committed by
Arnaldo Carvalho de Melo
069ee5c4 ed7b630b

+30
+30
tools/perf/util/data-convert-bt.c
··· 141 141 FUNC_VALUE_SET(u64) 142 142 __FUNC_VALUE_SET(u64_hex, u64) 143 143 144 + static int string_set_value(struct bt_ctf_field *field, const char *string); 145 + static __maybe_unused int 146 + value_set_string(struct ctf_writer *cw, struct bt_ctf_event *event, 147 + const char *name, const char *string) 148 + { 149 + struct bt_ctf_field_type *type = cw->data.string; 150 + struct bt_ctf_field *field; 151 + int ret = 0; 152 + 153 + field = bt_ctf_field_create(type); 154 + if (!field) { 155 + pr_err("failed to create a field %s\n", name); 156 + return -1; 157 + } 158 + 159 + ret = string_set_value(field, string); 160 + if (ret) { 161 + pr_err("failed to set value %s\n", name); 162 + goto err_put_field; 163 + } 164 + 165 + ret = bt_ctf_event_set_payload(event, name, field); 166 + if (ret) 167 + pr_err("failed to set payload %s\n", name); 168 + 169 + err_put_field: 170 + bt_ctf_field_put(field); 171 + return ret; 172 + } 173 + 144 174 static struct bt_ctf_field_type* 145 175 get_tracepoint_field_type(struct ctf_writer *cw, struct format_field *field) 146 176 {