Skip to content

Commit 1c63b75

Browse files
committed
Fix asm text test errors on 32bit machines
1 parent beb4889 commit 1c63b75

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

arch/ARM/ARMInstPrinter.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -886,15 +886,17 @@ static inline void printNoHashImmediate(MCInst *MI, unsigned OpNum, SStream *O)
886886
static inline void printPImmediate(MCInst *MI, unsigned OpNum, SStream *O)
887887
{
888888
add_cs_detail(MI, ARM_OP_GROUP_PImmediate, OpNum);
889-
SStream_concat(O, "%s%d", "p",
890-
MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
889+
SStream_concat(
890+
O, "%s%" PRIu32, "p",
891+
(uint32_t)MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
891892
}
892893

893894
static inline void printCImmediate(MCInst *MI, unsigned OpNum, SStream *O)
894895
{
895896
add_cs_detail(MI, ARM_OP_GROUP_CImmediate, OpNum);
896-
SStream_concat(O, "%s%d", "c",
897-
MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
897+
SStream_concat(
898+
O, "%s%" PRIu32, "c",
899+
(uint32_t)MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
898900
}
899901

900902
static inline void printCoprocOptionImm(MCInst *MI, unsigned OpNum, SStream *O)
@@ -1364,8 +1366,9 @@ static inline void printFBits16(MCInst *MI, unsigned OpNum, SStream *O)
13641366
{
13651367
add_cs_detail(MI, ARM_OP_GROUP_FBits16, OpNum);
13661368
SStream_concat(O, "%s%s", markup("<imm:"), "#");
1367-
SStream_concat(O, "%d",
1368-
16 - MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
1369+
SStream_concat(
1370+
O, "%" PRId32,
1371+
(int32_t)16 - MCOperand_getImm(MCInst_getOperand(MI, (OpNum))));
13691372
SStream_concat0(O, markup(">"));
13701373
}
13711374

arch/X86/X86IntelInstPrinter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ static void printMemReference(MCInst *MI, unsigned Op, SStream *O)
11811181
SStream_concat0(O, " + ");
11821182
_printOperand(MI, Op + X86_AddrIndexReg, O);
11831183
if (ScaleVal != 1)
1184-
SStream_concat(O, "*%u", ScaleVal);
1184+
SStream_concat(O, "*%" PRIu64, ScaleVal);
11851185
NeedPlus = true;
11861186
}
11871187

suite/cstest/src/helper.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
/* By Do Minh Tuan <tuanit96@gmail.com>, 02-2019 */
33

44
#include <assert.h>
5-
#include <stdbool.h>
65
#include <stdarg.h>
7-
#include <stdint.h>
86
#include <capstone/platform.h>
9-
#include <stddef.h>
107
#include <string.h>
118
#include <stdlib.h>
129
#include <stdio.h>
@@ -91,9 +88,9 @@ void replace_negative(char *src, size_t src_len, size_t arch_bits)
9188
char *tmp, *result, *found, *origin, *orig_found;
9289
int cnt, valid;
9390
char *value, *tmp_tmp;
94-
unsigned short int tmp_short;
95-
unsigned int tmp_int;
96-
unsigned long int tmp_long;
91+
uint16_t tmp_short;
92+
uint32_t tmp_int;
93+
uint64_t tmp_long;
9794

9895
result = (char *)malloc(sizeof(char));
9996
result[0] = '\0';
@@ -124,11 +121,11 @@ void replace_negative(char *src, size_t src_len, size_t arch_bits)
124121
sscanf(value, "%hu", &tmp_short);
125122
add_str(&result, "%s%hu", tmp_tmp, tmp_short);
126123
} else if (arch_bits == 32) {
127-
sscanf(value, "%u", &tmp_int);
128-
add_str(&result, "%s%u", tmp_tmp, tmp_int);
124+
sscanf(value, "%" PRIu32, &tmp_int);
125+
add_str(&result, "%s%" PRIu32, tmp_tmp, tmp_int);
129126
} else if (arch_bits == 64) {
130-
sscanf(value, "%lu", &tmp_long);
131-
add_str(&result, "%s%lu", tmp_tmp, tmp_long);
127+
sscanf(value, "%" PRIu64, &tmp_long);
128+
add_str(&result, "%s%" PRIu64, tmp_tmp, tmp_long);
132129
}
133130

134131
} else

0 commit comments

Comments
 (0)