all: Fix printf format errors
PATCH 1/1 all: Fix printf format errors
time_t is "long" or "long long" (depending on the system). So it should be safe to convert it to "long long", in order to get a consistent data type on all systems.
--- src/cyclictest/cyclictest.c | 8 ++++---- src/hackbench/hackbench.c | 2 +- src/sched_deadline/cyclicdeadline.c | 6 +++--- src/signaltest/signaltest.c | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-)
src/cyclictest/cyclictest.c +4 -4
@@ -1751,15 +1751,15 @@ static void write_stats(FILE *f, void *data)if (s->hist_array[j] ==0 )continue ;fprintf (f,"%s" , comma ?",\n" :"\n" ); -fprintf (f," \"%u\": %" PRIu64, j, s->hist_array[j]); +fprintf (f," \"%u\": %ld" , j, s->hist_array[j]); comma =1 ; }if (comma)fprintf (f,"\n" );fprintf (f," },\n" ); -fprintf (f," \"cycles\": %" PRIu64",\n" , s->cycles); -fprintf (f," \"min\": %" PRIu64",\n" , s->min); -fprintf (f," \"max\": %" PRIu64",\n" , s->max); +fprintf (f," \"cycles\": %lu,\n" , s->cycles); +fprintf (f," \"min\": %ld,\n" , s->min); +fprintf (f," \"max\": %ld,\n" , s->max);fprintf (f," \"avg\": %.2f,\n" , s->avg/s->cycles);fprintf (f," \"cpu\": %d,\n" , par[i]->cpu);fprintf (f," \"node\": %d\n" , par[i]->node);
src/hackbench/hackbench.c +1 -1
@@ -505,7 +505,7 @@ int main(int argc, char *argv[])/* Print time... */ if (timer_started) {timersub (&stop, &start, &diff); -printf ("Time: %lu.%03lu\n" , diff.tv_sec, diff.tv_usec/1000 ); +printf ("Time: %lld.%03lld\n" , (long long )diff.tv_sec, (long long )diff.tv_usec/1000 ); }else fprintf (stderr,"No measurements available\n" );
src/sched_deadline/cyclicdeadline.c +3 -3
@@ -978,9 +978,9 @@ static void write_stats(FILE *f, void *data)for (i =0 ; i < nr_threads; i++) { s = &sd[i].stat;fprintf (f," \"%u\": {\n" , i); -fprintf (f," \"cycles\": %" PRIu64",\n" , s->cycles); -fprintf (f," \"min\": %" PRIu64",\n" , s->min); -fprintf (f," \"max\": %" PRIu64",\n" , s->max); +fprintf (f," \"cycles\": %lu,\n" , s->cycles); +fprintf (f," \"min\": %ld,\n" , s->min); +fprintf (f," \"max\": %ld,\n" , s->max);fprintf (f," \"avg\": %.2f\n" , s->avg/s->cycles);fprintf (f," }%s\n" , i == nr_threads -1 ?"" :"," ); }
src/signaltest/signaltest.c +3 -3
@@ -392,9 +392,9 @@ static void write_stats(FILE *f, void *data)for (i =0 ; i < num_threads; i++) {fprintf (f," \"%u\": {\n" , i); s = &par->stats[i]; -fprintf (f," \"cycles\": %" PRIu64",\n" , s->cycles); -fprintf (f," \"min\": %" PRIu64",\n" , s->min); -fprintf (f," \"max\": %" PRIu64",\n" , s->max); +fprintf (f," \"cycles\": %lu,\n" , s->cycles); +fprintf (f," \"min\": %ld,\n" , s->min); +fprintf (f," \"max\": %ld,\n" , s->max);fprintf (f," \"avg\": %.2f,\n" , s->avg/s->cycles);fprintf (f," \"cpu\": %d\n" , par->cpu);fprintf (f," }%s\n" , i == num_threads -1 ?"" :"," );
Signature · 8 lines
Christian Eggers Embedded software developer Arnold & Richter Cine Technik GmbH & Co. Betriebs KG Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918 Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477 Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler
Quoted 94 lines · Christian Eggers
time_tis "long" or "long long" (depending on the system). So it should be safe to convert it to "long long", in order to get a consistent data type on all systems.Signed-off-by Christian Eggers <[email protected]>--- src/cyclictest/cyclictest.c | 8 ++++---- src/hackbench/hackbench.c | 2 +- src/sched_deadline/cyclicdeadline.c | 6 +++--- src/signaltest/signaltest.c | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-)src/cyclictest/cyclictest.c +4
-4@@ -1751,15 +1751,15 @@ static void write_stats(FILE *f, void *data)if (s->hist_array[j] ==0 )continue ;fprintf (f,"%s" , comma ?",\n" :"\n" ); -fprintf (f," \"%u\": %" PRIu64, j, s->hist_array[j]); +fprintf (f," \"%u\": %ld" , j, s->hist_array[j]); comma =1 ; }if (comma)fprintf (f,"\n" );fprintf (f," },\n" ); -fprintf (f," \"cycles\": %" PRIu64",\n" , s->cycles); -fprintf (f," \"min\": %" PRIu64",\n" , s->min); -fprintf (f," \"max\": %" PRIu64",\n" , s->max); +fprintf (f," \"cycles\": %lu,\n" , s->cycles); +fprintf (f," \"min\": %ld,\n" , s->min); +fprintf (f," \"max\": %ld,\n" , s->max);fprintf (f," \"avg\": %.2f,\n" , s->avg/s->cycles);fprintf (f," \"cpu\": %d,\n" , par[i]->cpu);fprintf (f," \"node\": %d\n" , par[i]->node);src/hackbench/hackbench.c +1
-1@@ -505,7 +505,7 @@ int main(int argc, char *argv[])/* Print time... */ if (timer_started) {timersub (&stop, &start, &diff); -printf ("Time: %lu.%03lu\n" , diff.tv_sec, diff.tv_usec/1000 ); +printf ("Time: %lld.%03lld\n" , (long long )diff.tv_sec, (long long )diff.tv_usec/1000 ); }else fprintf (stderr,"No measurements available\n" );src/sched_deadline/cyclicdeadline.c +3
-3@@ -978,9 +978,9 @@ static void write_stats(FILE *f, void *data)for (i =0 ; i < nr_threads; i++) { s = &sd[i].stat;fprintf (f," \"%u\": {\n" , i); -fprintf (f," \"cycles\": %" PRIu64",\n" , s->cycles); -fprintf (f," \"min\": %" PRIu64",\n" , s->min); -fprintf (f," \"max\": %" PRIu64",\n" , s->max); +fprintf (f," \"cycles\": %lu,\n" , s->cycles); +fprintf (f," \"min\": %ld,\n" , s->min); +fprintf (f," \"max\": %ld,\n" , s->max);fprintf (f," \"avg\": %.2f\n" , s->avg/s->cycles);fprintf (f," }%s\n" , i == nr_threads -1 ?"" :"," ); }src/signaltest/signaltest.c +3
-3@@ -392,9 +392,9 @@ static void write_stats(FILE *f, void *data)for (i =0 ; i < num_threads; i++) {fprintf (f," \"%u\": {\n" , i); s = &par->stats[i]; -fprintf (f," \"cycles\": %" PRIu64",\n" , s->cycles); -fprintf (f," \"min\": %" PRIu64",\n" , s->min); -fprintf (f," \"max\": %" PRIu64",\n" , s->max); +fprintf (f," \"cycles\": %lu,\n" , s->cycles); +fprintf (f," \"min\": %ld,\n" , s->min); +fprintf (f," \"max\": %ld,\n" , s->max);fprintf (f," \"avg\": %.2f,\n" , s->avg/s->cycles);fprintf (f," \"cpu\": %d\n" , par->cpu);fprintf (f," }%s\n" , i == num_threads -1 ?"" :"," );Signature · 8 lines
Christian Eggers Embedded software developer Arnold & Richter Cine Technik GmbH & Co. Betriebs KG Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918 Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477 Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler
Are you seeing a compile time warning on some systems?
John
Quoted 7 lines · John Kacur
Quoted 4 lines · Christian Eggers
time_tis "long" or "long long" (depending on the system). So it should be safe to convert it to "long long", in order to get a consistent data type on all systems.
Quoted 5 lines
Quoted 4 lines
Signed-off-by Christian Eggers <[email protected]>---
fprintf(f, " }%s\n", i == num_threads - 1 ? "" : ",");
[...}Are you seeing a compile time warning on some systems?
Yes, I do. I have an ARM32 system with 64 bit time_t.
I think that some of the printf format strings are simply wrong (e.g. using PRIu64 for a "long int"). For time_t, some systems require "%ld" while others require "%lld". Casting the values to "long long" seems to be easier compared to have individual format strings for different platforms.
regards
Christian
Quoted 12 lines · Christian Eggers
Quoted 11 lines · John Kacur
Quoted 8 lines · Christian Eggers
time_tis "long" or "long long" (depending on the system). So it should be safe to convert it to "long long", in order to get a consistent data type on all systems.Signed-off-by Christian Eggers <[email protected]>---
fprintf(f, " }%s\n", i == num_threads - 1 ? "" : ",");[...}
Quoted 8 lines
Quoted 1 line
Are you seeing a compile time warning on some systems?
Yes, I do. I have an ARM32 system with 64 bit
time_t.I think that some of the printf format strings are simply wrong (e.g. using PRIu64 for a "long int"). For
time_t, some systems require "%ld" while others require "%lld". Casting the values to "long long" seems to be easier compared to have individual format strings for different platforms.
Indeed, that was my fault. I've also send out patches for this a couple of weeks ago IIRC.
Quoted 1 line · John Kacur
Are you seeing a compile time warning on some systems?
My wild guess would be 32bit systems.
Quoted 1 line
John
Sebastian
Quoted 4 lines · Sebastian Andrzej Siewior
Quoted 1 line · John Kacur
Are you seeing a compile time warning on some systems?
My wild guess would be 32bit systems.
haha, mine too, but is it too much to ask for some better descriptions in the patches than, "fix printf format errors"?
Quoted 6 lines
Quoted 2 lines
John
Sebastian
Quoted 11 lines · John Kacur
Quoted 4 lines · Sebastian Andrzej Siewior
Quoted 1 line · John Kacur
Are you seeing a compile time warning on some systems?
My wild guess would be 32bit systems.
haha, mine too, but is it too much to ask for some better descriptions in the patches than, "fix printf format errors"?
nope.
Not sure the author is aware if the request :)
Sebastian
Quoted 94 lines · Christian Eggers
time_tis "long" or "long long" (depending on the system). So it should be safe to convert it to "long long", in order to get a consistent data type on all systems.Signed-off-by Christian Eggers <[email protected]>--- src/cyclictest/cyclictest.c | 8 ++++---- src/hackbench/hackbench.c | 2 +- src/sched_deadline/cyclicdeadline.c | 6 +++--- src/signaltest/signaltest.c | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-)src/cyclictest/cyclictest.c +4
-4@@ -1751,15 +1751,15 @@ static void write_stats(FILE *f, void *data)if (s->hist_array[j] ==0 )continue ;fprintf (f,"%s" , comma ?",\n" :"\n" ); -fprintf (f," \"%u\": %" PRIu64, j, s->hist_array[j]); +fprintf (f," \"%u\": %ld" , j, s->hist_array[j]); comma =1 ; }if (comma)fprintf (f,"\n" );fprintf (f," },\n" ); -fprintf (f," \"cycles\": %" PRIu64",\n" , s->cycles); -fprintf (f," \"min\": %" PRIu64",\n" , s->min); -fprintf (f," \"max\": %" PRIu64",\n" , s->max); +fprintf (f," \"cycles\": %lu,\n" , s->cycles); +fprintf (f," \"min\": %ld,\n" , s->min); +fprintf (f," \"max\": %ld,\n" , s->max);fprintf (f," \"avg\": %.2f,\n" , s->avg/s->cycles);fprintf (f," \"cpu\": %d,\n" , par[i]->cpu);fprintf (f," \"node\": %d\n" , par[i]->node);src/hackbench/hackbench.c +1
-1@@ -505,7 +505,7 @@ int main(int argc, char *argv[])/* Print time... */ if (timer_started) {timersub (&stop, &start, &diff); -printf ("Time: %lu.%03lu\n" , diff.tv_sec, diff.tv_usec/1000 ); +printf ("Time: %lld.%03lld\n" , (long long )diff.tv_sec, (long long )diff.tv_usec/1000 ); }else fprintf (stderr,"No measurements available\n" );src/sched_deadline/cyclicdeadline.c +3
-3@@ -978,9 +978,9 @@ static void write_stats(FILE *f, void *data)for (i =0 ; i < nr_threads; i++) { s = &sd[i].stat;fprintf (f," \"%u\": {\n" , i); -fprintf (f," \"cycles\": %" PRIu64",\n" , s->cycles); -fprintf (f," \"min\": %" PRIu64",\n" , s->min); -fprintf (f," \"max\": %" PRIu64",\n" , s->max); +fprintf (f," \"cycles\": %lu,\n" , s->cycles); +fprintf (f," \"min\": %ld,\n" , s->min); +fprintf (f," \"max\": %ld,\n" , s->max);fprintf (f," \"avg\": %.2f\n" , s->avg/s->cycles);fprintf (f," }%s\n" , i == nr_threads -1 ?"" :"," ); }src/signaltest/signaltest.c +3
-3@@ -392,9 +392,9 @@ static void write_stats(FILE *f, void *data)for (i =0 ; i < num_threads; i++) {fprintf (f," \"%u\": {\n" , i); s = &par->stats[i]; -fprintf (f," \"cycles\": %" PRIu64",\n" , s->cycles); -fprintf (f," \"min\": %" PRIu64",\n" , s->min); -fprintf (f," \"max\": %" PRIu64",\n" , s->max); +fprintf (f," \"cycles\": %lu,\n" , s->cycles); +fprintf (f," \"min\": %ld,\n" , s->min); +fprintf (f," \"max\": %ld,\n" , s->max);fprintf (f," \"avg\": %.2f,\n" , s->avg/s->cycles);fprintf (f," \"cpu\": %d\n" , par->cpu);fprintf (f," }%s\n" , i == num_threads -1 ?"" :"," );Signature · 8 lines
Christian Eggers Embedded software developer Arnold & Richter Cine Technik GmbH & Co. Betriebs KG Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRA 57918 Persoenlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH Sitz: Muenchen - Registergericht: Amtsgericht Muenchen - Handelsregisternummer: HRB 54477 Geschaeftsfuehrer: Dr. Michael Neuhaeuser; Stephan Schenk; Walter Trauninger; Markus Zeiler
I took the patches that Daniel Wagner already sent for cyclictest and cyclicdeadline. Please make sure they work for you.
If you send me separate patches for hackbench and for signaltest I'll take them.
Thanks
John Kacur