From e086dc93a37f9a69d82eb753c3871408c591d925 Mon Sep 17 00:00:00 2001 From: kib Date: Wed, 6 Jun 2012 17:26:52 +0000 Subject: [PATCH] Do not execute a needed statement with side-effect in assert(). MFC after: 3 days --- tools/tools/syscall_timing/syscall_timing.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/tools/syscall_timing/syscall_timing.c b/tools/tools/syscall_timing/syscall_timing.c index 756fec90aeb..175c1bc9bd6 100644 --- a/tools/tools/syscall_timing/syscall_timing.c +++ b/tools/tools/syscall_timing/syscall_timing.c @@ -71,20 +71,24 @@ alarm_handler(int signum) static void benchmark_start(void) { + int error; alarm_fired = 0; if (alarm_timeout) { signal(SIGALRM, alarm_handler); alarm(alarm_timeout); } - assert(clock_gettime(CLOCK_REALTIME, &ts_start) == 0); + error = clock_gettime(CLOCK_REALTIME, &ts_start); + assert(error == 0); } static void benchmark_stop(void) { + int error; - assert(clock_gettime(CLOCK_REALTIME, &ts_end) == 0); + error = clock_gettime(CLOCK_REALTIME, &ts_end); + assert(error == 0); } uintmax_t @@ -687,7 +691,7 @@ main(int argc, char *argv[]) const char *path; long long ll; char *endp; - int ch, i, j, k; + int ch, error, i, j, k; uintmax_t iterations, loops; alarm_timeout = 1; @@ -756,7 +760,8 @@ main(int argc, char *argv[]) } } - assert(clock_getres(CLOCK_REALTIME, &ts_res) == 0); + error = clock_getres(CLOCK_REALTIME, &ts_res); + assert(error == 0); printf("Clock resolution: %ju.%09ju\n", (uintmax_t)ts_res.tv_sec, (uintmax_t)ts_res.tv_nsec); printf("test\tloop\ttime\titerations\tperiteration\n"); -- 2.45.0