Skip to content

Commit

Permalink
unify-fex: Use int64_t and portable format specifiers for its output
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
n1tehawk committed Nov 13, 2016
1 parent dfce203 commit 8445d71
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/unify-fex.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/

#include <ctype.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand All @@ -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");
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8445d71

Please sign in to comment.