mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-07 02:23:58 +00:00
Fix more clang warnings (#12458)
This commit is contained in:
parent
2382f616b0
commit
97b94b3f94
@ -217,14 +217,17 @@ static int cb(RDiff *d, void *user, RDiffOp *op) {
|
||||
if (core) {
|
||||
int len = R_MAX (4, op->a_len);
|
||||
RAsmCode *ac = r_asm_mdisassemble (core->assembler, op->a_buf, len);
|
||||
char *acbufasm = strdup (ac->buf_asm);
|
||||
if (quiet) {
|
||||
char *bufasm = r_str_prefix_all (strdup (ac->buf_asm), "- ");
|
||||
char *bufasm = r_str_prefix_all (acbufasm, "- ");
|
||||
printf ("%s\n", bufasm);
|
||||
free (bufasm);
|
||||
free (acbufasm);
|
||||
} else {
|
||||
char *bufasm = r_str_prefix_all (strdup (ac->buf_asm), Color_RED"- ");
|
||||
char *bufasm = r_str_prefix_all (acbufasm, Color_RED"- ");
|
||||
printf ("%s"Color_RESET, bufasm);
|
||||
free (bufasm);
|
||||
free (acbufasm);
|
||||
}
|
||||
// r_asm_code_free (ac);
|
||||
}
|
||||
@ -247,14 +250,17 @@ static int cb(RDiff *d, void *user, RDiffOp *op) {
|
||||
if (core) {
|
||||
int len = R_MAX (4, op->b_len);
|
||||
RAsmCode *ac = r_asm_mdisassemble (core->assembler, op->b_buf, len);
|
||||
char *acbufasm = strdup (ac->buf_asm);
|
||||
if (quiet) {
|
||||
char *bufasm = r_str_prefix_all (strdup (ac->buf_asm), "+ ");
|
||||
char *bufasm = r_str_prefix_all (acbufasm, "+ ");
|
||||
printf ("%s\n", bufasm);
|
||||
free (bufasm);
|
||||
free (acbufasm);
|
||||
} else {
|
||||
char *bufasm = r_str_prefix_all (strdup (ac->buf_asm), Color_GREEN"+ ");
|
||||
char *bufasm = r_str_prefix_all (acbufasm, Color_GREEN"+ ");
|
||||
printf ("%s\n" Color_RESET, bufasm);
|
||||
free (bufasm);
|
||||
free (acbufasm);
|
||||
}
|
||||
// r_asm_code_free (ac);
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ static const char *arg(csh *handle, cs_insn *insn, char *buf, int n) {
|
||||
#define ARG(x) (*str[x]!=0)?str[x]:arg(handle, insn, str[x], x)
|
||||
|
||||
static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, csh *handle, cs_insn *insn) {
|
||||
char str[8][32];
|
||||
char str[8][32] = {0};
|
||||
int i;
|
||||
|
||||
r_strbuf_init (&op->esil);
|
||||
|
@ -441,7 +441,8 @@ R_API int r_anal_var_rename(RAnal *a, ut64 addr, int scope, char kind, const cha
|
||||
}
|
||||
if (!old_name) {
|
||||
old_name = stored_name;
|
||||
} else if (strcmp (stored_name, old_name)) {
|
||||
}
|
||||
if (strcmp (stored_name, old_name)) {
|
||||
return 0;
|
||||
}
|
||||
sdb_unset (DB, key, 0);
|
||||
|
@ -4873,9 +4873,8 @@ struct arc_operand_value *
|
||||
get_ext_suffix (char *s, char field)
|
||||
{
|
||||
struct arc_ext_operand_value *suffix = arc_ext_operands;
|
||||
char ctype;
|
||||
char ctype = 0;
|
||||
|
||||
ctype = 0;
|
||||
switch(field){
|
||||
case 'e' :
|
||||
ctype = arc_mach_a4 ? CACHEBYPASS5 : 0;
|
||||
|
@ -504,8 +504,6 @@ static inline int cr16_decode_ld_st(const ut8 *instr, struct cr16_cmd *cmd) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = 2;
|
||||
|
||||
switch ((c >> 11) & (~0x4)) {
|
||||
case 0x12:
|
||||
ret = 4;
|
||||
@ -561,7 +559,6 @@ static inline int cr16_decode_ld_st(const ut8 *instr, struct cr16_cmd *cmd) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = 2;
|
||||
switch (c >> 14) {
|
||||
case 0x3:
|
||||
ret = 2;
|
||||
|
@ -907,7 +907,6 @@ int h8300_decode_command(const ut8 *instr, struct h8300_cmd *cmd)
|
||||
case 0x70:
|
||||
case 0x71:
|
||||
case 0x72:
|
||||
ret = decode_imm2abs8(instr, cmd);
|
||||
ret = decode_imm2abs8(instr, cmd);
|
||||
break;
|
||||
default:
|
||||
|
@ -804,6 +804,7 @@ static Sdb *store_versioninfo_gnu_verdef(ELFOBJ *bin, Elf_(Shdr) *shdr, int sz)
|
||||
}
|
||||
Elf_(Verdef) *defs = calloc (shdr->sh_size, sizeof (char));
|
||||
if (!defs) {
|
||||
bprintf ("Cannot allocate memory (Check Elf_(Verdef))\n");
|
||||
return false;
|
||||
}
|
||||
if (bin->shstrtab && shdr->sh_name < bin->shstrtab_size) {
|
||||
@ -812,10 +813,6 @@ static Sdb *store_versioninfo_gnu_verdef(ELFOBJ *bin, Elf_(Shdr) *shdr, int sz)
|
||||
if (link_shdr && bin->shstrtab && link_shdr->sh_name < bin->shstrtab_size) {
|
||||
link_section_name = &bin->shstrtab[link_shdr->sh_name];
|
||||
}
|
||||
if (!defs) {
|
||||
bprintf ("Cannot allocate memory (Check Elf_(Verdef))\n");
|
||||
return NULL;
|
||||
}
|
||||
sdb = sdb_new0 ();
|
||||
end = (char *)defs + shdr->sh_size;
|
||||
sdb_set (sdb, "section_name", section_name, 0);
|
||||
|
@ -2127,7 +2127,6 @@ struct reloc_t* MACH0_(get_relocs)(struct MACH0_(obj_t)* bin) {
|
||||
if (seg_idx < 0 || seg_idx >= bin->nsegs) {
|
||||
bprintf ("Error: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB"
|
||||
" has unexistent segment %d\n", seg_idx);
|
||||
addr = 0LL;
|
||||
R_FREE (relocs);
|
||||
return 0; // early exit to avoid future mayhem
|
||||
} else {
|
||||
|
@ -86,7 +86,7 @@ struct PE_(r_bin_pe_obj_t)* r_bin_pemixed_init_native(struct PE_(r_bin_pe_obj_t)
|
||||
dotnet_offset += sizeof (PE_(image_nt_headers));
|
||||
dotnet_offset -= sizeof (PE_(image_data_directory)) * 2;
|
||||
|
||||
if (!(zero_out = (ut8*) calloc (2, sizeof (ut32)))) {
|
||||
if (!(zero_out = (ut8*) calloc (2, 4 * sizeof (ut8)))) {
|
||||
// can't call PE_(r_bin_pe_free) since this will free the underlying pe_bin
|
||||
// object which we may need for later
|
||||
// PE_(r_bin_pe_free) (sub_bin_native);
|
||||
|
@ -1395,7 +1395,6 @@ static EDemanglerErr parse_microsoft_mangled_name(char *sym, char **demangled_na
|
||||
if (r_list_length (func_args)) {
|
||||
copy_string (&func_str, "(", 0);
|
||||
i = r_list_length (func_args);
|
||||
it = r_list_iterator (func_args);
|
||||
r_list_foreach (func_args, it, str_arg) {
|
||||
copy_string (&func_str, str_arg->str_ptr, 0);
|
||||
if (--i) {
|
||||
|
@ -207,7 +207,6 @@ while_end:
|
||||
if (fail) {
|
||||
ZERO_FILL (grep->tokens);
|
||||
grep->tokens_used = 0;
|
||||
fail = 0;
|
||||
break;
|
||||
}
|
||||
switch (*ptr2) {
|
||||
|
@ -2143,7 +2143,6 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd, char *colon, bool *tmpseek
|
||||
free (line);
|
||||
if (oseek != UT64_MAX) {
|
||||
r_core_seek (core, oseek, 1);
|
||||
oseek = UT64_MAX;
|
||||
}
|
||||
if (pipefd != -1) {
|
||||
r_cons_flush ();
|
||||
@ -2901,14 +2900,12 @@ next_arroba:
|
||||
core->fixedarch = oldfixedarch;
|
||||
r_config_set (core->config, "asm.arch", tmpasm);
|
||||
R_FREE (tmpasm);
|
||||
is_arch_set = false;
|
||||
}
|
||||
if (tmpfd != -1) {
|
||||
r_io_use_fd (core->io, tmpfd);
|
||||
}
|
||||
if (is_bits_set) {
|
||||
r_config_set (core->config, "asm.bits", tmpbits);
|
||||
is_bits_set = false;
|
||||
core->fixedbits = oldfixedbits;
|
||||
}
|
||||
if (tmpeval) {
|
||||
@ -2917,7 +2914,6 @@ next_arroba:
|
||||
}
|
||||
if (flgspc != -123) {
|
||||
r_flag_space_set_i (core->flags, flgspc);
|
||||
flgspc = -123;
|
||||
}
|
||||
*ptr = '@';
|
||||
rc = ret;
|
||||
|
@ -7473,7 +7473,6 @@ static bool anal_fcn_data (RCore *core, const char *input) {
|
||||
}
|
||||
if (gap) {
|
||||
r_cons_printf ("Cd %d @ 0x%08"PFMT64x"\n", fcn->addr + fcn_size - gap_addr, gap_addr);
|
||||
gap = false;
|
||||
}
|
||||
free (bitmap);
|
||||
return true;
|
||||
|
@ -3828,7 +3828,6 @@ static bool cmd_dcu (RCore *core, const char *input) {
|
||||
r_core_cmd_help (core, help_msg_dcu);
|
||||
return false;
|
||||
}
|
||||
from = UT64_MAX;
|
||||
to = UT64_MAX;
|
||||
if (input[2] == '.') {
|
||||
ptr = strchr (input + 3, ' ');
|
||||
|
@ -2786,7 +2786,6 @@ static void cmd_print_bars(RCore *core, const char *input) {
|
||||
if (spc) {
|
||||
nblocks = r_num_math (core->num, spc + 1);
|
||||
if (nblocks < 1) {
|
||||
nblocks = core->blocksize;
|
||||
goto beach;
|
||||
}
|
||||
spc = strchr (spc + 1, ' ');
|
||||
|
@ -1000,7 +1000,6 @@ static RList *construct_rop_gadget(RCore *core, ut64 addr, ut8 *buf, int idx, co
|
||||
ht_uu_insert (localbadstart, idx, 1);
|
||||
r_asm_set_pc (core->assembler, addr);
|
||||
if (!r_asm_disassemble (core->assembler, &asmop, buf + idx, 15)) {
|
||||
opsz = 1;
|
||||
goto ret;
|
||||
} else {
|
||||
opsz = asmop.size;
|
||||
@ -2723,7 +2722,6 @@ reread:
|
||||
if (core->offset) {
|
||||
RInterval itv = {0, core->offset};
|
||||
if (!r_itv_overlap (search_itv, itv)) {
|
||||
empty_search_itv = true;
|
||||
ret = false;
|
||||
goto beach;
|
||||
} else {
|
||||
@ -3380,7 +3378,6 @@ reread:
|
||||
if (core->offset) {
|
||||
RInterval itv = {core->offset, -core->offset};
|
||||
if (!r_itv_overlap (search_itv, itv)) {
|
||||
empty_search_itv = true;
|
||||
ret = false;
|
||||
goto beach;
|
||||
} else {
|
||||
|
@ -2587,9 +2587,8 @@ static void ds_print_offset(RDisasmState *ds) {
|
||||
}
|
||||
if (ds->atabsoff > 0 && ds->show_offset) {
|
||||
if (ds->_tabsoff != ds->atabsoff) {
|
||||
char *b = ds->_tabsbuf;
|
||||
// TODO optimize to avoid down resizing
|
||||
b = malloc (ds->atabsoff + 1);
|
||||
char *b = malloc (ds->atabsoff + 1);
|
||||
if (b) {
|
||||
memset (b, ' ', ds->atabsoff);
|
||||
b[ds->atabsoff] = 0;
|
||||
@ -5687,7 +5686,7 @@ R_API int r_core_print_disasm_json(RCore *core, ut64 addr, ut8 *buf, int nb_byte
|
||||
|
||||
R_API int r_core_print_disasm_all(RCore *core, ut64 addr, int l, int len, int mode) {
|
||||
const bool scr_color = r_config_get_i (core->config, "scr.color");
|
||||
int i, ret, err = 0, count = 0;
|
||||
int i, ret, count = 0;
|
||||
ut8 *buf = core->block;
|
||||
char str[128];
|
||||
RAsmOp asmop;
|
||||
@ -5712,7 +5711,6 @@ R_API int r_core_print_disasm_all(RCore *core, ut64 addr, int l, int len, int mo
|
||||
}
|
||||
ret = r_asm_disassemble (core->assembler, &asmop, buf + i, l - i);
|
||||
if (ret < 1) {
|
||||
err = 1;
|
||||
switch (mode) {
|
||||
case 'j':
|
||||
case '=':
|
||||
|
@ -845,7 +845,7 @@ static int r_cmd_java_handle_replace_classname_value (RCore *core, const char *c
|
||||
res = r_cmd_java_get_class_names_from_input (cmd, &class_name,
|
||||
&class_name_len, &new_class_name, &new_class_name_len);
|
||||
|
||||
if (!class_name || !new_class_name) {
|
||||
if (!res || !class_name || !new_class_name) {
|
||||
r_cmd_java_print_cmd_help (JAVA_CMDS+REPLACE_CLASS_NAME_IDX);
|
||||
free (class_name);
|
||||
free (new_class_name);
|
||||
@ -1459,10 +1459,6 @@ static int r_cmd_java_handle_set_flags (RCore * core, const char * input) {
|
||||
case 'c': flag_value = r_bin_java_calculate_class_access_value (p); break;
|
||||
default: flag_value = -1;
|
||||
}
|
||||
if (flag_value == -1) {
|
||||
eprintf ("[-] r_cmd_java: in valid flag type provided .\n");
|
||||
res = true;
|
||||
}
|
||||
}
|
||||
IFDBG r_cons_printf ("Current args: (flag_value: 0x%04x addr: 0x%"PFMT64x")\n.", flag_value, addr, res);
|
||||
if (flag_value != -1) {
|
||||
|
@ -597,7 +597,7 @@ static RList *r_debug_native_pids (RDebug *dbg, int pid) {
|
||||
r_list_free (list);
|
||||
list = NULL;
|
||||
}
|
||||
while ((de = readdir (dh))) {
|
||||
while (dh && (de = readdir (dh))) {
|
||||
uid = 0;
|
||||
st = ' ';
|
||||
/* for each existing pid file... */
|
||||
|
@ -691,11 +691,13 @@ R_API char *r_str_newlen(const char *str, int len) {
|
||||
|
||||
R_API char *r_str_trunc_ellipsis(const char *str, int len) {
|
||||
char *buf;
|
||||
if (strlen (str) < len) {
|
||||
if (str && strlen (str) < len) {
|
||||
buf = strdup (str);
|
||||
} else {
|
||||
buf = r_str_newlen (str, len);
|
||||
strcpy (buf + len - 4, "...");
|
||||
if (buf) {
|
||||
strcpy (buf + len - 4, "...");
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
@ -771,6 +771,9 @@ R_API int r_num_between(RNum *num, const char *input_value) {
|
||||
char * const str = strdup (input_value);
|
||||
RList *nums = r_num_str_split_list (str);
|
||||
int len = r_list_length (nums);
|
||||
if (len < 3) {
|
||||
return -1;
|
||||
}
|
||||
if (len > 3) {
|
||||
len = 3;
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ static RList * build_str_list_from_iterable (RList *the_list) {
|
||||
char *str = dso_json_obj_to_str (json_obj);
|
||||
if (str && *str) {
|
||||
r_list_append (res, str);
|
||||
} else {
|
||||
free (str);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
Loading…
Reference in New Issue
Block a user