Skip to content

Commit 7512e96

Browse files
captain5050acmel
authored andcommitted
perf build-id: Simplify build_id_cache__cachedir()
Initialize realname to NULL, rather than name. This avoids a cast and as realpath is either NULL or an allocated string, free can be called unconditionally. Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: K Prateek Nayak <kprateek.nayak@amd.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Ming Wang <wangming01@loongson.cn> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Wei Li <liwei391@huawei.com> Cc: Will Deacon <will@kernel.org> Cc: linux-arm-kernel@lists.infradead.org Link: https://lore.kernel.org/r/20230825024002.801955-6-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent b782304 commit 7512e96

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

tools/perf/util/build-id.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
560560
struct nsinfo *nsi, bool is_kallsyms,
561561
bool is_vdso)
562562
{
563-
char *realname = (char *)name, *filename;
563+
char *realname = NULL, *filename;
564564
bool slash = is_kallsyms || is_vdso;
565565

566566
if (!slash)
@@ -571,9 +571,7 @@ char *build_id_cache__cachedir(const char *sbuild_id, const char *name,
571571
sbuild_id ? "/" : "", sbuild_id ?: "") < 0)
572572
filename = NULL;
573573

574-
if (!slash)
575-
free(realname);
576-
574+
free(realname);
577575
return filename;
578576
}
579577

0 commit comments

Comments
 (0)