lkml.org 
[lkml]   [2021]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 2/3] perf tests: avoid storing an absolute path in perf binary
On Fri, May 21, 2021 at 10:27:52AM -0700, Denys Zagorui wrote:

SNIP

> free(cmd);
> +out:
> + free(pythonpath);
> return ret;
> }
> diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
> index 3bba74e431ed..53f3dbf02f58 100644
> --- a/tools/perf/util/util.c
> +++ b/tools/perf/util/util.c
> @@ -22,6 +22,7 @@
> #include "cap.h"
> #include "strlist.h"
> #include "string2.h"
> +#include <libgen.h>
>
> /*
> * XXX We need to find a better place for these things...
> @@ -388,3 +389,14 @@ char *perf_exe(char *buf, int len)
> }
> return strcpy(buf, "perf");
> }
> +
> +char *perf_exe_path(void)
> +{
> + char buf[PATH_MAX];
> + char *dname;
> +
> + perf_exe(buf, PATH_MAX);
> + dname = dirname(buf);

I think this is equally bad.. once you get out of perf_exe_path,
dname might be screwed

> +
> + return dname;

just return strdup(dname) in here?

jirka

\
 
 \ /
  Last update: 2021-05-23 17:58    [W:0.119 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site