Skip to content

Commit 68faab0

Browse files
changbinduacmel
authored andcommitted
perf ftrace: Factor out function write_tracing_file_int()
We will reuse this function later. Signed-off-by: Changbin Du <[email protected]> Acked-by: Namhyung Kim <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt (VMware) <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d6d81bf commit 68faab0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tools/perf/builtin-ftrace.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ static int read_tracing_file_to_stdout(const char *name)
169169
return ret;
170170
}
171171

172+
static int write_tracing_file_int(const char *name, int value)
173+
{
174+
char buf[16];
175+
176+
snprintf(buf, sizeof(buf), "%d", value);
177+
if (write_tracing_file(name, buf) < 0)
178+
return -1;
179+
180+
return 0;
181+
}
182+
172183
static int reset_tracing_cpu(void);
173184
static void reset_tracing_filters(void);
174185

@@ -299,8 +310,6 @@ static void reset_tracing_filters(void)
299310

300311
static int set_tracing_depth(struct perf_ftrace *ftrace)
301312
{
302-
char buf[16];
303-
304313
if (ftrace->graph_depth == 0)
305314
return 0;
306315

@@ -309,9 +318,7 @@ static int set_tracing_depth(struct perf_ftrace *ftrace)
309318
return -1;
310319
}
311320

312-
snprintf(buf, sizeof(buf), "%d", ftrace->graph_depth);
313-
314-
if (write_tracing_file("max_graph_depth", buf) < 0)
321+
if (write_tracing_file_int("max_graph_depth", ftrace->graph_depth) < 0)
315322
return -1;
316323

317324
return 0;

0 commit comments

Comments
 (0)