zunitc: use platform-independent macros for integer formatting

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@linkmauve.fr>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
dev
Emmanuel Gil Peyrot 9 years ago committed by Bryce Harrington
parent 8a120690a1
commit 1764d22f91
  1. 15
      tools/zunitc/src/zuc_base_logger.c
  2. 10
      tools/zunitc/src/zuc_junit_reporter.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);
}
}

@ -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,9 +129,9 @@ emit_event(xmlNodePtr parent, struct zuc_event *event)
}
} else {
if (asprintf(&msg, "%s:%d: error: Value of: %s\n"
" Actual: %ld\n"
" Actual: %"PRIdPTR"\n"
"Expected: %s\n"
"Which is: %ld\n",
"Which is: %"PRIdPTR"\n",
event->file, event->line, event->expr2,
event->val2, event->expr1,
event->val1) < 0) {
@ -152,7 +153,7 @@ emit_event(xmlNodePtr parent, struct zuc_event *event)
} else {
if (asprintf(&msg, "%s:%d: error: "
"Expected: (%s) %s (%s),"
" actual: %ld vs %ld\n",
" actual: %"PRIdPTR" vs %"PRIdPTR"\n",
event->file, event->line,
event->expr1, zuc_get_opstr(event->op),
event->expr2, event->val1,
@ -181,7 +182,8 @@ 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",
"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) {

Loading…
Cancel
Save