Message ID | CAAu8pHvnGYtR3TEY6WXD+xaNT=hE0KCUujoqOjUwv_gQNe=JGA@mail.gmail.com |
---|---|
State | New |
Headers | show |
On 03/30/2012 01:59 PM, Blue Swirl wrote: > Avoid this warning on OpenBSD: > CC tests/rtc-test.o > /src/qemu/tests/rtc-test.c: In function 'check_time': > /src/qemu/tests/rtc-test.c:171: warning: format '%ld' expects type > 'long int', but argument 2 has type 'time_t' > /src/qemu/tests/rtc-test.c:173: warning: format '%ld' expects type > 'long int', but argument 2 has type 'time_t' > > Signed-off-by: Blue Swirl<blauwirbel@gmail.com> I'd prefer to make t and s longs so that the casts weren't needed. It will make the issue less likely to come up later. Regards, Anthony Liguori > --- > tests/rtc-test.c | 6 ++++-- > 1 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/tests/rtc-test.c b/tests/rtc-test.c > index c32b36a..a5d4519 100644 > --- a/tests/rtc-test.c > +++ b/tests/rtc-test.c > @@ -168,9 +168,11 @@ static void check_time(int wiggle) > t = mktime(datep); > s = mktime(&start); > if (t< s) { > - g_test_message("RTC is %ld second(s) behind > wall-clock\n", (s - t)); > + g_test_message("RTC is %ld second(s) behind wall-clock\n", > + (long)(s - t)); > } else { > - g_test_message("RTC is %ld second(s) ahead of > wall-clock\n", (t - s)); > + g_test_message("RTC is %ld second(s) ahead of wall-clock\n", > + (long)(t - s)); > } > > g_assert_cmpint(ABS(t - s),<=, wiggle);
diff --git a/tests/rtc-test.c b/tests/rtc-test.c index c32b36a..a5d4519 100644 --- a/tests/rtc-test.c +++ b/tests/rtc-test.c @@ -168,9 +168,11 @@ static void check_time(int wiggle) t = mktime(datep); s = mktime(&start); if (t < s) { - g_test_message("RTC is %ld second(s) behind wall-clock\n", (s - t)); + g_test_message("RTC is %ld second(s) behind wall-clock\n", + (long)(s - t)); } else { - g_test_message("RTC is %ld second(s) ahead of wall-clock\n", (t - s)); + g_test_message("RTC is %ld second(s) ahead of wall-clock\n", + (long)(t - s)); }
Avoid this warning on OpenBSD: CC tests/rtc-test.o /src/qemu/tests/rtc-test.c: In function 'check_time': /src/qemu/tests/rtc-test.c:171: warning: format '%ld' expects type 'long int', but argument 2 has type 'time_t' /src/qemu/tests/rtc-test.c:173: warning: format '%ld' expects type 'long int', but argument 2 has type 'time_t' Signed-off-by: Blue Swirl <blauwirbel@gmail.com> --- tests/rtc-test.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) g_assert_cmpint(ABS(t - s), <=, wiggle);