lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Thu, 7 Jun 2018 01:10:20 -0700
From:   tip-bot for Arnaldo Carvalho de Melo <tipbot@...or.com>
To:     linux-tip-commits@...r.kernel.org
Cc:     acme@...hat.com, namhyung@...nel.org, mingo@...nel.org,
        hpa@...or.com, linux-kernel@...r.kernel.org, dsahern@...il.com,
        adrian.hunter@...el.com, jolsa@...nel.org, wangnan0@...wei.com,
        tglx@...utronix.de
Subject: [tip:perf/urgent] perf sort: Introduce addr_map_symbol__srcline()
 to make code more compact

Commit-ID:  bfa63519fb94fd8b4b0e5ffcd8bde650ea8b20c1
Gitweb:     https://git.kernel.org/tip/bfa63519fb94fd8b4b0e5ffcd8bde650ea8b20c1
Author:     Arnaldo Carvalho de Melo <acme@...hat.com>
AuthorDate: Mon, 28 May 2018 11:11:47 -0300
Committer:  Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Mon, 4 Jun 2018 10:28:52 -0300

perf sort: Introduce addr_map_symbol__srcline() to make code more compact

Since we have 'struct addr_map_symbol' and the srcline sort order keys
all operate on those, make the code more compact by introducing a
function that receives a pointer to such struct and expands the
arguments to map__srcline().

Cc: Adrian Hunter <adrian.hunter@...el.com>
Cc: David Ahern <dsahern@...il.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Wang Nan <wangnan0@...wei.com>
Link: https://lkml.kernel.org/n/tip-j540wq7n3ukkh70gk5be0in5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/util/sort.c | 37 +++++++++++++++++--------------------
 1 file changed, 17 insertions(+), 20 deletions(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index 71096dbfeb88..4ab0b4ab24e4 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -365,19 +365,20 @@ struct sort_entry sort_srcline = {
 
 /* --sort srcline_from */
 
+static char *addr_map_symbol__srcline(struct addr_map_symbol *ams)
+{
+	return map__srcline(ams->map, ams->al_addr, ams->sym);
+}
+
 static int64_t
 sort__srcline_from_cmp(struct hist_entry *left, struct hist_entry *right)
 {
-	if (!left->branch_info->srcline_from) {
-		left->branch_info->srcline_from = map__srcline(left->branch_info->from.map,
-							       left->branch_info->from.al_addr,
-							       left->branch_info->from.sym);
-	}
-	if (!right->branch_info->srcline_from) {
-		right->branch_info->srcline_from = map__srcline(right->branch_info->from.map,
-								right->branch_info->from.al_addr,
-								right->branch_info->from.sym);
-	}
+	if (!left->branch_info->srcline_from)
+		left->branch_info->srcline_from = addr_map_symbol__srcline(&left->branch_info->from);
+
+	if (!right->branch_info->srcline_from)
+		right->branch_info->srcline_from = addr_map_symbol__srcline(&right->branch_info->from);
+
 	return strcmp(right->branch_info->srcline_from, left->branch_info->srcline_from);
 }
 
@@ -399,16 +400,12 @@ struct sort_entry sort_srcline_from = {
 static int64_t
 sort__srcline_to_cmp(struct hist_entry *left, struct hist_entry *right)
 {
-	if (!left->branch_info->srcline_to) {
-		left->branch_info->srcline_to = map__srcline(left->branch_info->to.map,
-							     left->branch_info->to.al_addr,
-							     left->branch_info->to.sym);
-	}
-	if (!right->branch_info->srcline_to) {
-		right->branch_info->srcline_to = map__srcline(right->branch_info->to.map,
-							      right->branch_info->to.al_addr,
-							      right->branch_info->to.sym);
-	}
+	if (!left->branch_info->srcline_to)
+		left->branch_info->srcline_to = addr_map_symbol__srcline(&left->branch_info->to);
+
+	if (!right->branch_info->srcline_to)
+		right->branch_info->srcline_to = addr_map_symbol__srcline(&right->branch_info->to);
+
 	return strcmp(right->branch_info->srcline_to, left->branch_info->srcline_to);
 }
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ