aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/trace-event-info.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/trace-event-info.c')
-rw-r--r--tools/perf/util/trace-event-info.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index 7e6fcfe8b438..eb72716017ac 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -40,6 +40,7 @@
40#include "trace-event.h" 40#include "trace-event.h"
41#include <api/fs/debugfs.h> 41#include <api/fs/debugfs.h>
42#include "evsel.h" 42#include "evsel.h"
43#include "debug.h"
43 44
44#define VERSION "0.5" 45#define VERSION "0.5"
45 46
@@ -191,12 +192,10 @@ static int copy_event_system(const char *sys, struct tracepoint_path *tps)
191 strcmp(dent->d_name, "..") == 0 || 192 strcmp(dent->d_name, "..") == 0 ||
192 !name_in_tp_list(dent->d_name, tps)) 193 !name_in_tp_list(dent->d_name, tps))
193 continue; 194 continue;
194 format = malloc(strlen(sys) + strlen(dent->d_name) + 10); 195 if (asprintf(&format, "%s/%s/format", sys, dent->d_name) < 0) {
195 if (!format) {
196 err = -ENOMEM; 196 err = -ENOMEM;
197 goto out; 197 goto out;
198 } 198 }
199 sprintf(format, "%s/%s/format", sys, dent->d_name);
200 ret = stat(format, &st); 199 ret = stat(format, &st);
201 free(format); 200 free(format);
202 if (ret < 0) 201 if (ret < 0)
@@ -217,12 +216,10 @@ static int copy_event_system(const char *sys, struct tracepoint_path *tps)
217 strcmp(dent->d_name, "..") == 0 || 216 strcmp(dent->d_name, "..") == 0 ||
218 !name_in_tp_list(dent->d_name, tps)) 217 !name_in_tp_list(dent->d_name, tps))
219 continue; 218 continue;
220 format = malloc(strlen(sys) + strlen(dent->d_name) + 10); 219 if (asprintf(&format, "%s/%s/format", sys, dent->d_name) < 0) {
221 if (!format) {
222 err = -ENOMEM; 220 err = -ENOMEM;
223 goto out; 221 goto out;
224 } 222 }
225 sprintf(format, "%s/%s/format", sys, dent->d_name);
226 ret = stat(format, &st); 223 ret = stat(format, &st);
227 224
228 if (ret >= 0) { 225 if (ret >= 0) {
@@ -317,12 +314,10 @@ static int record_event_files(struct tracepoint_path *tps)
317 strcmp(dent->d_name, "ftrace") == 0 || 314 strcmp(dent->d_name, "ftrace") == 0 ||
318 !system_in_tp_list(dent->d_name, tps)) 315 !system_in_tp_list(dent->d_name, tps))
319 continue; 316 continue;
320 sys = malloc(strlen(path) + strlen(dent->d_name) + 2); 317 if (asprintf(&sys, "%s/%s", path, dent->d_name) < 0) {
321 if (!sys) {
322 err = -ENOMEM; 318 err = -ENOMEM;
323 goto out; 319 goto out;
324 } 320 }
325 sprintf(sys, "%s/%s", path, dent->d_name);
326 ret = stat(sys, &st); 321 ret = stat(sys, &st);
327 if (ret >= 0) { 322 if (ret >= 0) {
328 ssize_t size = strlen(dent->d_name) + 1; 323 ssize_t size = strlen(dent->d_name) + 1;