From 63df67be95c2bf23c14dc83d82cb38f871c4d544 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 24 Dec 2013 23:38:25 +0200 Subject: [PATCH] fix some 32bit-host issues --- tools/protoparse.h | 26 +++++++++++++------------- tools/translate.c | 17 +++++++++-------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/tools/protoparse.h b/tools/protoparse.h index 4a1b0a0..3a51438 100644 --- a/tools/protoparse.h +++ b/tools/protoparse.h @@ -234,7 +234,7 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) kt = check_type(p, &ret); if (kt == NULL) { - printf("%s:%d:%ld: unhandled return in '%s'\n", + printf("%s:%d:%zd: unhandled return in '%s'\n", hdrfn, hdrfline, (p - protostr) + 1, protostr); return -1; } @@ -245,7 +245,7 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) p = next_idt(buf, sizeof(buf), p); p = sskip(p); if (buf[0] == 0) { - printf("%s:%d:%ld: var name missing\n", + printf("%s:%d:%zd: var name missing\n", hdrfn, hdrfline, (p - protostr) + 1); return -1; } @@ -269,7 +269,7 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) p = next_word(cconv, sizeof(cconv), p); p = sskip(p); if (cconv[0] == 0) { - printf("%s:%d:%ld: cconv missing\n", + printf("%s:%d:%zd: cconv missing\n", hdrfn, hdrfline, (p - protostr) + 1); return -1; } @@ -288,14 +288,14 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) else if (IS(cconv, "WINAPI")) pp->is_stdcall = 1; else { - printf("%s:%d:%ld: unhandled cconv: '%s'\n", + printf("%s:%d:%zd: unhandled cconv: '%s'\n", hdrfn, hdrfline, (p - protostr) + 1, cconv); return -1; } if (pp->is_fptr) { if (*p != '*') { - printf("%s:%d:%ld: '*' expected\n", + printf("%s:%d:%zd: '*' expected\n", hdrfn, hdrfline, (p - protostr) + 1); return -1; } @@ -305,7 +305,7 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) p = next_idt(buf, sizeof(buf), p); p = sskip(p); if (buf[0] == 0) { - printf("%s:%d:%ld: func name missing\n", + printf("%s:%d:%zd: func name missing\n", hdrfn, hdrfline, (p - protostr) + 1); return -1; } @@ -316,7 +316,7 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) if (!IS(regparm, "eax") && !IS(regparm, "ax") && !IS(regparm, "al")) { - printf("%s:%d:%ld: bad regparm: %s\n", + printf("%s:%d:%zd: bad regparm: %s\n", hdrfn, hdrfline, (p - protostr) + 1, regparm); return -1; } @@ -326,7 +326,7 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) if (pp->is_fptr) { if (*p != ')') { - printf("%s:%d:%ld: ')' expected\n", + printf("%s:%d:%zd: ')' expected\n", hdrfn, hdrfline, (p - protostr) + 1); return -1; } @@ -334,7 +334,7 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) } if (*p != '(') { - printf("%s:%d:%ld: '(' expected, got '%c'\n", + printf("%s:%d:%zd: '(' expected, got '%c'\n", hdrfn, hdrfline, (p - protostr) + 1, *p); return -1; } @@ -362,7 +362,7 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) p++; break; } - printf("%s:%d:%ld: ')' expected\n", + printf("%s:%d:%zd: ')' expected\n", hdrfn, hdrfline, (p - protostr) + 1); return -1; } @@ -373,7 +373,7 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) p1 = p; kt = check_type(p, &ret); if (kt == NULL) { - printf("%s:%d:%ld: unhandled type for arg%d\n", + printf("%s:%d:%zd: unhandled type for arg%d\n", hdrfn, hdrfline, (p - protostr) + 1, xarg); return -1; } @@ -385,7 +385,7 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) arg->fptr = calloc(1, sizeof(*arg->fptr)); ret = parse_protostr(p1, arg->fptr); if (ret < 0) { - printf("%s:%d:%ld: funcarg parse failed\n", + printf("%s:%d:%zd: funcarg parse failed\n", hdrfn, hdrfline, p1 - protostr); return -1; } @@ -399,7 +399,7 @@ static int parse_protostr(char *protostr, struct parsed_proto *pp) p = sskip(p); #if 0 if (buf[0] == 0) { - printf("%s:%d:%ld: idt missing for arg%d\n", + printf("%s:%d:%zd: idt missing for arg%d\n", hdrfn, hdrfline, (p - protostr) + 1, xarg); return -1; } diff --git a/tools/translate.c b/tools/translate.c index 8624d69..8c52603 100644 --- a/tools/translate.c +++ b/tools/translate.c @@ -157,7 +157,7 @@ struct parsed_data { struct { union { char *label; - int val; + unsigned int val; } u; int bt_i; } *d; @@ -194,7 +194,7 @@ static int g_sp_frame; static int g_stack_fsz; static int g_ida_func_attr; #define ferr(op_, fmt, ...) do { \ - printf("error:%s:#%ld: '%s': " fmt, g_func, (op_) - ops, \ + printf("error:%s:#%zd: '%s': " fmt, g_func, (op_) - ops, \ dump_op(op_), ##__VA_ARGS__); \ fcloseall(); \ exit(1); \ @@ -236,7 +236,8 @@ static int char_array_i(const char *array[], size_t len, const char *s) return -1; } -static void printf_number(char *buf, size_t buf_size, long number) +static void printf_number(char *buf, size_t buf_size, + unsigned long number) { // output in C-friendly form snprintf(buf, buf_size, number < 10 ? "%lu" : "0x%02lx", number); @@ -270,14 +271,14 @@ static int parse_reg(enum opr_lenmod *reg_lmod, const char *s) return -1; } -static long parse_number(const char *number) +static unsigned long parse_number(const char *number) { int len = strlen(number); const char *p = number; char *endp = NULL; + unsigned long ret; int neg = 0; int bad; - long ret; if (*p == '-') { neg = 1; @@ -286,11 +287,11 @@ static long parse_number(const char *number) if (len > 1 && *p == '0') p++; if (number[len - 1] == 'h') { - ret = strtol(p, &endp, 16); + ret = strtoul(p, &endp, 16); bad = (*endp != 'h'); } else { - ret = strtol(p, &endp, 10); + ret = strtoul(p, &endp, 10); bad = (*endp != 0); } if (bad) @@ -542,8 +543,8 @@ static int parse_operand(struct parsed_opr *opr, { struct parsed_proto pp; enum opr_lenmod tmplmod; + unsigned long number; int ret, len; - long number; int wordc_in; char *tmp; int i; -- 2.39.2