diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2014-01-31 14:07:20 -0600 |
---|---|---|
committer | Clark Williams <clark.williams@gmail.com> | 2014-01-31 14:11:46 -0600 |
commit | 87f11582451733f9e37ccae470fca70e1e83a17c (patch) | |
tree | 89a96db31727f3af6071cfa4d058a47e2852ee68 | |
parent | 3917fdbe56a8e8716f3d1ba93806083e598d3e49 (diff) | |
download | rt-tests-87f11582451733f9e37ccae470fca70e1e83a17c.tar.gz |
cyclictest: Fix tracemark output when the latency threshold is hit on ARM
on ARM I'm seeing output like:
cyclicte-623 0....... 19619418us+: tracing_mark_write: hit latency threshold (2000 > 2097)
That's because of a format mismatch in
tracemark("hit latency threshold (%d > %d)", diff, tracelimit);
diff is a u64 and tracelimit an int. So on ARM the string is passed in r0,
tracelimit in r1 and diff in r2+r3. vsnprintf used in tracemark only
expects two ints passed and so only uses r1 and r2 yielding the permutation
in the output.
This patch also adds a gcc attribute to tracemark that helps catching
similar bugs. In this case just adding the attribute but not touching
the call site, would result in:
src/cyclictest/cyclictest.c: In function ‘timerthread’:
src/cyclictest/cyclictest.c:899:4: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘uint64_t’ [-Wformat]
---
Hello
after some chatting with Clark and John I dropped the c99 stuff and added the
attribute annotation.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Clark Williams <clark.williams@gmail.com>
-rw-r--r-- | src/cyclictest/cyclictest.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index 686a635..c3fa60f 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -400,6 +400,7 @@ static int trace_file_exists(char *name) #define TRACEBUFSIZ 1024 static __thread char tracebuf[TRACEBUFSIZ]; +static void tracemark(char *fmt, ...) __attribute__((format(printf, 1, 2))); static void tracemark(char *fmt, ...) { va_list ap; @@ -895,7 +896,8 @@ void *timerthread(void *param) if (!stopped && tracelimit && (diff > tracelimit)) { stopped++; - tracemark("hit latency threshold (%d > %d)", diff, tracelimit); + tracemark("hit latency threshold (%llu > %d)", + (unsigned long long) diff, tracelimit); tracing(0); shutdown++; pthread_mutex_lock(&break_thread_id_lock); |