aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2019-01-09 04:18:31 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-02-06 08:00:40 -0500
commite7a3a055f2b88ebd0bdae8b0aade1e7d80c8a81e (patch)
tree82c42aa714923ee6a2faf67b0451c0347cd8cb81
parentd6d457451eb94fa747dc202765592eb8885a7352 (diff)
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>
-rw-r--r--tools/perf/util/thread-stack.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c
index d52f27f373ce..93ba3ab6a602 100644
--- a/tools/perf/util/thread-stack.c
+++ b/tools/perf/util/thread-stack.c
@@ -493,6 +493,9 @@ static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr,
493 struct thread_stack_entry *tse; 493 struct thread_stack_entry *tse;
494 int err; 494 int err;
495 495
496 if (!cp)
497 return -ENOMEM;
498
496 if (ts->cnt == ts->sz) { 499 if (ts->cnt == ts->sz) {
497 err = thread_stack__grow(ts); 500 err = thread_stack__grow(ts);
498 if (err) 501 if (err)
@@ -576,8 +579,6 @@ static int thread_stack__bottom(struct thread_stack *ts,
576 579
577 cp = call_path__findnew(cpr, &cpr->call_path, sym, ip, 580 cp = call_path__findnew(cpr, &cpr->call_path, sym, ip,
578 ts->kernel_start); 581 ts->kernel_start);
579 if (!cp)
580 return -ENOMEM;
581 582
582 return thread_stack__push_cp(ts, ip, sample->time, ref, cp, 583 return thread_stack__push_cp(ts, ip, sample->time, ref, cp,
583 true, false); 584 true, false);
@@ -609,8 +610,6 @@ static int thread_stack__no_call_return(struct thread *thread,
609 cp = call_path__findnew(cpr, &cpr->call_path, 610 cp = call_path__findnew(cpr, &cpr->call_path,
610 to_al->sym, sample->addr, 611 to_al->sym, sample->addr,
611 ts->kernel_start); 612 ts->kernel_start);
612 if (!cp)
613 return -ENOMEM;
614 return thread_stack__push_cp(ts, 0, sample->time, ref, 613 return thread_stack__push_cp(ts, 0, sample->time, ref,
615 cp, true, false); 614 cp, true, false);
616 } 615 }
@@ -633,8 +632,6 @@ static int thread_stack__no_call_return(struct thread *thread,
633 /* This 'return' had no 'call', so push and pop top of stack */ 632 /* This 'return' had no 'call', so push and pop top of stack */
634 cp = call_path__findnew(cpr, parent, from_al->sym, sample->ip, 633 cp = call_path__findnew(cpr, parent, from_al->sym, sample->ip,
635 ts->kernel_start); 634 ts->kernel_start);
636 if (!cp)
637 return -ENOMEM;
638 635
639 err = thread_stack__push_cp(ts, sample->addr, sample->time, ref, cp, 636 err = thread_stack__push_cp(ts, sample->addr, sample->time, ref, cp,
640 true, false); 637 true, false);
@@ -680,8 +677,6 @@ static int thread_stack__trace_end(struct thread_stack *ts,
680 677
681 cp = call_path__findnew(cpr, ts->stack[ts->cnt - 1].cp, NULL, 0, 678 cp = call_path__findnew(cpr, ts->stack[ts->cnt - 1].cp, NULL, 0,
682 ts->kernel_start); 679 ts->kernel_start);
683 if (!cp)
684 return -ENOMEM;
685 680
686 ret_addr = sample->ip + sample->insn_len; 681 ret_addr = sample->ip + sample->insn_len;
687 682
@@ -745,8 +740,6 @@ int thread_stack__process(struct thread *thread, struct comm *comm,
745 cp = call_path__findnew(cpr, ts->stack[ts->cnt - 1].cp, 740 cp = call_path__findnew(cpr, ts->stack[ts->cnt - 1].cp,
746 to_al->sym, sample->addr, 741 to_al->sym, sample->addr,
747 ts->kernel_start); 742 ts->kernel_start);
748 if (!cp)
749 return -ENOMEM;
750 err = thread_stack__push_cp(ts, ret_addr, sample->time, ref, 743 err = thread_stack__push_cp(ts, ret_addr, sample->time, ref,
751 cp, false, trace_end); 744 cp, false, trace_end);
752 } else if (sample->flags & PERF_IP_FLAG_RETURN) { 745 } else if (sample->flags & PERF_IP_FLAG_RETURN) {