[PATCH] perf tools: fix test for whether pathnames can be shortened

From: Alan Jenkins
Date: Fri Oct 30 2009 - 10:12:30 EST


The intention is to consider the pair (filename, cwd) and shorten the
filename if it lives under cwd. E.g. ("/src/foo", "/src") -> "./foo".

Make the test more specific to exclude these unintended consequences:

("/src/foo", "/") -> ".src/foo"
("/src/foo", "/s") -> ".rc/foo"

Signed-off-by: Alan Jenkins <alan-jenkins@xxxxxxxxxxxxxx>
---
tools/perf/util/map.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 804e023..bd17703 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -31,7 +31,7 @@ static int strcommon(const char *pathname, char *cwd, int cwdlen)
if (cwd) {
int n = strcommon(filename, cwd, cwdlen);

- if (n == cwdlen) {
+ if (n == cwdlen && filename[n] == '/') {
snprintf(newfilename, sizeof(newfilename),
".%s", filename + n);
filename = newfilename;
--
1.6.3.2



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/