Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1399107

[PATCH perf/core v7 06/21] perf-buildid-cache: Use lsdir for looking up buildid caches

From Masami Hiramatsu <mhiramat@kernel.org>
Newsgroups linux.kernel
Subject [PATCH perf/core v7 06/21] perf-buildid-cache: Use lsdir for looking up buildid caches
Date 2016-05-11 16:00 +0200
Message-ID <rxCQa-UH-15@gated-at.bofh.it> (permalink)
References <rxCQa-UH-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

Use new lsdir() for looking up buildid caches. This changes
logic a bit to ignore all dot files, since the build-id
cache must not start with dot.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 Changes in v7:
  - Remove unneeded local strlist.
---
 tools/perf/util/build-id.c |   30 ++++--------------------------
 1 file changed, 4 insertions(+), 26 deletions(-)

diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 53df9aa..2cb6454 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -369,39 +369,17 @@ static char *build_id_cache__dirname_from_path(const char *name,
 int build_id_cache__list_build_ids(const char *pathname,
 				   struct strlist **result)
 {
-	struct strlist *list;
 	char *dir_name;
-	DIR *dir;
-	struct dirent *d;
 	int ret = 0;
 
-	list = strlist__new(NULL, NULL);
 	dir_name = build_id_cache__dirname_from_path(pathname, false, false);
-	if (!list || !dir_name) {
-		ret = -ENOMEM;
-		goto out;
-	}
+	if (!dir_name)
+		return -ENOMEM;
 
-	/* List up all dirents */
-	dir = opendir(dir_name);
-	if (!dir) {
+	*result = lsdir(dir_name, lsdir_no_dot_filter);
+	if (!*result)
 		ret = -errno;
-		goto out;
-	}
-
-	while ((d = readdir(dir)) != NULL) {
-		if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
-			continue;
-		strlist__add(list, d->d_name);
-	}
-	closedir(dir);
-
-out:
 	free(dir_name);
-	if (ret)
-		strlist__delete(list);
-	else
-		*result = list;
 
 	return ret;
 }

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH perf/core v7 06/21] perf-buildid-cache: Use lsdir for looking up buildid caches Masami Hiramatsu <mhiramat@kernel.org> - 2016-05-11 16:00 +0200
  Re: [PATCH perf/core v7 06/21] perf-buildid-cache: Use lsdir for  looking up buildid caches Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-05-11 18:00 +0200
  [tip:perf/core] perf buildid-cache: Use lsdir() for looking up  buildid caches tip-bot for Masami Hiramatsu <tipbot@zytor.com> - 2016-05-12 12:30 +0200

csiph-web