From 8445d71f4e5f7846ddda0704aa8ffba6dd46acce Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Sat, 29 Oct 2016 14:15:55 +0200 Subject: [PATCH] unify-fex: Use int64_t and portable format specifiers for its output Otherwise we could run into ambiguities with "long long", and Windows compilation is likely to bail out as it might not understand "%ll". Signed-off-by: Bernhard Nortmann --- tests/unify-fex.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unify-fex.c b/tests/unify-fex.c index 05f2acd..a1ff548 100644 --- a/tests/unify-fex.c +++ b/tests/unify-fex.c @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -36,7 +37,7 @@ int main(int argc, char **argv) FILE *input = stdin; char line[1024]; char *c, *p; - long long num; + int64_t num; if (argc >= 2) { input = fopen(argv[1], "r"); @@ -74,7 +75,7 @@ int main(int argc, char **argv) /* get pin number (including bank) */ num = ((p[6] - 'A') << 5) + strtoll(p + 7, &c, 10); c = strdup(c); - sprintf(p, "port:P%c%02lld%s", 'A' + (int)(num >> 5), (num & 0x1F), c); + sprintf(p, "port:P%c%02" PRId64 "%s", 'A' + (int)(num >> 5), num & 0x1F, c); free(c); /* check angle brackets to determine options count */ @@ -115,7 +116,7 @@ int main(int argc, char **argv) if (!hex && num >= 2147483648LL) num -= 4294967296LL; - sprintf(p, hex ? "0x%llx" : "%lld", num); + sprintf(p, hex ? "0x%" PRIx64 : "%" PRId64, num); } else { /* * We expect all other (= non-numeric) values