summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2016-03-17 14:30:16 -0400
committerJohn Kacur <jkacur@redhat.com>2016-03-22 15:33:22 +0100
commitc20e8c2c553ac5d86911d41afea37c842606ddd7 (patch)
tree5c1062edb4a6b6cd1e1570692a57fd3c31b5af02
parent3290f8412a4562adbc05b38d8e5212090e41587e (diff)
downloadrt-tests-c20e8c2c553ac5d86911d41afea37c842606ddd7.tar.gz
rt-tests-c20e8c2c553ac5d86911d41afea37c842606ddd7.tar.xz
cyclictest: move tracemark_fd handling to its own function
A function added by the next commit will want to call this code too. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r--src/cyclictest/cyclictest.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index df3db2a..5834f4e 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -527,6 +527,19 @@ static int settracer(char *tracer)
return -1;
}
+static void open_tracemark_fd(void)
+{
+ char path[MAX_PATH];
+
+ if (tracemark_fd >= 0)
+ return;
+
+ sprintf(path, "%s/%s", fileprefix, "trace_marker");
+ tracemark_fd = open(path, O_WRONLY);
+ if (tracemark_fd < 0)
+ warn("unable to open trace_marker file: %s\n", path);
+}
+
static void setup_tracer(void)
{
if (!tracelimit || notrace)
@@ -655,14 +668,7 @@ static void setup_tracer(void)
fatal("unable to open %s for tracing", path);
}
- /* open the tracemark file descriptor */
- if (tracemark_fd == -1) {
- char path[MAX_PATH];
- strcat(strcpy(path, fileprefix), "trace_marker");
- if ((tracemark_fd = open(path, O_WRONLY)) == -1)
- warn("unable to open trace_marker file: %s\n", path);
- }
-
+ open_tracemark_fd();
} else {
setkernvar("trace_all_cpus", "1");
setkernvar("trace_freerunning", "1");