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

perf strlist: Make dupstr be the default and part of an extensible config parm

So that we can pass more info to strlist__new() without having to change
its function signature, just adding entries to the strlist_config struct
with sensible defaults for when those fields are not specified.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-5uaaler4931i0s9sedxjquhq@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

+22 -16
+4 -4
tools/perf/builtin-buildid-cache.c
··· 363 363 setup_pager(); 364 364 365 365 if (add_name_list_str) { 366 - list = strlist__new(true, add_name_list_str); 366 + list = strlist__new(add_name_list_str, NULL); 367 367 if (list) { 368 368 strlist__for_each(pos, list) 369 369 if (build_id_cache__add_file(pos->s)) { ··· 381 381 } 382 382 383 383 if (remove_name_list_str) { 384 - list = strlist__new(true, remove_name_list_str); 384 + list = strlist__new(remove_name_list_str, NULL); 385 385 if (list) { 386 386 strlist__for_each(pos, list) 387 387 if (build_id_cache__remove_file(pos->s)) { ··· 399 399 } 400 400 401 401 if (purge_name_list_str) { 402 - list = strlist__new(true, purge_name_list_str); 402 + list = strlist__new(purge_name_list_str, NULL); 403 403 if (list) { 404 404 strlist__for_each(pos, list) 405 405 if (build_id_cache__purge_path(pos->s)) { ··· 420 420 ret = build_id_cache__fprintf_missing(session, stdout); 421 421 422 422 if (update_name_list_str) { 423 - list = strlist__new(true, update_name_list_str); 423 + list = strlist__new(update_name_list_str, NULL); 424 424 if (list) { 425 425 strlist__for_each(pos, list) 426 426 if (build_id_cache__update_file(pos->s)) {
+1 -1
tools/perf/builtin-trace.c
··· 2931 2931 trace.not_ev_qualifier = *s == '!'; 2932 2932 if (trace.not_ev_qualifier) 2933 2933 ++s; 2934 - trace.ev_qualifier = strlist__new(true, s); 2934 + trace.ev_qualifier = strlist__new(s, NULL); 2935 2935 if (trace.ev_qualifier == NULL) { 2936 2936 fputs("Not enough memory to parse event qualifier", 2937 2937 trace.output);
+1 -1
tools/perf/util/build-id.c
··· 291 291 struct dirent *d; 292 292 int ret = 0; 293 293 294 - list = strlist__new(true, NULL); 294 + list = strlist__new(NULL, NULL); 295 295 dir_name = build_id_cache__dirname_from_path(pathname, false, false); 296 296 if (!list || !dir_name) { 297 297 ret = -ENOMEM;
+1 -1
tools/perf/util/machine.c
··· 250 250 static struct strlist *seen; 251 251 252 252 if (!seen) 253 - seen = strlist__new(true, NULL); 253 + seen = strlist__new(NULL, NULL); 254 254 255 255 if (!strlist__has_entry(seen, path)) { 256 256 pr_err("Can't access file %s\n", path);
+2 -2
tools/perf/util/probe-event.c
··· 2066 2066 char *p; 2067 2067 struct strlist *sl; 2068 2068 2069 - sl = strlist__new(true, NULL); 2069 + sl = strlist__new(NULL, NULL); 2070 2070 2071 2071 fp = fdopen(dup(fd), "r"); 2072 2072 while (!feof(fp)) { ··· 2362 2362 rawlist = get_probe_trace_command_rawlist(fd); 2363 2363 if (!rawlist) 2364 2364 return NULL; 2365 - sl = strlist__new(true, NULL); 2365 + sl = strlist__new(NULL, NULL); 2366 2366 strlist__for_each(ent, rawlist) { 2367 2367 ret = parse_probe_trace_command(ent->s, &tev); 2368 2368 if (ret < 0)
+1 -1
tools/perf/util/probe-finder.c
··· 1355 1355 vl->point.offset); 1356 1356 1357 1357 /* Find local variables */ 1358 - vl->vars = strlist__new(true, NULL); 1358 + vl->vars = strlist__new(NULL, NULL); 1359 1359 if (vl->vars == NULL) 1360 1360 return -ENOMEM; 1361 1361 af->child = true;
+2 -2
tools/perf/util/strlist.c
··· 133 133 return *s ? strlist__parse_list_entry(slist, s) : 0; 134 134 } 135 135 136 - struct strlist *strlist__new(bool dupstr, const char *list) 136 + struct strlist *strlist__new(const char *list, const struct strlist_config *config) 137 137 { 138 138 struct strlist *slist = malloc(sizeof(*slist)); 139 139 ··· 143 143 slist->rblist.node_new = strlist__node_new; 144 144 slist->rblist.node_delete = strlist__node_delete; 145 145 146 - slist->dupstr = dupstr; 146 + slist->dupstr = config ? !config->dont_dupstr : true; 147 147 if (list && strlist__parse_list(slist, list) != 0) 148 148 goto out_error; 149 149 }
+5 -1
tools/perf/util/strlist.h
··· 16 16 bool dupstr; 17 17 }; 18 18 19 - struct strlist *strlist__new(bool dupstr, const char *slist); 19 + struct strlist_config { 20 + bool dont_dupstr; 21 + }; 22 + 23 + struct strlist *strlist__new(const char *slist, const struct strlist_config *config); 20 24 void strlist__delete(struct strlist *slist); 21 25 22 26 void strlist__remove(struct strlist *slist, struct str_node *sn);
+1 -1
tools/perf/util/symbol.c
··· 1906 1906 if (list_str == NULL) 1907 1907 return 0; 1908 1908 1909 - *list = strlist__new(true, list_str); 1909 + *list = strlist__new(list_str, NULL); 1910 1910 if (!*list) { 1911 1911 pr_err("problems parsing %s list\n", list_name); 1912 1912 return -1;
+4 -2
tools/perf/util/thread_map.c
··· 196 196 pid_t pid, prev_pid = INT_MAX; 197 197 char *end_ptr; 198 198 struct str_node *pos; 199 - struct strlist *slist = strlist__new(false, pid_str); 199 + struct strlist_config slist_config = { .dont_dupstr = true, }; 200 + struct strlist *slist = strlist__new(pid_str, &slist_config); 200 201 201 202 if (!slist) 202 203 return NULL; ··· 267 266 pid_t tid, prev_tid = INT_MAX; 268 267 char *end_ptr; 269 268 struct str_node *pos; 269 + struct strlist_config slist_config = { .dont_dupstr = true, }; 270 270 struct strlist *slist; 271 271 272 272 /* perf-stat expects threads to be generated even if tid not given */ 273 273 if (!tid_str) 274 274 return thread_map__new_dummy(); 275 275 276 - slist = strlist__new(false, tid_str); 276 + slist = strlist__new(tid_str, &slist_config); 277 277 if (!slist) 278 278 return NULL; 279 279