mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 21:29:49 +00:00
Fix almost all warnings from the msvc build
This commit is contained in:
parent
86b8013d84
commit
0b1e8eaecc
@ -1162,10 +1162,10 @@ static int esil_asreq(RAnalEsil *esil) {
|
||||
}
|
||||
if (isNegative) {
|
||||
if (regsize == 32) {
|
||||
op_num = -op_num;
|
||||
op_num = -(st64)op_num;
|
||||
if (op_num >> param_num) {
|
||||
op_num >>= param_num;
|
||||
op_num = -op_num;
|
||||
op_num = -(st64)op_num;
|
||||
} else {
|
||||
op_num = -1;
|
||||
}
|
||||
@ -1245,7 +1245,7 @@ static int esil_ror(RAnalEsil *esil) {
|
||||
if (src && r_anal_esil_get_parm (esil, src, &num2)) {
|
||||
ut64 mask = (regsize - 1);
|
||||
num2 &= mask;
|
||||
ut64 res = (num >> num2) | (num << ((-num2) & mask));
|
||||
ut64 res = (num >> num2) | (num << ((-(st64)num2) & mask));
|
||||
r_anal_esil_pushnum (esil, res);
|
||||
ret = 1;
|
||||
} else {
|
||||
@ -1266,7 +1266,7 @@ static int esil_rol(RAnalEsil *esil) {
|
||||
if (src && r_anal_esil_get_parm (esil, src, &num2)) {
|
||||
ut64 mask = (regsize - 1);
|
||||
num2 &= mask;
|
||||
ut64 res = (num << num2) | (num >> ((-num2) & mask));
|
||||
ut64 res = (num << num2) | (num >> ((-(st64)num2) & mask));
|
||||
r_anal_esil_pushnum (esil, res);
|
||||
ret = 1;
|
||||
} else {
|
||||
|
@ -1541,6 +1541,7 @@ static int opmov(RAsm *a, ut8 *data, const Opcode *op) {
|
||||
data[l++] = offset;
|
||||
}
|
||||
if (mod == 2) {
|
||||
// warning C4293: '>>': shift count negative or too big, undefined behavior
|
||||
data[l++] = offset >> 8;
|
||||
data[l++] = offset >> 16;
|
||||
data[l++] = offset >> 24;
|
||||
@ -1548,7 +1549,6 @@ static int opmov(RAsm *a, ut8 *data, const Opcode *op) {
|
||||
}
|
||||
}
|
||||
} else if (op->operands[1].type & OT_MEMORY) {
|
||||
|
||||
if (op->operands[0].type & OT_MEMORY) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ static int string_scan_range(RList *list, const ut8 *buf, int min,
|
||||
rc = r_utf8_encode (&tmp[i], r);
|
||||
runes++;
|
||||
/* Print the escape code */
|
||||
} else if (r && r < 0x100 && strchr ("\b\v\f\n\r\t\a\e\\", (char)r)) {
|
||||
} else if (r && r < 0x100 && strchr ("\b\v\f\n\r\t\a\033\\", (char)r)) {
|
||||
if ((i + 32) < sizeof (tmp) && r < 93) {
|
||||
tmp[i + 0] = '\\';
|
||||
tmp[i + 1] = " abtnvfr e "
|
||||
|
@ -433,7 +433,7 @@ R_API void r_line_autocomplete() {
|
||||
char *p;
|
||||
const char **argv = NULL;
|
||||
int i, j, opt = 0, plen, len = 0;
|
||||
int cols = r_cons_get_size (NULL) * 0.82;
|
||||
int cols = (int)(r_cons_get_size (NULL) * 0.82);
|
||||
|
||||
/* prepare argc and argv */
|
||||
if (I.completion.run) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2013-2016 - pancake */
|
||||
/* radare - LGPL - Copyright 2013-2017 - pancake */
|
||||
/* ansi 256 color extension for r_cons */
|
||||
/* https://en.wikipedia.org/wiki/ANSI_color */
|
||||
|
||||
@ -9,6 +9,7 @@ int value_range[6] = { 0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff};
|
||||
|
||||
static void init_color_table () {
|
||||
int i, r, g, b;
|
||||
// ansi colors
|
||||
color_table[0] = 0x000000;
|
||||
color_table[1] = 0x800000;
|
||||
color_table[2] = 0x008000;
|
||||
@ -25,6 +26,7 @@ static void init_color_table () {
|
||||
color_table[13] = 0xff00ff;
|
||||
color_table[14] = 0x00ffff;
|
||||
color_table[15] = 0xffffff;
|
||||
// color palette
|
||||
for (i = 0; i < 216; i++) {
|
||||
r = value_range[(i / 36) % 6];
|
||||
g = value_range[(i / 6) % 6];
|
||||
@ -32,6 +34,7 @@ static void init_color_table () {
|
||||
color_table[i + 16] = ((r << 16) & 0xffffff) +
|
||||
((g << 8) & 0xffff) + (b & 0xff);
|
||||
}
|
||||
// grayscale
|
||||
for (i = 0; i < 24; i++) {
|
||||
r = 8 + (i * 10);
|
||||
color_table[i + 232] = ((r << 16) & 0xffffff) +
|
||||
@ -50,25 +53,48 @@ static int lookup_rgb (int r, int g, int b) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int approximate_rgb (int r, int g, int b) {
|
||||
static ut32 approximate_rgb (int r, int g, int b) {
|
||||
bool grey = (r > 0 && r < 255 && r == g && r == b);
|
||||
const double k = (256.0 / 6.0);
|
||||
if (grey) {
|
||||
return 232 + (double)r / (255 / 24.1);
|
||||
return 232 + (int)((double)r / (255 / 24.1));
|
||||
}
|
||||
r = R_DIM (r / k, 0, 5);
|
||||
g = R_DIM (g / k, 0, 5);
|
||||
b = R_DIM (b / k, 0, 5);
|
||||
#if 0
|
||||
const double M = 16;
|
||||
double R = r;
|
||||
double G = g;
|
||||
double B = b;
|
||||
R = R /256 * 216;
|
||||
R /= 256 * 216;
|
||||
R /= 256 * 216;
|
||||
r = R = R_DIM (R / 16, 0, 16);
|
||||
g = G = R_DIM (G / 16, 0, 16);
|
||||
b = B = R_DIM (B / 16, 0, 16);
|
||||
r &= 0xff;
|
||||
g &= 0xff;
|
||||
b &= 0xff;
|
||||
return (ut32)((G * M * M) + (g * M) + b) + 16;
|
||||
#else
|
||||
const int k = (256.0 / 6);
|
||||
r = R_DIM (r / k, 0, 6);
|
||||
g = R_DIM (g / k, 0, 6);
|
||||
b = R_DIM (b / k, 0, 6);
|
||||
return 16 + (r * 36) + (g * 6) + b;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int rgb (int r, int g, int b) {
|
||||
int c = lookup_rgb (r, g, b);
|
||||
if (c == -1) return approximate_rgb (r, g, b);
|
||||
else return c;
|
||||
if (c == -1) {
|
||||
return approximate_rgb (r, g, b);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
static void unrgb (int color, int *r, int *g, int *b) {
|
||||
if (color < 0 || color > 256) {
|
||||
*r = *g = *b = 0;
|
||||
return;
|
||||
}
|
||||
int rgb = color_table[color];
|
||||
*r = (rgb >> 16) & 0xff;
|
||||
*g = (rgb >> 8) & 0xff;
|
||||
|
@ -204,7 +204,7 @@ R_API int r_cmd_call(RCmd *cmd, const char *input) {
|
||||
RListIter *iter;
|
||||
RCorePlugin *cp;
|
||||
if (!cmd || !input) {
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
if (!input || !*input) {
|
||||
if (cmd->nullcallback) {
|
||||
|
@ -3540,7 +3540,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
break;
|
||||
case '-': // "p-"
|
||||
mode = input[1];
|
||||
w = core->print->cols * 2.7;
|
||||
w = (int)(core->print->cols * 2.7);
|
||||
if (mode == 'j') {
|
||||
r_cons_strcat ("{");
|
||||
}
|
||||
@ -4044,7 +4044,7 @@ static int cmd_print(void *data, const char *input) {
|
||||
free (old_arch);
|
||||
free (new_arch);
|
||||
goto beach;
|
||||
} else if (core->blocksize_max < use_blocksize && (int) use_blocksize > -core->blocksize_max) {
|
||||
} else if (core->blocksize_max < use_blocksize && (int) use_blocksize > -(int)core->blocksize_max) {
|
||||
bw_disassemble = true;
|
||||
l = use_blocksize; // negative
|
||||
use_blocksize = -use_blocksize;
|
||||
|
@ -2278,6 +2278,9 @@ static int memcmpdiff(const ut8 *a, const ut8 *b, int len) {
|
||||
static void search_similar_pattern_in(RCore *core, int count, ut64 from, ut64 to) {
|
||||
ut64 addr = from;
|
||||
ut8 *block = calloc (core->blocksize, 1);
|
||||
if (!block) {
|
||||
return;
|
||||
}
|
||||
while (addr < to) {
|
||||
(void) r_io_read_at (core->io, addr, block, core->blocksize);
|
||||
if (r_cons_is_breaked ()) {
|
||||
@ -2289,7 +2292,7 @@ static void search_similar_pattern_in(RCore *core, int count, ut64 from, ut64 to
|
||||
int pc = (equal * 100) / core->blocksize;
|
||||
r_cons_printf ("0x%08"PFMT64x " %4d/%d %3d%% ", addr, equal, core->blocksize, pc);
|
||||
ut8 ptr[2] = {
|
||||
pc * 2.5, 0
|
||||
(ut8)(pc * 2.5), 0
|
||||
};
|
||||
r_print_fill (core->print, ptr, 1, UT64_MAX, core->blocksize);
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ static int cmd_seek(void *data, const char *input) {
|
||||
const char *u_num = inputnum? inputnum + 1: input + 1;
|
||||
off = r_num_math (core->num, u_num);
|
||||
if (*u_num == '-') {
|
||||
off = -off;
|
||||
off = -(st64)off;
|
||||
}
|
||||
}
|
||||
int sign = 1;
|
||||
|
@ -3225,7 +3225,7 @@ static void ds_print_ptr(RDisasmState *ds, int len, int idx) {
|
||||
ds_comment (ds, true, "; var %s", v->name);
|
||||
r_anal_var_free (v);
|
||||
} else {
|
||||
ds_comment (ds, true, "; var %d", (int)-refaddr);
|
||||
ds_comment (ds, true, "; var %d", -(int)refaddr);
|
||||
}
|
||||
} else {
|
||||
if (r_core_anal_address (core, refaddr) & R_ANAL_ADDR_TYPE_ASCII) {
|
||||
|
@ -1627,7 +1627,7 @@ R_API void r_core_rtr_session(RCore *core, const char *input) {
|
||||
while (!r_cons_is_breaked ()) {
|
||||
if (rtr_host[rtr_n].fd) {
|
||||
snprintf (prompt, sizeof (prompt),
|
||||
"fd:%d> ", rtr_host[rtr_n].fd->fd);
|
||||
"fd:%d> ", (int)(size_t)rtr_host[rtr_n].fd->fd);
|
||||
}
|
||||
free (r_line_singleton ()->prompt);
|
||||
r_line_singleton ()->prompt = strdup (prompt);
|
||||
|
@ -2575,17 +2575,17 @@ R_API void r_core_visual_title(RCore *core, int color) {
|
||||
if (autoblocksize) {
|
||||
switch (core->printidx) {
|
||||
case R_CORE_VISUAL_MODE_PRC: // prc
|
||||
r_core_block_size (core, core->cons->rows * hexcols * 3.5);
|
||||
r_core_block_size (core, (int)(core->cons->rows * hexcols * 3.5));
|
||||
break;
|
||||
case R_CORE_VISUAL_MODE_PX: // x
|
||||
case R_CORE_VISUAL_MODE_PXa: // pxa
|
||||
r_core_block_size (core, core->cons->rows * hexcols * 3.5);
|
||||
r_core_block_size (core, (int)(core->cons->rows * hexcols * 3.5));
|
||||
break;
|
||||
case R_CORE_VISUAL_MODE_PW: // XXX pw
|
||||
r_core_block_size (core, core->cons->rows * hexcols);
|
||||
r_core_block_size (core, (int)(core->cons->rows * hexcols));
|
||||
break;
|
||||
case R_CORE_VISUAL_MODE_PC: // XXX pc
|
||||
r_core_block_size (core, core->cons->rows * hexcols * 4);
|
||||
r_core_block_size (core, (int)(core->cons->rows * hexcols * 4));
|
||||
break;
|
||||
case R_CORE_VISUAL_MODE_PD: // pd
|
||||
case R_CORE_VISUAL_MODE_PDDBG: // pd+dbg
|
||||
|
@ -900,7 +900,7 @@ R_API bool r_fs_check(RFS *fs, const char *p) {
|
||||
RListIter *iter;
|
||||
char* path = strdup (p);
|
||||
if (!path) {
|
||||
return NULL;
|
||||
return false;
|
||||
}
|
||||
r_str_chop_path (path);
|
||||
r_list_foreach (fs->roots, iter, root) {
|
||||
|
@ -156,7 +156,7 @@ R_API RIOMap* r_io_map_new(RIO* io, int fd, int flags, ut64 delta, ut64 addr, ut
|
||||
map->delta = delta;
|
||||
if ((UT64_MAX - size + 1) < addr) {
|
||||
r_io_map_new (io, fd, flags, delta - addr, 0LL, size + addr, do_skyline);
|
||||
size = -addr;
|
||||
size = -(st64)addr;
|
||||
}
|
||||
// RIOMap describes an interval of addresses (map->from; map->to)
|
||||
map->itv.size = size;
|
||||
|
@ -204,8 +204,11 @@ static char *getstr(const char *src) {
|
||||
eprintf ("Invalid hexpair string\n");
|
||||
free (ret);
|
||||
return NULL;
|
||||
#if 0
|
||||
// what is this for??
|
||||
case '%':
|
||||
return (char *) strtoul (src + 1, NULL, 0);
|
||||
#endif
|
||||
}
|
||||
r_str_unescape ((ret = strdup (src)));
|
||||
return ret;
|
||||
|
@ -661,9 +661,7 @@ R_API int r_socket_ready(RSocket *s, int secs, int usecs) {
|
||||
|
||||
R_API char *r_socket_to_string(RSocket *s) {
|
||||
#if __WINDOWS__ && !defined(__CYGWIN__) //&& !defined(__MINGW64__)
|
||||
char *str = malloc (32);
|
||||
snprintf (str, 31, "fd%d", s->fd);
|
||||
return str;
|
||||
return r_str_newf ("fd%d", (int)(size_t)s->fd);
|
||||
#elif __UNIX__ || defined(__CYGWIN__)
|
||||
char *str = NULL;
|
||||
struct sockaddr sa;
|
||||
|
@ -147,7 +147,7 @@ R_API bool r_json_object_add (RJSVar* object, const char* name, RJSVar* value) {
|
||||
object->object.l = len;
|
||||
free (object->object.a);
|
||||
object->object.a = v;
|
||||
free (object->object.n);
|
||||
free ((void *)object->object.n);
|
||||
object->object.n = (const char**) c;
|
||||
return true;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ R_API char *r_num_units(char *buf, ut64 num) {
|
||||
if (num>=GB) { unit = 'G'; fnum = fnum/GB; } else
|
||||
if (num>=MB) { unit = 'M'; fnum = fnum/MB; } else
|
||||
if (num>=KB) { unit = 'K'; fnum = fnum/KB; } else
|
||||
{ unit = 0; fnum = num; }
|
||||
{ unit = 0; fnum = (double)num; }
|
||||
tnum = (int)((double)(fnum - (int)fnum)*10);
|
||||
if (tnum) {
|
||||
snprintf (buf, 31, "%.1f%c", fnum, unit);
|
||||
|
@ -8713,7 +8713,8 @@ R_API int U(r_bin_java_float_cp_set)(RBinJavaObj * bin, ut16 idx, float val) {
|
||||
r_bin_java_check_reset_cp_obj (cp_obj, R_BIN_JAVA_CP_FLOAT);
|
||||
cp_obj->tag = R_BIN_JAVA_CP_FLOAT;
|
||||
memcpy (bytes, (const char *) &val, 4);
|
||||
val = R_BIN_JAVA_UINT (bytes, 0);
|
||||
float *foo = (float*) bytes;
|
||||
val = *foo; //(float)R_BIN_JAVA_UINT (bytes, 0);
|
||||
memcpy (&cp_obj->info.cp_float.bytes.raw, (const char *) &val, 4);
|
||||
return true;
|
||||
}
|
||||
|
@ -31,12 +31,12 @@ SDB_API int sdb_num_set(Sdb *s, const char *key, ut64 v, ut32 cas) {
|
||||
SDB_API ut64 sdb_num_inc(Sdb *s, const char *key, ut64 n2, ut32 cas) {
|
||||
ut32 c;
|
||||
ut64 n = sdb_num_get (s, key, &c);
|
||||
if ((cas && c != cas) || (-n2 < n)) {
|
||||
ut64 res = n + n2;
|
||||
if ((cas && c != cas) || res < n) {
|
||||
return 0LL;
|
||||
}
|
||||
n += n2;
|
||||
sdb_num_set (s, key, n, cas);
|
||||
return n;
|
||||
sdb_num_set (s, key, res, cas);
|
||||
return res;
|
||||
}
|
||||
|
||||
SDB_API ut64 sdb_num_dec(Sdb *s, const char *key, ut64 n2, ut32 cas) {
|
||||
|
@ -1123,7 +1123,7 @@ static int like_cb(void *user, const char *k, const char *v) {
|
||||
if (lcd->array) {
|
||||
int idx = lcd->array_index;
|
||||
int newsize = lcd->array_size + sizeof (char*) * 2;
|
||||
const char **newarray = realloc (lcd->array, newsize);
|
||||
const char **newarray = (const char **)realloc (lcd->array, newsize);
|
||||
if (!newarray) {
|
||||
return 0;
|
||||
}
|
||||
@ -1163,7 +1163,7 @@ SDB_API char** sdb_like(Sdb *s, const char *k, const char *v, SdbForeachCallback
|
||||
lcd.array_index = 0;
|
||||
sdb_foreach (s, like_cb, &lcd);
|
||||
if (lcd.array_index == 0) {
|
||||
free (lcd.array);
|
||||
free ((void*)lcd.array);
|
||||
return NULL;
|
||||
}
|
||||
return (char**)lcd.array;
|
||||
|
Loading…
Reference in New Issue
Block a user