Fix various lgtm warning (#16497)
* Wrong type of arguments to formatting function root/shlr/mpc/mpc.c * Overflow in uncontrolled allocation size ./libr/socket/run.c * Multiplication result converted to larger type ./libr/core/cmd_print.c * Multiplication result converted to larger type ./libr/bin/p/bin_dyldcache.c * Multiplication result converted to larger type ./libr/core/linux_heap_glibc.c * Multiplication result converted to larger type ./libr/core/visual.c * Comparison of narrow type with wide type in loop condition ./libr/core/p/core_java.c * Fix various warning -Wall ./libr/core/p/core_java.c * Multiplication result converted to larger type ./libr/bin/format/mach0/mach0.c * Multiplication result converted to larger type ./libr/util/print.c * Multiplication result converted to larger type ./libr/asm/asm.c * Fix small warning python * Fix type error and declaration inside loop * Reset mpc * replace size_t * Fix space missing, type and format
This commit is contained in:
parent
7743d5e829
commit
ef07476e38
|
@ -617,8 +617,8 @@ R_API RAsmCode* r_asm_mdisassemble(RAsm *a, const ut8 *buf, int len) {
|
|||
ut64 pc = a->pc;
|
||||
RAsmOp op;
|
||||
ut64 idx;
|
||||
int ret, slen;
|
||||
const int addrbytes = a->user ? ((RCore *)a->user)->io->addrbytes : 1;
|
||||
size_t ret, slen;
|
||||
const size_t addrbytes = a->user? ((RCore *)a->user)->io->addrbytes: 1;
|
||||
|
||||
if (!(acode = r_asm_code_new ())) {
|
||||
return NULL;
|
||||
|
|
|
@ -2831,7 +2831,8 @@ const struct symbol_t *MACH0_(get_symbols)(struct MACH0_(obj_t) *bin) {
|
|||
}
|
||||
|
||||
static int parse_import_ptr(struct MACH0_(obj_t) *bin, struct reloc_t *reloc, int idx) {
|
||||
int i, j, sym, wordsize;
|
||||
int i, j, sym;
|
||||
size_t wordsize;
|
||||
ut32 stype;
|
||||
wordsize = MACH0_(get_bits)(bin) / 8;
|
||||
if (idx < 0 || idx >= bin->nsymtab) {
|
||||
|
|
|
@ -673,7 +673,7 @@ static RDyldRebaseInfo *get_rebase_info(RBinFile *bf, RDyldCache *cache) {
|
|||
}
|
||||
|
||||
if (slide_info.entries_count > 0) {
|
||||
ut64 size = slide_info.entries_count * slide_info.entries_size;
|
||||
ut64 size = (ut64) slide_info.entries_count * (ut64) slide_info.entries_size;
|
||||
ut64 at = cache->hdr->slideInfoOffset + slide_info.entries_offset;
|
||||
tmp_buf_2 = malloc (size);
|
||||
if (!tmp_buf_2) {
|
||||
|
|
|
@ -3338,8 +3338,8 @@ static inline void matchBar(ut8 *ptr, int i) {
|
|||
}
|
||||
}
|
||||
|
||||
static ut8 *analBars(RCore *core, int type, int nblocks, int blocksize, int skipblocks, ut64 from) {
|
||||
int j, i = 0;
|
||||
static ut8 *analBars(RCore *core, size_t type, size_t nblocks, size_t blocksize, size_t skipblocks, ut64 from) {
|
||||
size_t j, i = 0;
|
||||
ut8 *ptr = calloc (1, nblocks);
|
||||
if (!ptr) {
|
||||
eprintf ("Error: failed to malloc memory");
|
||||
|
@ -5432,7 +5432,7 @@ static int cmd_print(void *data, const char *input) {
|
|||
pj_a (pj);
|
||||
r_list_sort (f->bbs, bb_cmpaddr);
|
||||
r_list_foreach (f->bbs, locs_it, b) {
|
||||
|
||||
|
||||
ut8 *buf = malloc (b->size);
|
||||
if (buf) {
|
||||
r_io_read_at (core->io, b->addr, buf, b->size);
|
||||
|
|
|
@ -152,7 +152,7 @@ static void GH(get_brks)(RCore *core, GHT *brk_start, GHT *brk_end) {
|
|||
}
|
||||
|
||||
static void GH(print_arena_stats)(RCore *core, GHT m_arena, MallocState *main_arena, GHT global_max_fast, int format) {
|
||||
int i, j, k, start;
|
||||
size_t i, j, k, start;
|
||||
GHT align = 12 * SZ + sizeof (int) * 2;
|
||||
const int tcache = r_config_get_i (core->config, "dbg.glibc.tcache");
|
||||
RConsPrintablePalette *pal = &r_cons_singleton ()->context->pal;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -254,7 +254,7 @@ static bool __core_visual_gogo (RCore *core, int ch) {
|
|||
break;
|
||||
}
|
||||
(void)p->consbind.get_size (&scr_rows);
|
||||
int scols = r_config_get_i (core->config, "hex.cols");
|
||||
ut64 scols = r_config_get_i (core->config, "hex.cols");
|
||||
ret = r_core_seek (core, r_itv_end (map->itv) - (scr_rows - 2) * scols, 1);
|
||||
}
|
||||
if (ret != -1) {
|
||||
|
|
|
@ -81,7 +81,7 @@ typedef struct r_io_t {
|
|||
int va; //all of this config stuff must be in 1 int
|
||||
int ff;
|
||||
int Oxff;
|
||||
int addrbytes;
|
||||
size_t addrbytes;
|
||||
int aslr;
|
||||
int autofd;
|
||||
int cached;
|
||||
|
|
|
@ -138,7 +138,7 @@ R_API void r_print_set_is_interrupted_cb(RPrintIsInterruptedCallback cb);
|
|||
|
||||
/* ... */
|
||||
R_API char *r_print_hexpair(RPrint *p, const char *str, int idx);
|
||||
R_API void r_print_hex_from_bin (RPrint *p, char *bin_str);
|
||||
R_API void r_print_hex_from_bin(RPrint *p, char *bin_str);
|
||||
R_API RPrint *r_print_new(void);
|
||||
R_API RPrint *r_print_free(RPrint *p);
|
||||
R_API bool r_print_mute(RPrint *p, int x);
|
||||
|
@ -146,9 +146,9 @@ R_API void r_print_set_flags(RPrint *p, int _flags);
|
|||
R_API void r_print_unset_flags(RPrint *p, int flags);
|
||||
R_API void r_print_addr(RPrint *p, ut64 addr);
|
||||
R_API void r_print_section(RPrint *p, ut64 at);
|
||||
R_API void r_print_columns (RPrint *p, const ut8 *buf, int len, int height);
|
||||
R_API void r_print_columns(RPrint *p, const ut8 *buf, int len, int height);
|
||||
R_API void r_print_hexii(RPrint *p, ut64 addr, const ut8 *buf, int len, int step);
|
||||
R_API void r_print_hexdump(RPrint *p, ut64 addr, const ut8 *buf, int len, int base, int step, int zoomsz);
|
||||
R_API void r_print_hexdump(RPrint *p, ut64 addr, const ut8 *buf, int len, int base, int step, size_t zoomsz);
|
||||
R_API void r_print_hexdump_simple(const ut8 *buf, int len);
|
||||
R_API int r_print_jsondump(RPrint *p, const ut8 *buf, int len, int wordsize);
|
||||
R_API void r_print_hexpairs(RPrint *p, ut64 addr, const ut8 *buf, int len);
|
||||
|
|
|
@ -162,15 +162,16 @@ static char *getstr(const char *src) {
|
|||
{
|
||||
char *pat = strchr (src + 1, '@');
|
||||
if (pat) {
|
||||
int i, len, rep;
|
||||
size_t len;
|
||||
long i, rep;
|
||||
*pat++ = 0;
|
||||
rep = atoi (src + 1);
|
||||
rep = strtol (src + 1, NULL, 10);
|
||||
len = strlen (pat);
|
||||
if (rep > 0) {
|
||||
char *buf = malloc (rep);
|
||||
if (buf) {
|
||||
for (i = 0; i < rep; i++) {
|
||||
buf[i] = pat[i%len];
|
||||
buf[i] = pat[i % len];
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
|
|
|
@ -808,11 +808,12 @@ R_API void r_print_section(RPrint *p, ut64 at) {
|
|||
}
|
||||
}
|
||||
|
||||
R_API void r_print_hexdump(RPrint *p, ut64 addr, const ut8 *buf, int len, int base, int step, int zoomsz) {
|
||||
PrintfCallback printfmt = (PrintfCallback) printf;
|
||||
R_API void r_print_hexdump(RPrint *p, ut64 addr, const ut8 *buf, int len, int base, int step, size_t zoomsz) {
|
||||
PrintfCallback printfmt = (PrintfCallback)printf;
|
||||
bool c = p? (p->flags & R_PRINT_FLAGS_COLOR): false;
|
||||
const char *color_title = c? (Pal (p, offset): Color_MAGENTA): "";
|
||||
int i, j, k, inc = p? p->cols : 16;
|
||||
int inc = p? p->cols : 16;
|
||||
size_t i, j, k;
|
||||
int sparse_char = 0;
|
||||
int stride = 0;
|
||||
int col = 0; // selected column (0=none, 1=hex, 2=ascii)
|
||||
|
|
|
@ -83,7 +83,7 @@ def main():
|
|||
match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
|
||||
if match:
|
||||
filename = match.group(2)
|
||||
if filename == None:
|
||||
if filename is None:
|
||||
continue
|
||||
|
||||
if args.regex is not None:
|
||||
|
@ -101,8 +101,6 @@ def main():
|
|||
line_count = int(match.group(3))
|
||||
if line_count == 0:
|
||||
continue
|
||||
end_line = start_line + line_count - 1
|
||||
ranges = []
|
||||
range_start, range_end = None, None
|
||||
range_line = -1
|
||||
debug(line_count)
|
||||
|
|
Loading…
Reference in New Issue