Skip to content

Commit 20dcad8

Browse files
captain5050acmel
authored andcommitted
tools lib api fs tracing_path: Remove two unused MAX_PATH paths
tracing_mnt was set but never written. tracing_events_path was set and read on errors paths, but its value is exactly tracing_path with a "/events" appended, so we can derive the value in the error paths. There appears to have been a missing "/" when tracing_events_path was initialized. Signed-off-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/r/20230526183401.2326121-8-irogers@google.com Cc: K Prateek Nayak <kprateek.nayak@amd.com> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Ross Zwisler <zwisler@chromium.org> Cc: Steven Rostedt (Google) <rostedt@goodmis.org> Cc: Sean Christopherson <seanjc@google.com> Cc: Yang Jihong <yangjihong1@huawei.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Arnaldo Carvalho de Melo <acme@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Leo Yan <leo.yan@linaro.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Tiezhu Yang <yangtiezhu@loongson.cn> Cc: Ingo Molnar <mingo@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: linux-kernel@vger.kernel.org Cc: linux-perf-users@vger.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 89df62c commit 20dcad8

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

tools/lib/api/fs/tracing_path.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,12 @@
1313

1414
#include "tracing_path.h"
1515

16-
static char tracing_mnt[PATH_MAX] = "/sys/kernel/debug";
1716
static char tracing_path[PATH_MAX] = "/sys/kernel/tracing";
18-
static char tracing_events_path[PATH_MAX] = "/sys/kernel/tracing/events";
1917

2018
static void __tracing_path_set(const char *tracing, const char *mountpoint)
2119
{
22-
snprintf(tracing_mnt, sizeof(tracing_mnt), "%s", mountpoint);
2320
snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
2421
mountpoint, tracing);
25-
snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
26-
mountpoint, tracing, "events");
2722
}
2823

2924
static const char *tracing_path_tracefs_mount(void)
@@ -149,15 +144,15 @@ int tracing_path__strerror_open_tp(int err, char *buf, size_t size,
149144
/* sdt markers */
150145
if (!strncmp(filename, "sdt_", 4)) {
151146
snprintf(buf, size,
152-
"Error:\tFile %s/%s not found.\n"
147+
"Error:\tFile %s/events/%s not found.\n"
153148
"Hint:\tSDT event cannot be directly recorded on.\n"
154149
"\tPlease first use 'perf probe %s:%s' before recording it.\n",
155-
tracing_events_path, filename, sys, name);
150+
tracing_path, filename, sys, name);
156151
} else {
157152
snprintf(buf, size,
158-
"Error:\tFile %s/%s not found.\n"
153+
"Error:\tFile %s/events/%s not found.\n"
159154
"Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
160-
tracing_events_path, filename);
155+
tracing_path, filename);
161156
}
162157
break;
163158
}
@@ -169,9 +164,9 @@ int tracing_path__strerror_open_tp(int err, char *buf, size_t size,
169164
break;
170165
case EACCES: {
171166
snprintf(buf, size,
172-
"Error:\tNo permissions to read %s/%s\n"
167+
"Error:\tNo permissions to read %s/events/%s\n"
173168
"Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
174-
tracing_events_path, filename, tracing_path_mount());
169+
tracing_path, filename, tracing_path_mount());
175170
}
176171
break;
177172
default:

0 commit comments

Comments
 (0)