perf trace: Streamline validation of select syscall names list

Rename the 'i' variable to 'nr_used' and use set 'nr_allocated' since
the start of this function, leaving the final assignment of the longer
named trace->ev_qualifier_ids.nr state to 'nr_used' at the end of the
function.

No change in behaviour intended.

Cc: Leo Yan <leo.yan@linaro.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lkml.kernel.org/n/tip-kpgyn8xjdjgt0timrrnniquv@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent a4066d64
...@@ -1529,11 +1529,10 @@ static int trace__validate_ev_qualifier(struct trace *trace) ...@@ -1529,11 +1529,10 @@ static int trace__validate_ev_qualifier(struct trace *trace)
{ {
int err = 0; int err = 0;
bool printed_invalid_prefix = false; bool printed_invalid_prefix = false;
size_t nr_allocated, i;
struct str_node *pos; struct str_node *pos;
size_t nr_used = 0, nr_allocated = strlist__nr_entries(trace->ev_qualifier);
trace->ev_qualifier_ids.nr = strlist__nr_entries(trace->ev_qualifier); trace->ev_qualifier_ids.entries = malloc(nr_allocated *
trace->ev_qualifier_ids.entries = malloc(trace->ev_qualifier_ids.nr *
sizeof(trace->ev_qualifier_ids.entries[0])); sizeof(trace->ev_qualifier_ids.entries[0]));
if (trace->ev_qualifier_ids.entries == NULL) { if (trace->ev_qualifier_ids.entries == NULL) {
...@@ -1543,9 +1542,6 @@ static int trace__validate_ev_qualifier(struct trace *trace) ...@@ -1543,9 +1542,6 @@ static int trace__validate_ev_qualifier(struct trace *trace)
goto out; goto out;
} }
nr_allocated = trace->ev_qualifier_ids.nr;
i = 0;
strlist__for_each_entry(pos, trace->ev_qualifier) { strlist__for_each_entry(pos, trace->ev_qualifier) {
const char *sc = pos->s; const char *sc = pos->s;
int id = syscalltbl__id(trace->sctbl, sc), match_next = -1; int id = syscalltbl__id(trace->sctbl, sc), match_next = -1;
...@@ -1566,7 +1562,7 @@ static int trace__validate_ev_qualifier(struct trace *trace) ...@@ -1566,7 +1562,7 @@ static int trace__validate_ev_qualifier(struct trace *trace)
continue; continue;
} }
matches: matches:
trace->ev_qualifier_ids.entries[i++] = id; trace->ev_qualifier_ids.entries[nr_used++] = id;
if (match_next == -1) if (match_next == -1)
continue; continue;
...@@ -1574,7 +1570,7 @@ static int trace__validate_ev_qualifier(struct trace *trace) ...@@ -1574,7 +1570,7 @@ static int trace__validate_ev_qualifier(struct trace *trace)
id = syscalltbl__strglobmatch_next(trace->sctbl, sc, &match_next); id = syscalltbl__strglobmatch_next(trace->sctbl, sc, &match_next);
if (id < 0) if (id < 0)
break; break;
if (nr_allocated == i) { if (nr_allocated == nr_used) {
void *entries; void *entries;
nr_allocated += 8; nr_allocated += 8;
...@@ -1587,11 +1583,11 @@ static int trace__validate_ev_qualifier(struct trace *trace) ...@@ -1587,11 +1583,11 @@ static int trace__validate_ev_qualifier(struct trace *trace)
} }
trace->ev_qualifier_ids.entries = entries; trace->ev_qualifier_ids.entries = entries;
} }
trace->ev_qualifier_ids.entries[i++] = id; trace->ev_qualifier_ids.entries[nr_used++] = id;
} }
} }
trace->ev_qualifier_ids.nr = i; trace->ev_qualifier_ids.nr = nr_used;
out: out:
if (printed_invalid_prefix) if (printed_invalid_prefix)
pr_debug("\n"); pr_debug("\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment