Messages in this thread | | | Date | Tue, 20 Jan 2015 14:06:09 +0100 | From | Jiri Olsa <> | Subject | Re: [PATCH 1/2] perf: convert: fix duplicate field names. |
| |
On Tue, Jan 20, 2015 at 07:07:08PM +0800, Wang Nan wrote:
SNIP
> + * > + * So instead of checking duplication, simply tries 10 times. > + */ > + for (dup = 0; dup < 10; dup ++) { > + struct bt_ctf_field_type *f; > + char *dupl_name = get_dupl_name(field->name, dup); > + > + if (!dupl_name) { > + pr_err("Failed to alloc memory for dup '%s'\n", > + field->name); > + return -1; > + } > + > + ret = bt_ctf_event_class_add_field(event_class, type, > + dupl_name); > + free(dupl_name); > + if (ret) > + continue;
hum.. so we dont know if we failed because of the name, but we keep trying 10 times anyway.. does not seem nice to me
how about using that function you mentioned in the above comment to get the proper name first, like:
while(bt_ctf_event_class_get_field_by_name(name)) change_name(name)
and then add use it for bt_ctf_event_class_add_field
thanks, jirka
| |