[PATCH weston] zunitc: use platform-independent macros for integer formatting

Emmanuel Gil Peyrot linkmauve at linkmauve.fr
Wed May 18 16:18:18 UTC 2016


From: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>

Fixes warnings and potential issues on 32-bit platforms, tested only on
ARM but I’d expect the same issue on i686.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve at linkmauve.fr>
---

This patch should be fine to land during the 1.11 beta, it doesn’t
change any functional element and is just about cleaner build.

 tools/zunitc/src/zuc_base_logger.c    | 15 +++++++++------
 tools/zunitc/src/zuc_junit_reporter.c | 34 ++++++++++++++++++----------------
 2 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/tools/zunitc/src/zuc_base_logger.c b/tools/zunitc/src/zuc_base_logger.c
index cdbd9ea..ffa127f 100644
--- a/tools/zunitc/src/zuc_base_logger.c
+++ b/tools/zunitc/src/zuc_base_logger.c
@@ -27,6 +27,7 @@
 
 #include "zuc_base_logger.h"
 
+#include <inttypes.h>
 #include <memory.h>
 #include <stdarg.h>
 #include <stdbool.h>
@@ -363,9 +364,9 @@ check_triggered(void *data, char const *file, int line,
 		} else {
 			printf("%s:%d: error: Value of: %s\n", file, line,
 			       expr2);
-			printf("  Actual: %ld\n", val2);
+			printf("  Actual: %"PRIdPTR"\n", val2);
 			printf("Expected: %s\n", expr1);
-			printf("Which is: %ld\n", val1);
+			printf("Which is: %"PRIdPTR"\n", val1);
 		}
 		break;
 	case ZUC_OP_NE:
@@ -376,8 +377,9 @@ check_triggered(void *data, char const *file, int line,
 			       (char *)val1, (char *)val2);
 		} else {
 			printf("%s:%d: error: ", file, line);
-			printf("Expected: (%s) %s (%s), actual: %ld vs %ld\n",
-			       expr1, zuc_get_opstr(op), expr2, val1, val2);
+			printf("Expected: (%s) %s (%s), actual: %"PRIdPTR" vs "
+			       "%"PRIdPTR"\n", expr1, zuc_get_opstr(op), expr2,
+			       val1, val2);
 		}
 		break;
 	case ZUC_OP_TERMINATE: {
@@ -392,7 +394,8 @@ check_triggered(void *data, char const *file, int line,
 		break;
 	default:
 		printf("%s:%d: error: ", file, line);
-		printf("Expected: (%s) %s (%s), actual: %ld vs %ld\n",
-		       expr1, zuc_get_opstr(op), expr2, val1, val2);
+		printf("Expected: (%s) %s (%s), actual: %"PRIdPTR" vs "
+		       "%"PRIdPTR"\n", expr1, zuc_get_opstr(op), expr2, val1,
+		       val2);
 	}
 }
diff --git a/tools/zunitc/src/zuc_junit_reporter.c b/tools/zunitc/src/zuc_junit_reporter.c
index a33b33f..369f035 100644
--- a/tools/zunitc/src/zuc_junit_reporter.c
+++ b/tools/zunitc/src/zuc_junit_reporter.c
@@ -30,6 +30,7 @@
 #if ENABLE_JUNIT_XML
 
 #include <fcntl.h>
+#include <inttypes.h>
 #include <libxml/parser.h>
 #include <memory.h>
 #include <stdio.h>
@@ -128,12 +129,12 @@ emit_event(xmlNodePtr parent, struct zuc_event *event)
 			}
 		} else {
 			if (asprintf(&msg, "%s:%d: error: Value of: %s\n"
-				     "  Actual: %ld\n"
-				     "Expected: %s\n"
-				     "Which is: %ld\n",
-				     event->file, event->line, event->expr2,
-				     event->val2, event->expr1,
-				     event->val1) < 0) {
+			             "  Actual: %"PRIdPTR"\n"
+			             "Expected: %s\n"
+			             "Which is: %"PRIdPTR"\n",
+			             event->file, event->line, event->expr2,
+			             event->val2, event->expr1,
+			             event->val1) < 0) {
 				msg = NULL;
 			}
 		}
@@ -151,12 +152,12 @@ emit_event(xmlNodePtr parent, struct zuc_event *event)
 			}
 		} else {
 			if (asprintf(&msg, "%s:%d: error: "
-				     "Expected: (%s) %s (%s),"
-				     " actual: %ld vs %ld\n",
-				     event->file, event->line,
-				     event->expr1, zuc_get_opstr(event->op),
-				     event->expr2, event->val1,
-				     event->val2) < 0) {
+			             "Expected: (%s) %s (%s),"
+			             " actual: %"PRIdPTR" vs %"PRIdPTR"\n",
+			             event->file, event->line,
+			             event->expr1, zuc_get_opstr(event->op),
+			             event->expr2, event->val1,
+			             event->val2) < 0) {
 				msg = NULL;
 			}
 		}
@@ -181,10 +182,11 @@ emit_event(xmlNodePtr parent, struct zuc_event *event)
 		break;
 	default:
 		if (asprintf(&msg, "%s:%d: error: "
-			     "Expected: (%s) %s (%s), actual: %ld vs %ld\n",
-			     event->file, event->line,
-			     event->expr1, zuc_get_opstr(event->op),
-			     event->expr2, event->val1, event->val2) < 0) {
+		             "Expected: (%s) %s (%s), actual: %"PRIdPTR" vs "
+		             "%"PRIdPTR"\n",
+		             event->file, event->line,
+		             event->expr1, zuc_get_opstr(event->op),
+		             event->expr2, event->val1, event->val2) < 0) {
 			msg = NULL;
 		}
 	}
-- 
2.8.2



More information about the wayland-devel mailing list