From 918310c04d1f5a5af4d5116540b46ea8b39397fb Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Tue, 24 Sep 2019 11:00:48 -0700 Subject: [PATCH] tests: fix -Werror,-Wimplicit-int-float-conversion ``` testes/dispatch_timer_short.c:58:74: error: implicit conversion from 'unsigned long long' to 'double' may loose precision [-Werror,-Wimplicit-int-float-conversion] test_long_less_than("Frequency", 1, (long)ceil((double)delay/(finalCount*interval))); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~ ``` Fix the casting for `finalCount` and explicitly cast the result which would be an `unsigned long long` due to the multiplication by `interval`. --- tests/dispatch_timer_short.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/dispatch_timer_short.c b/tests/dispatch_timer_short.c index da17775c0..eb948ab37 100644 --- a/tests/dispatch_timer_short.c +++ b/tests/dispatch_timer_short.c @@ -52,10 +52,11 @@ static void test_fin(void *cxt) { - unsigned long finalCount = (unsigned long)count; + uint32_t finalCount = (uint32_t)count; fprintf(stderr, "Called back every %llu us on average\n", (delay/finalCount)/NSEC_PER_USEC); - test_long_less_than("Frequency", 1, (long)ceil((double)delay/(finalCount*interval))); + test_long_less_than("Frequency", 1, + (long)ceil((double)delay/(double)(finalCount*interval))); int i; for (i = 0; i < N; i++) { dispatch_source_cancel(t[i]);