linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, David Ahern <dsahern@gmail.com>,
	Irina Tirdea <irina.tirdea@gmail.com>,
	Pekka Enberg <penberg@kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 7/9] perf annotate: Make a copy of filename for passing to basename
Date: Sat,  8 Sep 2012 17:36:52 -0300	[thread overview]
Message-ID: <1347136614-25598-8-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1347136614-25598-1-git-send-email-acme@infradead.org>

From: David Ahern <dsahern@gmail.com>

The basename function may modify the string passed to it, so the string
should not be marked const.

Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Irina Tirdea <irina.tirdea@gmail.com>
Cc: Pekka Enberg <penberg@kernel.org>
Link: http://lkml.kernel.org/r/1347116812-93646-2-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/annotate.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 51ef69c..04eafd3 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -984,7 +984,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
 			    int context)
 {
 	struct dso *dso = map->dso;
-	const char *filename = dso->long_name, *d_filename;
+	char *filename;
+	const char *d_filename;
 	struct annotation *notes = symbol__annotation(sym);
 	struct disasm_line *pos, *queue = NULL;
 	u64 start = map__rip_2objdump(map, sym->start);
@@ -992,6 +993,10 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
 	int more = 0;
 	u64 len;
 
+	filename = strdup(dso->long_name);
+	if (!filename)
+		return -ENOMEM;
+
 	if (full_paths)
 		d_filename = filename;
 	else
@@ -1042,6 +1047,8 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
 		}
 	}
 
+	free(filename);
+
 	return more;
 }
 
-- 
1.7.1


  parent reply	other threads:[~2012-09-08 20:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-08 20:36 [GIT PULL 0/9] perf/core improvements and fixes Arnaldo Carvalho de Melo
2012-09-08 20:36 ` [PATCH 1/9] perf bench: fix assert when NDEBUG is defined Arnaldo Carvalho de Melo
2012-09-08 20:36 ` [PATCH 2/9] perf hists: Introduce perf_hpp for hist period printing Arnaldo Carvalho de Melo
2012-09-08 20:36 ` [PATCH 3/9] perf hists: Handle field separator properly Arnaldo Carvalho de Melo
2012-09-08 20:36 ` [PATCH 4/9] perf hists: Use perf_hpp__format->width to calculate the column widths Arnaldo Carvalho de Melo
2012-09-08 20:36 ` [PATCH 5/9] perf hists browser: Use perf_hpp__format functions Arnaldo Carvalho de Melo
2012-09-08 20:36 ` [PATCH 6/9] perf gtk/browser: " Arnaldo Carvalho de Melo
2012-09-08 20:36 ` Arnaldo Carvalho de Melo [this message]
2012-09-08 20:36 ` [PATCH 8/9] perf probe: Make a copy of exec path for passing to basename Arnaldo Carvalho de Melo
2012-09-08 20:36 ` [PATCH 9/9] perf symbols: Remove BIONIC wrapper around libgen.h Arnaldo Carvalho de Melo
2012-09-09  8:40 ` [GIT PULL 0/9] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1347136614-25598-8-git-send-email-acme@infradead.org \
    --to=acme@infradead.org \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=irina.tirdea@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=penberg@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).