mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
perf tools: Use asprintf instead of malloc plus snprintf
The asprintf library function is equivalent to malloc plus snprintf so use it because it is simpler. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1386055390-13757-4-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
89e3bbd58a
commit
d88938ebc9
1 changed files with 1 additions and 8 deletions
|
@ -227,7 +227,6 @@ char *get_srcline(struct dso *dso, unsigned long addr)
|
||||||
unsigned line = 0;
|
unsigned line = 0;
|
||||||
char *srcline;
|
char *srcline;
|
||||||
char *dso_name = dso->long_name;
|
char *dso_name = dso->long_name;
|
||||||
size_t size;
|
|
||||||
|
|
||||||
if (!dso->has_srcline)
|
if (!dso->has_srcline)
|
||||||
return SRCLINE_UNKNOWN;
|
return SRCLINE_UNKNOWN;
|
||||||
|
@ -241,13 +240,7 @@ char *get_srcline(struct dso *dso, unsigned long addr)
|
||||||
if (!addr2line(dso_name, addr, &file, &line))
|
if (!addr2line(dso_name, addr, &file, &line))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* just calculate actual length */
|
if (asprintf(&srcline, "%s:%u", file, line) < 0)
|
||||||
size = snprintf(NULL, 0, "%s:%u", file, line) + 1;
|
|
||||||
|
|
||||||
srcline = malloc(size);
|
|
||||||
if (srcline)
|
|
||||||
snprintf(srcline, size, "%s:%u", file, line);
|
|
||||||
else
|
|
||||||
srcline = SRCLINE_UNKNOWN;
|
srcline = SRCLINE_UNKNOWN;
|
||||||
|
|
||||||
free(file);
|
free(file);
|
||||||
|
|
Loading…
Reference in a new issue