[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
times test warnings
From: |
Bruno Haible |
Subject: |
times test warnings |
Date: |
Sun, 26 Dec 2010 19:20:17 +0100 |
User-agent: |
KMail/1.9.9 |
Hi Simon,
On OSF/1 5.1, with "gcc -Wall", I'm seeing these warnings:
test-times.c:63: warning: format '%ld' expects type 'long int', but argument 2
has type 'clock_t'
test-times.c:64: warning: format '%ld' expects type 'long int', but argument 2
has type 'clock_t'
test-times.c:65: warning: format '%ld' expects type 'long int', but argument 2
has type 'clock_t'
test-times.c:66: warning: format '%ld' expects type 'long int', but argument 2
has type 'clock_t'
test-times.c:67: warning: format '%ld' expects type 'long int', but argument 2
has type 'clock_t'
test-times.c:97: warning: format '%ld' expects type 'long int', but argument 2
has type 'clock_t'
test-times.c:98: warning: format '%ld' expects type 'long int', but argument 2
has type 'clock_t'
test-times.c:99: warning: format '%ld' expects type 'long int', but argument 2
has type 'clock_t'
test-times.c:100: warning: format '%ld' expects type 'long int', but argument 2
has type 'clock_t'
test-times.c:101: warning: format '%ld' expects type 'long int', but argument 2
has type 'clock_t'
The reason is that on this platform clock_t is 'int', which is narrower than
the 'long int' expected by printf.
This patch fixes it. OK to push?
2010-12-24 Bruno Haible <address@hidden>
times test: Avoid gcc warnings on OSF/1.
* tests/test-times.c (main): Cast printf arguments from clock_t to
'long int'.
--- tests/test-times.c.orig Sat Dec 25 03:03:47 2010
+++ tests/test-times.c Sat Dec 25 03:02:11 2010
@@ -60,11 +60,11 @@
{
printf ("clk_tck %ld\n", (long int) clk_tck);
- printf ("t %ld\n", t);
- printf ("tms.tms_utime %ldms\n", (tms.tms_utime * 1000) / clk_tck);
- printf ("tms.tms_stime %ldms\n", (tms.tms_stime * 1000) / clk_tck);
- printf ("tms.tms_cutime %ldms\n", (tms.tms_cutime * 1000) / clk_tck);
- printf ("tms.tms_cstime %ldms\n", (tms.tms_cstime * 1000) / clk_tck);
+ printf ("t %ld\n", (long int) t);
+ printf ("tms.tms_utime %ldms\n", ((long int) tms.tms_utime * 1000) /
clk_tck);
+ printf ("tms.tms_stime %ldms\n", ((long int) tms.tms_stime * 1000) /
clk_tck);
+ printf ("tms.tms_cutime %ldms\n", ((long int) tms.tms_cutime * 1000) /
clk_tck);
+ printf ("tms.tms_cstime %ldms\n", ((long int) tms.tms_cstime * 1000) /
clk_tck);
}
if (argc > 1)
@@ -94,11 +94,11 @@
{
printf ("clk_tck %ld\n", (long int) clk_tck);
- printf ("t %ld\n", t);
- printf ("tms.tms_utime %ldms\n", (tms.tms_utime * 1000) / clk_tck);
- printf ("tms.tms_stime %ldms\n", (tms.tms_stime * 1000) / clk_tck);
- printf ("tms.tms_cutime %ldms\n", (tms.tms_cutime * 1000) / clk_tck);
- printf ("tms.tms_cstime %ldms\n", (tms.tms_cstime * 1000) / clk_tck);
+ printf ("t %ld\n", (long int) t);
+ printf ("tms.tms_utime %ldms\n", ((long int) tms.tms_utime * 1000) /
clk_tck);
+ printf ("tms.tms_stime %ldms\n", ((long int) tms.tms_stime * 1000) /
clk_tck);
+ printf ("tms.tms_cutime %ldms\n", ((long int) tms.tms_cutime * 1000) /
clk_tck);
+ printf ("tms.tms_cstime %ldms\n", ((long int) tms.tms_cstime * 1000) /
clk_tck);
}
return 0;
- times test warnings,
Bruno Haible <=