perf thread-stack: Tidy thread_stack__push_cp() usage
If 'cp' is checked in thread_stack__push_cp() a number of error checks can be removed, reducing code size and improving readability. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: http://lkml.kernel.org/r/20190109091835.5570-3-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
d6d457451e
commit
e7a3a055f2
@@ -493,6 +493,9 @@ static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr,
|
|||||||
struct thread_stack_entry *tse;
|
struct thread_stack_entry *tse;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
if (!cp)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
if (ts->cnt == ts->sz) {
|
if (ts->cnt == ts->sz) {
|
||||||
err = thread_stack__grow(ts);
|
err = thread_stack__grow(ts);
|
||||||
if (err)
|
if (err)
|
||||||
@@ -576,8 +579,6 @@ static int thread_stack__bottom(struct thread_stack *ts,
|
|||||||
|
|
||||||
cp = call_path__findnew(cpr, &cpr->call_path, sym, ip,
|
cp = call_path__findnew(cpr, &cpr->call_path, sym, ip,
|
||||||
ts->kernel_start);
|
ts->kernel_start);
|
||||||
if (!cp)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
return thread_stack__push_cp(ts, ip, sample->time, ref, cp,
|
return thread_stack__push_cp(ts, ip, sample->time, ref, cp,
|
||||||
true, false);
|
true, false);
|
||||||
@@ -609,8 +610,6 @@ static int thread_stack__no_call_return(struct thread *thread,
|
|||||||
cp = call_path__findnew(cpr, &cpr->call_path,
|
cp = call_path__findnew(cpr, &cpr->call_path,
|
||||||
to_al->sym, sample->addr,
|
to_al->sym, sample->addr,
|
||||||
ts->kernel_start);
|
ts->kernel_start);
|
||||||
if (!cp)
|
|
||||||
return -ENOMEM;
|
|
||||||
return thread_stack__push_cp(ts, 0, sample->time, ref,
|
return thread_stack__push_cp(ts, 0, sample->time, ref,
|
||||||
cp, true, false);
|
cp, true, false);
|
||||||
}
|
}
|
||||||
@@ -633,8 +632,6 @@ static int thread_stack__no_call_return(struct thread *thread,
|
|||||||
/* This 'return' had no 'call', so push and pop top of stack */
|
/* This 'return' had no 'call', so push and pop top of stack */
|
||||||
cp = call_path__findnew(cpr, parent, from_al->sym, sample->ip,
|
cp = call_path__findnew(cpr, parent, from_al->sym, sample->ip,
|
||||||
ts->kernel_start);
|
ts->kernel_start);
|
||||||
if (!cp)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
err = thread_stack__push_cp(ts, sample->addr, sample->time, ref, cp,
|
err = thread_stack__push_cp(ts, sample->addr, sample->time, ref, cp,
|
||||||
true, false);
|
true, false);
|
||||||
@@ -680,8 +677,6 @@ static int thread_stack__trace_end(struct thread_stack *ts,
|
|||||||
|
|
||||||
cp = call_path__findnew(cpr, ts->stack[ts->cnt - 1].cp, NULL, 0,
|
cp = call_path__findnew(cpr, ts->stack[ts->cnt - 1].cp, NULL, 0,
|
||||||
ts->kernel_start);
|
ts->kernel_start);
|
||||||
if (!cp)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
ret_addr = sample->ip + sample->insn_len;
|
ret_addr = sample->ip + sample->insn_len;
|
||||||
|
|
||||||
@@ -745,8 +740,6 @@ int thread_stack__process(struct thread *thread, struct comm *comm,
|
|||||||
cp = call_path__findnew(cpr, ts->stack[ts->cnt - 1].cp,
|
cp = call_path__findnew(cpr, ts->stack[ts->cnt - 1].cp,
|
||||||
to_al->sym, sample->addr,
|
to_al->sym, sample->addr,
|
||||||
ts->kernel_start);
|
ts->kernel_start);
|
||||||
if (!cp)
|
|
||||||
return -ENOMEM;
|
|
||||||
err = thread_stack__push_cp(ts, ret_addr, sample->time, ref,
|
err = thread_stack__push_cp(ts, ret_addr, sample->time, ref,
|
||||||
cp, false, trace_end);
|
cp, false, trace_end);
|
||||||
} else if (sample->flags & PERF_IP_FLAG_RETURN) {
|
} else if (sample->flags & PERF_IP_FLAG_RETURN) {
|
||||||
|
|||||||
Reference in New Issue
Block a user