Skip to contentSkip to conversation

rt-tests, cyclictest - fix printf format for 32 bit systems

PATCH In review Frank Rowand 2 participants 2 messages Sep 28, 2011 – Sep 29, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rt-tests, cyclictest - fix printf format for 32 bit systems

The printf() format for a uint64_t is %l on a 64 bit system and %ll on a 32 bit system. Use the ugly but portable format descriptor.

---
src/cyclictest/cyclictest.c | 3 2 + 1 - 0 !

 1 file changed, 2 insertions(+), 1 deletion(-)
src/cyclictest/cyclictest.c +2 -1
Index: b/src/cyclictest/cyclictest.c
===================================================================
@@ -24,6 +24,7 @@
 #include <time.h>
 #include <errno.h>
 #include <limits.h>
+#include <inttypes.h>
 #include <linux/unistd.h>
 
 #include <sys/prctl.h>
@@ -1561,7 +1562,7 @@ int main(int argc, char **argv)
 		print_tids(parameters, num_threads);
 		if (break_thread_id) {
 			printf("# Break thread: %d\n", break_thread_id);
-			printf("# Break value: %lu\n", break_thread_value);
+			printf("# Break value: %" PRIu64 "\n", break_thread_value);
 		}
 	}
 	
#1 lore raw
Quoted 22 lines · Frank Rowand

The printf() format for a uint64_t is %l on a 64 bit system and %ll on a 32 bit system. Use the ugly but portable format descriptor.

---
src/cyclictest/cyclictest.c | 3 2 + 1 - 0 !

 1 file changed, 2 insertions(+), 1 deletion(-)

Index: b/src/cyclictest/cyclictest.c
===================================================================

src/cyclictest/cyclictest.c +1 -0
@@ -24,6 +24,7 @@
 #include <time.h>
 #include <errno.h>
 #include <limits.h>
+#include <inttypes.h>
 #include <linux/unistd.h>
 
 #include <sys/prctl.h>

src/cyclictest/cyclictest.c int main(int argc, char **argv) · line 1565

Quoted 5 lines
src/cyclictest/cyclictest.c +1 -1
@@ -1561,7 +1562,7 @@ int main(int argc, char **argv)
 		print_tids(parameters, num_threads);
 		if (break_thread_id) {
 			printf("# Break thread: %d\n", break_thread_id);
-			printf("# Break value: %lu\n", break_thread_value);
+			printf("# Break value: %" PRIu64 "\n", break_thread_value);

If you consider this ugly, you might prefer

	printf("# Break value: %llu\n", (unsigned long long)break_thread_value);

Best regards
Uwe

Signature · 6 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
--
To unsubscribe from this list: send the line "unsubscribe linux-rt-users" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html