lkml.org 
[lkml]   [2023]   [May]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH v1 08/16] perf daemon: Dynamically allocate path to perf
From
Avoid a PATH_MAX array in __daemon (the .data section) by dynamically
allocating the memory.

Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/builtin-daemon.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-daemon.c b/tools/perf/builtin-daemon.c
index 34cbe3e959aa..adb5751c3ed0 100644
--- a/tools/perf/builtin-daemon.c
+++ b/tools/perf/builtin-daemon.c
@@ -90,7 +90,7 @@ struct daemon {
char *base;
struct list_head sessions;
FILE *out;
- char perf[PATH_MAX];
+ char *perf;
int signal_fd;
time_t start;
};
@@ -1490,6 +1490,15 @@ static int __cmd_ping(struct daemon *daemon, struct option parent_options[],
return send_cmd(daemon, &cmd);
}

+static char *set_perf_exe(void)
+{
+ char path[PATH_MAX];
+
+ perf_exe(path, sizeof(path));
+ __daemon.perf = strdup(path);
+ return __daemon.perf;
+}
+
int cmd_daemon(int argc, const char **argv)
{
struct option daemon_options[] = {
@@ -1503,7 +1512,9 @@ int cmd_daemon(int argc, const char **argv)
OPT_END()
};

- perf_exe(__daemon.perf, sizeof(__daemon.perf));
+ if (!set_perf_exe())
+ return -ENOMEM;
+
__daemon.out = stdout;

argc = parse_options(argc, argv, daemon_options, daemon_usage,
--
2.40.1.698.g37aff9b760-goog
\
 
 \ /
  Last update: 2023-05-25 09:14    [W:0.118 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site