Fix #5633 - Change x == NULL to correct syntax

This commit is contained in:
Sven Steinbauer 2016-09-19 13:44:47 +01:00 committed by radare
parent a86ae89f1d
commit 2996538700
167 changed files with 644 additions and 646 deletions

View File

@ -245,7 +245,7 @@ static int rabin_dump_symbols(int len) {
char *ret;
int olen = len;
if ((symbols = r_bin_get_symbols (bin)) == NULL)
if (!(symbols = r_bin_get_symbols (bin)))
return false;
r_list_foreach (symbols, iter, symbol) {
@ -278,7 +278,7 @@ static int rabin_dump_sections(char *scnname) {
char *ret;
int r;
if ((sections = r_bin_get_sections (bin)) == NULL)
if (!(sections = r_bin_get_sections (bin)))
return false;
r_list_foreach (sections, iter, section) {

View File

@ -1072,13 +1072,12 @@ int main(int argc, char **argv, char **envp) {
}
free (question);
}
} else {
// r_core_project_save (&r, prj);
if (debug && r_config_get_i (r.config, "dbg.exitkills")) {
r_debug_kill (r.dbg, 0, false, 9); // KILL
}
}
break;
}

View File

@ -39,7 +39,7 @@ static RCore* opencore(const char *f) {
r_config_set_i (c->config, "io.va", useva);
r_config_set_i (c->config, "anal.split", true);
if (f) {
if (r_core_file_open (c, f, 0, 0) == NULL) {
if (!r_core_file_open (c, f, 0, 0)) {
r_core_free (c);
return NULL;
}

View File

@ -108,7 +108,7 @@ static int rafind_open(char *file) {
io = r_io_new ();
fd = r_io_open_nomap (io, file, R_IO_READ, 0);
if (fd == NULL) {
if (!fd) {
eprintf ("Cannot open file '%s'\n", file);
return 1;
}

View File

@ -131,14 +131,14 @@ R_API RAnalOp * r_anal_ex_get_op(RAnal *anal, RAnalState *state, ut64 addr) {
if (current_op) return current_op;
IFDBG eprintf("[==] r_anal_ex_get_op: Parsing op @ 0x%04"PFMT64x"\n", addr);
if (anal->cur == NULL ||
(anal->cur->op_from_buffer == NULL && anal->cur->op == NULL) ) {
if (!anal->cur ||
(!anal->cur->op_from_buffer && !anal->cur->op) ) {
return NULL;
}
if (!r_anal_state_addr_is_valid(state, addr) ||
(anal->cur && (anal->cur->op == NULL && anal->cur->op_from_buffer == NULL))) {
(anal->cur && (!anal->cur->op && !anal->cur->op_from_buffer))) {
state->done = 1;
return NULL;
}
@ -165,10 +165,10 @@ R_API RAnalBlock * r_anal_ex_get_bb(RAnal *anal, RAnalState *state, ut64 addr) {
if (current_bb) return current_bb;
IFDBG eprintf("[==] r_anal_ex_get_bb: Parsing op @ 0x%04"PFMT64x"\n", addr);
if (r_anal_state_addr_is_valid(state, addr) && op == NULL)
if (r_anal_state_addr_is_valid(state, addr) && !op)
op = r_anal_ex_get_op(anal, state, addr);
if (op == NULL || !r_anal_state_addr_is_valid(state, addr)) {
if (!op || !r_anal_state_addr_is_valid (state, addr)) {
return NULL;
}
current_bb = r_anal_bb_new ();
@ -180,11 +180,11 @@ R_API RAnalBlock * r_anal_ex_get_bb(RAnal *anal, RAnalState *state, ut64 addr) {
if (r_anal_op_is_eob (op))
current_bb->type |= R_ANAL_BB_TYPE_LAST;
if (current_bb->op_bytes == NULL) {
if (!current_bb->op_bytes) {
current_bb->op_sz = state->current_op->size;
current_bb->op_bytes = malloc(current_bb->op_sz);
current_bb->op_bytes = malloc (current_bb->op_sz);
if (current_bb->op_bytes) {
int buf_len = r_anal_state_get_len( state, addr);
int buf_len = r_anal_state_get_len (state, addr);
if (current_bb->op_sz <buf_len) {
eprintf ("Oops\n");
r_anal_bb_free (current_bb);
@ -287,7 +287,7 @@ R_API RList * r_anal_ex_analysis_driver( RAnal *anal, RAnalState *state, ut64 ad
r_anal_ex_get_bb (anal, state, state->current_addr);
if ( state->current_bb_head == NULL ) {
if (!state->current_bb_head) {
state->current_bb_head = state->current_bb;
if (state->current_bb_head) {
state->current_bb_head->type |= R_ANAL_BB_TYPE_HEAD;

View File

@ -306,7 +306,7 @@ R_API const char *r_anal_data_kind(RAnal *a, ut64 addr, const ut8 *buf, int len)
if (str && !buf[i])
str++;
data = r_anal_data (a, addr + i, buf + i, len - i);
if (data == NULL) {
if (!data) {
i += word;
continue;
}

View File

@ -177,7 +177,7 @@ R_API int r_anal_diff_fcn(RAnal *anal, RList *fcns, RList *fcns2) {
/* Compare functions with the same name */
if (fcns) {
r_list_foreach (fcns, iter, fcn) {
if (fcn->type != R_ANAL_FCN_TYPE_SYM || fcn->name == NULL) {
if (fcn->type != R_ANAL_FCN_TYPE_SYM || !fcn->name) {
continue;
}
r_list_foreach (fcns2, iter2, fcn2) {

View File

@ -1349,7 +1349,7 @@ R_API int r_anal_fcn_add_bb(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 siz
bbi->size = addr - (bbi->addr);
}
}
if (bb == NULL) {
if (!bb) {
bb = appendBasicBlock (anal, fcn, addr);
if (!bb) {
eprintf ("appendBasicBlock failed\n");

View File

@ -163,7 +163,7 @@ static int arm_op32(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int le
ut32* code = (ut32 *)data;
struct winedbg_arm_insn *arminsn;
if (data == NULL)
if (!data)
return 0;
memset (op, '\0', sizeof (RAnalOp));
arminsn = arm_new();

View File

@ -17,7 +17,7 @@ static int countChar (const ut8 *buf, int len, char ch) {
static int bf_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
ut64 dst = 0LL;
if (op == NULL)
if (!op)
return 1;
/* Ayeeee! What's inside op? Do we have an initialized RAnalOp? Are we going to have a leak here? :-( */
memset (op, 0, sizeof (RAnalOp)); /* We need to refactorize this. Something like r_anal_op_init would be more appropiate */

View File

@ -9,7 +9,7 @@
static int dalvik_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {
int sz = dalvik_opcodes[data[0]].len;
if (op == NULL)
if (!op)
return sz;
memset (op, '\0', sizeof (RAnalOp));

View File

@ -61,7 +61,7 @@ static int ebc_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len)
ebc_command_t cmd;
ut8 opcode = buf[0] & EBC_OPCODE_MASK;
if (op == NULL)
if (!op)
return 2;
memset(op, 0, sizeof (RAnalOp));

View File

@ -539,7 +539,7 @@ static int h8300_op(RAnal *anal, RAnalOp *op, ut64 addr,
ut8 opcode = buf[0];
struct h8300_cmd cmd;
if (op == NULL)
if (!op)
return 2;
memset(op, 0, sizeof (RAnalOp));

View File

@ -207,7 +207,7 @@ static int handle_bb_cf_recursive_descent (RAnal *anal, RAnalState *state) {
ut64 addr = 0;
int result = 0;
if (bb == NULL) {
if (!bb) {
eprintf ("Error: unable to handle basic block @ 0x%08"PFMT64x"\n", addr);
return R_ANAL_RET_ERROR;
} else if (state->max_depth <= state->current_depth) {
@ -232,7 +232,7 @@ static int handle_bb_cf_recursive_descent (RAnal *anal, RAnalState *state) {
IFDBG eprintf (" - Handling a jmp @ 0x%04"PFMT64x" to 0x%04"PFMT64x".\n", addr, bb->jump);
// visited some other time
if (r_anal_state_search_bb (state, bb->jump) == NULL) {
if (!r_anal_state_search_bb (state, bb->jump)) {
jmp_list = r_anal_ex_perform_analysis ( anal, state, bb->jump );
if (jmp_list)
bb->jumpbb = (RAnalBlock *) r_list_get_n (jmp_list, 0);
@ -257,7 +257,7 @@ static int handle_bb_cf_recursive_descent (RAnal *anal, RAnalState *state) {
IFDBG eprintf (" - Handling a cjmp @ 0x%04"PFMT64x" jmp to 0x%04"PFMT64x" and fail to 0x%04"PFMT64x".\n", addr, bb->jump, bb->fail);
IFDBG eprintf (" - Handling jmp to 0x%04"PFMT64x".\n", bb->jump);
// visited some other time
if (r_anal_state_search_bb (state, bb->jump) == NULL) {
if (!r_anal_state_search_bb (state, bb->jump)) {
jmp_list = r_anal_ex_perform_analysis ( anal, state, bb->jump );
if (jmp_list)
bb->jumpbb = (RAnalBlock *) r_list_get_n (jmp_list, 0);
@ -275,7 +275,7 @@ static int handle_bb_cf_recursive_descent (RAnal *anal, RAnalState *state) {
encountered_stop = 1;
}
if (r_anal_state_search_bb (state, bb->fail) == NULL) {
if (!r_anal_state_search_bb (state, bb->fail)) {
jmp_list = r_anal_ex_perform_analysis ( anal, state, bb->fail );
if (jmp_list)
bb->failbb = (RAnalBlock *) r_list_get_n (jmp_list, 0);
@ -351,7 +351,7 @@ static int java_post_anal_linear_sweep(RAnal *anal, RAnalState *state, ut64 addr
ut64 *paddr64;
state->done = 0;
if (nodes == NULL || nodes->cfg_node_addrs == NULL) {
if (!nodes || !nodes->cfg_node_addrs) {
state->done = 1;
return R_ANAL_RET_ERROR;
}
@ -359,7 +359,7 @@ static int java_post_anal_linear_sweep(RAnal *anal, RAnalState *state, ut64 addr
while (r_list_length (nodes->cfg_node_addrs) > 0) {
paddr64 = r_list_get_n (nodes->cfg_node_addrs, 0);
r_list_del_n (nodes->cfg_node_addrs, 0);
if (paddr64 && r_anal_state_search_bb (state, *paddr64) == NULL) {
if (paddr64 && !r_anal_state_search_bb (state, *paddr64)) {
ut64 list_length = 0;
IFDBG eprintf (" - Visiting 0x%04"PFMT64x" for analysis.\n", *paddr64);
jmp_list = r_anal_ex_perform_analysis ( anal, state, *paddr64 );
@ -380,14 +380,14 @@ static int handle_bb_cf_linear_sweep (RAnal *anal, RAnalState *state) {
RAnalBlock *bb = state->current_bb;
RAnalJavaLinearSweep *nodes = state->user_state;
if (nodes == NULL || nodes->cfg_node_addrs == NULL) {
if (!nodes || !nodes->cfg_node_addrs) {
state->done = 1;
return R_ANAL_RET_ERROR;
}
ut64 addr = 0;
int result = 0;
if (bb == NULL) {
if (!bb) {
eprintf ("Error: unable to handle basic block @ 0x%08"PFMT64x"\n", addr);
return R_ANAL_RET_ERROR;
} else if (state->max_depth <= state->current_depth) {
@ -590,7 +590,7 @@ static int java_analyze_fns_from_buffer( RAnal *anal, ut64 start, ut64 end, int
buffer = malloc (buf_len);
if (buffer == NULL) return R_ANAL_RET_ERROR;
if (!buffer) return R_ANAL_RET_ERROR;
anal->iob.read_at (anal->iob.io, addr, buffer, buf_len);
@ -631,7 +631,7 @@ static int java_analyze_fns( RAnal *anal, ut64 start, ut64 end, int reftype, int
if (end == UT64_MAX) analyze_all = 1;
if (bin_objs_list == NULL || r_list_length (bin_objs_list) == 0) {
if (!bin_objs_list || r_list_empty (bin_objs_list)) {
r_list_free (bin_objs_list);
return java_analyze_fns_from_buffer (anal, start, end, reftype, depth);
}
@ -644,7 +644,7 @@ static int java_analyze_fns( RAnal *anal, ut64 start, ut64 end, int reftype, int
ut64 loadaddr = bin->loadaddr;
const char * bin_name = bin && bin->file ? bin->file : anal->iob.io->desc->name;
IFDBG eprintf ("Analyzing java functions for %s\n", bin_name);
IFDBG eprintf ("Analyzing functions. binobj = %p, methods_list = %p, Analysing from buffer? %d\n", bin, methods_list, methods_list == NULL);
IFDBG eprintf ("Analyzing functions. binobj = %p, methods_list = %p, Analysing from buffer? %d\n", bin, methods_list, !methods_list);
// loop over all methods in the binary object and analyse
// the functions
r_list_foreach ( methods_list, methods_iter, method ) {
@ -732,7 +732,7 @@ static int java_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len
//ut8 op_byte = data[0];
ut8 op_byte = data[0];
sz = JAVA_OPS[op_byte].size;
if (op == NULL) return sz;
if (!op) return sz;
memset (op, '\0', sizeof (RAnalOp));
@ -802,7 +802,7 @@ static RAnalOp * java_op_from_buffer(RAnal *anal, RAnalState *state, ut64 addr)
RAnalOp *op = r_anal_op_new ();
// get opcode size
if (op == NULL) return 0;
if (!op) return 0;
memset (op, '\0', sizeof (RAnalOp));
java_op (anal, op, addr, state->buffer, state->len - (addr - state->start) );
return op;

View File

@ -31,7 +31,7 @@ static int instlen(const ut8 *buf, int len) {
static int m68k_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len) {
int sz = 2;
if (op == NULL)
if (!op)
return sz;
memset (op, 0, sizeof (RAnalOp));
op->type = R_ANAL_OP_TYPE_NULL;

View File

@ -24,7 +24,7 @@ static int mips_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len) {
// WIP char buf[10]; int reg; int family;
int optype, oplen = (anal->bits==16)?2:4;
if (op == NULL)
if (!op)
return oplen;
memset (op, 0, sizeof (RAnalOp));

View File

@ -7,7 +7,7 @@
#include <r_anal.h>
static int nios2_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *b, int len) {
if (op == NULL)
if (!op)
return 1;
/* Ayeeee! What's inside op? Do we have an initialized RAnalOp? Are we going to have a leak here? :-( */
memset (op, 0, sizeof (RAnalOp)); /* We need to refactorize this. Something like r_anal_op_init would be more appropiate */

View File

@ -756,7 +756,7 @@ static int (*first_nibble_decode[])(RAnal*,RAnalOp*,ut16) = {
static int sh_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {
ut8 op_MSB,op_LSB;
int ret;
if (data == NULL)
if (!data)
return 0;
memset (op, '\0', sizeof (RAnalOp));
op->addr = addr;

View File

@ -12,7 +12,7 @@ int tms320_c55x_plus_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int
ut16 *ins = (ut16*)buf;
ut32 ins_len;
if (buf == NULL || len <= 0)
if (!buf || len <= 0)
return 0;
ins_len = get_ins_len(buf[0]);

View File

@ -2296,7 +2296,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
{
ut64 naddr = addr;
size_t size = len;
if (insn == NULL)
if (!insn)
insn = cs_malloc (handle);
n = cs_disasm_iter (handle, (const uint8_t**)&buf,
&size, (uint64_t*)&naddr, insn);

View File

@ -1914,7 +1914,7 @@ static void analop_esil (RAnal *a, RAnalOp *op, ut64 addr, ut8 *buffer, size_t l
}
static int xtensa_op (RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
if (op == NULL)
if (!op)
return 1;
memset (op, 0, sizeof (RAnalOp));
r_strbuf_init (&op->esil);

View File

@ -255,7 +255,7 @@ UDis86Esil udis86_esil_callback_table[ UD_MAX_MNEMONIC_CODE ] = {
};
UDis86Esil * udis86_esil_get_handler (enum ud_mnemonic_code code) {
if (udis86_esil_callback_table[code].callback == NULL)
if (!udis86_esil_callback_table[code].callback)
return NULL;
return udis86_esil_callback_table + code;
}

View File

@ -66,7 +66,7 @@ R_API bool r_sign_add(RSign *sig, RAnal *anal, int type, const char *name, const
len = strlen (data)+4; // \xf0
si->bytes = (ut8 *)malloc (R_MAX (len, 4));
si->mask = (ut8 *)malloc (R_MAX (len, 4));
if (si->bytes == NULL || si->mask == NULL) {
if (!si->bytes || !si->mask) {
eprintf ("Cannot malloc\n");
r_sign_item_free (si);
break;

View File

@ -41,7 +41,7 @@ R_API void r_anal_state_set_depth(RAnalState *state, ut32 depth) {
R_API void r_anal_state_insert_bb(RAnalState* state, RAnalBlock *bb) {
if (!state || !bb)
return;
if (r_anal_state_search_bb (state, bb->addr) == NULL &&
if (!r_anal_state_search_bb (state, bb->addr) &&
state->current_fcn) {
RAnalBlock *tmp_bb;
IFDBG eprintf ("Inserting bb 0x%04"PFMT64x" into hash table\n", bb->addr);

View File

@ -404,7 +404,7 @@ R_API int r_anal_var_rename(RAnal *a, ut64 var_addr, int scope, char kind, const
eprintf ("Cannot find key in storage.\n");
return 0;
}
if (old_name == NULL) {
if (!old_name) {
old_name = stored_name;
} else if (strcmp (stored_name, old_name)) {
eprintf ("Old name missmatch %s vs %s.\n", stored_name, old_name);

View File

@ -1108,7 +1108,7 @@ insert_reg (arc_insn insn,long *ex ATTRIBUTE_UNUSED,
{
static char buf[100];
enum operand op_type = OP_NONE;
if (reg == NULL)
if (!reg)
{
/* We have a constant that also requires a value stored in a register
field. Handle these by updating the register field and saving the
@ -2134,7 +2134,7 @@ insert_absaddr (arc_insn insn,long *ex ATTRIBUTE_UNUSED,
The suffix extraction functions' return value is redundant since it can be
obtained from (*OPVAL)->value. However, the boolean suffixes don't have
a suffix table entry for the "false" case, so values of zero must be
obtained from the return value (*OPVAL == NULL). */
obtained from the return value (!*OPVAL). */
/* Called by the disassembler before printing an instruction. */
@ -2244,7 +2244,7 @@ extract_reg (arc_insn *insn,
op_type = OP_REG;
if (reg == NULL)
if (!reg)
return 0;
if (opval != NULL)
*opval = reg;

View File

@ -85,7 +85,7 @@ parse_aarch64_dis_options (const char *options)
{
const char *option_end;
if (options == NULL)
if (!options)
return;
while (*options != '\0')
@ -2184,7 +2184,7 @@ aarch64_symbol_is_valid (asymbol * sym,
{
const char * name;
if (sym == NULL)
if (!sym)
return FALSE;
name = bfd_asymbol_name (sym);
@ -2303,7 +2303,7 @@ print_insn_aarch64 (bfd_vma pc,
addr = bfd_asymbol_value (info->symtab[n]);
if (addr > pc)
break;
if ((info->section == NULL
if ((!info->section
|| info->section == info->symtab[n]->section)
&& get_sym_code_type (info, n, &type))
{

View File

@ -1073,7 +1073,7 @@ aarch64_logical_immediate_p (uint64_t value, int is32, aarch64_insn *encoding)
imm_encoding = (const simd_imm_encoding *)
bsearch(&imm_enc, simd_immediates, TOTAL_IMM_NB,
sizeof(simd_immediates[0]), simd_imm_encoding_cmp);
if (imm_encoding == NULL)
if (!imm_encoding)
{
DEBUG_TRACE ("exit with FALSE");
return FALSE;
@ -1113,7 +1113,7 @@ set_error (aarch64_operand_error *mismatch_detail,
enum aarch64_operand_error_kind kind, int idx,
const char* error)
{
if (mismatch_detail == NULL)
if (!mismatch_detail)
return;
mismatch_detail->kind = kind;
mismatch_detail->index = idx;
@ -1125,7 +1125,7 @@ set_out_of_range_error (aarch64_operand_error *mismatch_detail,
int idx, int lower_bound, int upper_bound,
const char* error)
{
if (mismatch_detail == NULL)
if (!mismatch_detail)
return;
set_error (mismatch_detail, AARCH64_OPDE_OUT_OF_RANGE, idx, error);
mismatch_detail->data[0] = lower_bound;
@ -1136,7 +1136,7 @@ static inline void
set_imm_out_of_range_error (aarch64_operand_error *mismatch_detail,
int idx, int lower_bound, int upper_bound)
{
if (mismatch_detail == NULL)
if (!mismatch_detail)
return;
set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
_("immediate value"));
@ -1146,7 +1146,7 @@ static inline void
set_offset_out_of_range_error (aarch64_operand_error *mismatch_detail,
int idx, int lower_bound, int upper_bound)
{
if (mismatch_detail == NULL)
if (!mismatch_detail)
return;
set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
_("immediate offset"));
@ -1156,7 +1156,7 @@ static inline void
set_regno_out_of_range_error (aarch64_operand_error *mismatch_detail,
int idx, int lower_bound, int upper_bound)
{
if (mismatch_detail == NULL)
if (!mismatch_detail)
return;
set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
_("register number"));
@ -1166,7 +1166,7 @@ static inline void
set_elem_idx_out_of_range_error (aarch64_operand_error *mismatch_detail,
int idx, int lower_bound, int upper_bound)
{
if (mismatch_detail == NULL)
if (!mismatch_detail)
return;
set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
_("register element index"));
@ -1176,7 +1176,7 @@ static inline void
set_sft_amount_out_of_range_error (aarch64_operand_error *mismatch_detail,
int idx, int lower_bound, int upper_bound)
{
if (mismatch_detail == NULL)
if (!mismatch_detail)
return;
set_out_of_range_error (mismatch_detail, idx, lower_bound, upper_bound,
_("shift amount"));
@ -1186,7 +1186,7 @@ static inline void
set_unaligned_error (aarch64_operand_error *mismatch_detail, int idx,
int alignment)
{
if (mismatch_detail == NULL)
if (!mismatch_detail)
return;
set_error (mismatch_detail, AARCH64_OPDE_UNALIGNED, idx, NULL);
mismatch_detail->data[0] = alignment;
@ -1196,7 +1196,7 @@ static inline void
set_reg_list_error (aarch64_operand_error *mismatch_detail, int idx,
int expected_num)
{
if (mismatch_detail == NULL)
if (!mismatch_detail)
return;
set_error (mismatch_detail, AARCH64_OPDE_REG_LIST, idx, NULL);
mismatch_detail->data[0] = expected_num;
@ -1206,7 +1206,7 @@ static inline void
set_other_error (aarch64_operand_error *mismatch_detail, int idx,
const char* error)
{
if (mismatch_detail == NULL)
if (!mismatch_detail)
return;
set_error (mismatch_detail, AARCH64_OPDE_OTHER_ERROR, idx, error);
}

View File

@ -4549,7 +4549,7 @@ arm_symbol_is_valid (asymbol * sym,
{
const char * name;
if (sym == NULL)
if (!sym)
return FALSE;
name = bfd_asymbol_name (sym);
@ -4562,7 +4562,7 @@ arm_symbol_is_valid (asymbol * sym,
void
parse_arm_disassembler_option (char *option)
{
if (option == NULL)
if (!option)
return;
if (CONST_STRNEQ (option, "reg-names-"))
@ -4601,7 +4601,7 @@ parse_arm_disassembler_option (char *option)
static void
parse_disassembler_options (char *options)
{
if (options == NULL)
if (!options)
return;
while (*options)
@ -4834,7 +4834,7 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
}
/* PR 10288: Control which instructions will be disassembled. */
if (info->private_data == NULL)
if (!info->private_data)
{
static struct arm_private_data private;
@ -5014,7 +5014,7 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
{
addr = bfd_asymbol_value (info->symtab[n]);
if (addr > pc
&& (info->section == NULL
&& (!info->section
|| info->section == info->symtab[n]->section))
{
if (addr - pc < size)

View File

@ -58,7 +58,7 @@ static int lookupInstruction(uint16_t opcode, int offset);
static int disassembleInstruction(disassembledInstruction *dInstruction, const assembledInstruction aInstruction) {
int insidx, i;
if (dInstruction == NULL)
if (!dInstruction)
return ERROR_INVALID_ARGUMENTS;
@ -201,9 +201,9 @@ static int disassembleOperands(disassembledInstruction *dInstruction) {
int i;
/* This should never happen */
if (dInstruction == NULL)
if (!dInstruction)
return ERROR_INVALID_ARGUMENTS;
if (dInstruction->instruction == NULL)
if (!dInstruction->instruction)
return ERROR_INVALID_ARGUMENTS;
/* For each operand, decode its original value. */

View File

@ -110,12 +110,12 @@ cris_parse_disassembler_options (disassemble_info *info,
info->private_data = calloc (1, sizeof (struct cris_disasm_data));
disdata = (struct cris_disasm_data *) info->private_data;
if (disdata == NULL)
if (!disdata)
return FALSE;
/* Default true. */
disdata->trace_case
= (info->disassembler_options == NULL
= (!info->disassembler_options
|| (strcmp (info->disassembler_options, "nocase") != 0));
disdata->distype = distype;
@ -141,7 +141,7 @@ spec_reg_info (unsigned int sreg, enum cris_disass_family distype)
case cris_ver_v10p:
case cris_ver_v32p:
/* No ambiguous sizes or register names with CRISv32. */
if (cris_spec_regs[i].warning == NULL)
if (!cris_spec_regs[i].warning)
return &cris_spec_regs[i];
default:
;
@ -189,45 +189,45 @@ get_opcode_entry (unsigned int insn,
static const struct cris_opcode **rest_prefixes = NULL;
/* Allocate and clear the opcode-table. */
if (opc_table == NULL)
if (!opc_table)
{
opc_table = malloc (65536 * sizeof (opc_table[0]));
if (opc_table == NULL)
if (!opc_table)
return NULL;
memset (opc_table, 0, 65536 * sizeof (const struct cris_opcode *));
dip_prefixes
= malloc (65536 * sizeof (const struct cris_opcode **));
if (dip_prefixes == NULL)
if (!dip_prefixes)
return NULL;
memset (dip_prefixes, 0, 65536 * sizeof (dip_prefixes[0]));
bdapq_m1_prefixes
= malloc (65536 * sizeof (const struct cris_opcode **));
if (bdapq_m1_prefixes == NULL)
if (!bdapq_m1_prefixes)
return NULL;
memset (bdapq_m1_prefixes, 0, 65536 * sizeof (bdapq_m1_prefixes[0]));
bdapq_m2_prefixes
= malloc (65536 * sizeof (const struct cris_opcode **));
if (bdapq_m2_prefixes == NULL)
if (!bdapq_m2_prefixes)
return NULL;
memset (bdapq_m2_prefixes, 0, 65536 * sizeof (bdapq_m2_prefixes[0]));
bdapq_m4_prefixes
= malloc (65536 * sizeof (const struct cris_opcode **));
if (bdapq_m4_prefixes == NULL)
if (!bdapq_m4_prefixes)
return NULL;
memset (bdapq_m4_prefixes, 0, 65536 * sizeof (bdapq_m4_prefixes[0]));
rest_prefixes
= malloc (65536 * sizeof (const struct cris_opcode **));
if (rest_prefixes == NULL)
if (!rest_prefixes)
return NULL;
memset (rest_prefixes, 0, 65536 * sizeof (rest_prefixes[0]));
@ -246,7 +246,7 @@ get_opcode_entry (unsigned int insn,
? opc_table[prefix_insn]
: get_opcode_entry (prefix_insn, NO_CRIS_PREFIX, disdata));
if (popcodep == NULL)
if (!popcodep)
return NULL;
if (popcodep->match == BDAP_QUICK_OPCODE)
@ -665,7 +665,7 @@ bytes_to_skip (unsigned int insn,
for (s = template; *s; s++)
if ((*s == 's' || *s == 'N' || *s == 'Y')
&& (insn & 0x400) && (insn & 15) == 15
&& prefix_matchedp == NULL)
&& !prefix_matchedp)
{
/* Immediate via [pc+], so we have to check the size of the
operand. */
@ -680,7 +680,7 @@ bytes_to_skip (unsigned int insn,
/* FIXME: Improve error handling; should have been caught
earlier. */
if (sregp == NULL)
if (!sregp)
return 2;
/* PC is incremented by two, not one, for a byte. Except on
@ -886,7 +886,7 @@ print_with_operands (const struct cris_opcode *opcodep,
case 'S':
case 's':
/* Any "normal" memory operand. */
if ((insn & 0x400) && (insn & 15) == 15 && prefix_opcodep == NULL)
if ((insn & 0x400) && (insn & 15) == 15 && !prefix_opcodep)
{
/* We're looking at [pc+], i.e. we need to output an immediate
number, where the size can depend on different things. */
@ -906,7 +906,7 @@ print_with_operands (const struct cris_opcode *opcodep,
/* A NULL return should have been as a non-match earlier,
so catch it as an internal error in the error-case
below. */
if (sregp == NULL)
if (!sregp)
/* Whatever non-valid size. */
nbytes = 42;
else
@ -1007,7 +1007,7 @@ print_with_operands (const struct cris_opcode *opcodep,
/* FIXME: Improve error handling; should have been caught
earlier. */
if (sregp == NULL)
if (!sregp)
size = 4;
else
size = sregp->reg_size;
@ -1333,7 +1333,7 @@ print_with_operands (const struct cris_opcode *opcodep,
= spec_reg_info ((insn >> 12) & 15, disdata->distype);
if (sregp) {
if (sregp->name == NULL)
if (!sregp->name)
/* Should have been caught as a non-match eariler. */
*tp++ = '?';
else
@ -1526,7 +1526,7 @@ print_insn_cris_generic (bfd_vma memaddr,
}
}
if (matchedp == NULL)
if (!matchedp)
{
(*info->fprintf_func) (info->stream, "??0x%x", insn);
advance += 2;
@ -1584,7 +1584,7 @@ static int
print_insn_cris_with_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
if (!info->private_data
&& !cris_parse_disassembler_options (info, cris_dis_v0_v10))
return -1;
return print_insn_cris_generic (vma, info, TRUE);
@ -1596,7 +1596,7 @@ static int
print_insn_crisv32_with_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
if (!info->private_data
&& !cris_parse_disassembler_options (info, cris_dis_v32))
return -1;
return print_insn_cris_generic (vma, info, TRUE);
@ -1609,7 +1609,7 @@ int
print_insn_crisv10_v32_with_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
if (!info->private_data
&& !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
return -1;
return print_insn_cris_generic (vma, info, TRUE);
@ -1621,7 +1621,7 @@ static int
print_insn_cris_without_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
if (!info->private_data
&& !cris_parse_disassembler_options (info, cris_dis_v0_v10))
return -1;
return print_insn_cris_generic (vma, info, FALSE);
@ -1633,7 +1633,7 @@ int
print_insn_crisv32_without_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
if (!info->private_data
&& !cris_parse_disassembler_options (info, cris_dis_v32))
return -1;
return print_insn_cris_generic (vma, info, FALSE);
@ -1646,7 +1646,7 @@ int
print_insn_crisv10_v32_without_register_prefix (bfd_vma vma,
disassemble_info *info)
{
if (info->private_data == NULL
if (!info->private_data
&& !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
return -1;
return print_insn_cris_generic (vma, info, FALSE);
@ -1664,7 +1664,7 @@ const int mode = 0; // V32 by default
/* If there's no bfd in sight, we return what is valid as input in all
contexts if fed back to the assembler: disassembly *with* register
prefix. Unfortunately this will be totally wrong for v32. */
if (abfd == NULL)
if (!abfd)
return print_insn_cris_with_register_prefix;
if (bfd_get_symbol_leading_char (abfd) == 0)

View File

@ -2072,7 +2072,7 @@ extern bfd_boolean _sh_elf_set_mach_from_flags
{ \
/* It seems this can happen with erroneous or unsupported \
input (mixing a.out and elf in an archive, for example.) */ \
if (sym_hashes == NULL) \
if (!sym_hashes) \
return FALSE; \
\
h = sym_hashes[r_symndx - symtab_hdr->sh_info]; \
@ -2088,8 +2088,8 @@ extern bfd_boolean _sh_elf_set_mach_from_flags
|| h->root.type == bfd_link_hash_defweak) \
{ \
sec = h->root.u.def.section; \
if (sec == NULL \
|| sec->output_section == NULL) \
if (!sec \
|| !sec->output_section) \
/* Set a flag that will be cleared later if we find a \
relocation value for this symbol. output_section \
is typically NULL for symbols satisfied by a shared \

View File

@ -1584,7 +1584,7 @@ extern const struct bfd_symbol * const bfd_ind_symbol;
} \
while (0)
#define bfd_section_removed_from_list(ABFD, S) \
((S)->next == NULL ? (ABFD)->section_last != (S) : (S)->next->prev != (S))
((S)->next ? (S)->next->prev != (S) : (ABFD)->section_last != (S))
#define BFD_FAKE_SECTION(SEC, FLAGS, SYM, SYM_PTR, NAME, IDX) \
/* name, id, index, next, prev, flags, user_set_vma, */ \

View File

@ -2997,7 +2997,7 @@ static void print_disp(dis_buffer_t *dbuf, int disp, int sz, int rel, int dd) {
ut32 nv = 0;
ut32i diff = INT_MAX;
if (dbuf == NULL)
if (!dbuf)
return;
if (sz == SIZE_WORD)

View File

@ -457,7 +457,7 @@ choose_abi_by_name (const char *name, unsigned int namelen)
const struct mips_abi_choice *c;
unsigned int i;
for (i = 0, c = NULL; i < ARRAY_SIZE (mips_abi_choices) && c == NULL; i++)
for (i = 0, c = NULL; i < ARRAY_SIZE (mips_abi_choices) && !c; i++)
if (strncmp (mips_abi_choices[i].name, name, namelen) == 0
&& strlen (mips_abi_choices[i].name) == namelen)
c = &mips_abi_choices[i];
@ -471,7 +471,7 @@ choose_arch_by_name (const char *name, unsigned int namelen)
const struct mips_arch_choice *c = NULL;
unsigned int i;
for (i = 0, c = NULL; i < ARRAY_SIZE (mips_arch_choices) && c == NULL; i++)
for (i = 0, c = NULL; i < ARRAY_SIZE (mips_arch_choices) && !c; i++)
if (strncmp (mips_arch_choices[i].name, name, namelen) == 0
&& strlen (mips_arch_choices[i].name) == namelen)
c = &mips_arch_choices[i];
@ -494,7 +494,7 @@ choose_arch_by_number (unsigned long mach)
&& hint_arch_choice->bfd_mach == hint_bfd_mach)
return hint_arch_choice;
for (i = 0, c = NULL; i < ARRAY_SIZE (mips_arch_choices) && c == NULL; i++)
for (i = 0, c = NULL; i < ARRAY_SIZE (mips_arch_choices) && !c; i++)
{
if (mips_arch_choices[i].bfd_mach_valid
&& mips_arch_choices[i].bfd_mach == mach)
@ -673,7 +673,7 @@ parse_mips_dis_options (const char *options)
{
const char *option_end;
if (options == NULL)
if (!options)
return;
while (*options != '\0')

View File

@ -81,7 +81,7 @@ nios2_init_opcode_hash (void)
{
new_hash =
(nios2_opcode_hash *) malloc (sizeof (nios2_opcode_hash));
if (new_hash == NULL)
if (!new_hash)
{
fprintf (stderr,
"error allocating memory...broken disassembler\n");

View File

@ -38,7 +38,7 @@ static const char * const *riscv_fpr_names = riscv_fpr_names_abi;
static int init = 0;
static void arg_p (char *buf, unsigned long val, const char* const* array, size_t size) {
const char *s = val >= size || array[val] == NULL ? "unknown" : array[val];
const char *s = val >= size || array[val] ? array[val] : "unknown";
sprintf (buf+strlen (buf), "%s", s);
}

View File

@ -232,7 +232,7 @@ static st8 *decode_ins(st32 hash_code, ut32 ins_pos, ut32 ins_off, ut32 *ins_len
ins_len = get_ins_len(get_ins_part(ins_pos + ins_off, 1));
// get pseudo instruction
ins = ins_str[1 + 2 + hash_code * 4];
if (ins == NULL /*|| ins_str[4 * hash_code] == 0*/) {
if (!ins /*|| ins_str[4 * hash_code] == 0*/) {
fprintf(stderr, "Invalid instruction %s /hash %x\n", ins, hash_code);
*err_code = -1;
return NULL;
@ -256,7 +256,7 @@ static st8 *decode_ins(st32 hash_code, ut32 ins_pos, ut32 ins_off, ut32 *ins_len
if (*pos == '`') {
pos++;
aux = strchr(pos, '`');
if (aux == NULL || pos == aux) {
if (!aux || pos == aux) {
fprintf(stderr, "Invalid instruction %s\n", ins);
free (res_decode);
*err_code = -1;
@ -551,7 +551,7 @@ static st8* get_token_decoded(st32 hash_code, st8 *ins_token, ut32 ins_token_len
case 63:
case 64:
case 65:
if (reg_arg == NULL || *reg_arg == '\0') {
if (!reg_arg || *reg_arg == '\0') {
res = strdup("<register>");
goto ret_decode;
}
@ -691,7 +691,7 @@ static st8* get_token_decoded(st32 hash_code, st8 *ins_token, ut32 ins_token_len
break;
case 79:
res = get_trans_reg(ins_bits);
if (res == NULL) {
if (!res) {
*err_code = -1;
}
break;
@ -702,7 +702,7 @@ static st8* get_token_decoded(st32 hash_code, st8 *ins_token, ut32 ins_token_len
} else if (*reg_arg == '2')
res = get_tc2_tc1(ins_bits & 1);
} else res = get_tc2_tc1(ins_bits);
if (res == NULL) {
if (!res) {
*err_code = -1;
return NULL;
}

View File

@ -60,7 +60,7 @@ st8 *get_trans_reg(ut32 ins_bits) {
st8 *get_AR_regs_class1(ut32 ins_bits) {
ut32 op = (ins_bits >> 4) & 7;
st8 *res = (st8 *)malloc(50);
if (res == NULL)
if (!res)
return NULL;
memset (res, 0, 50);
switch (op) {
@ -1153,7 +1153,7 @@ st8 *get_sim_reg(st8 *reg_arg, ut32 ins_bits) {
break;
case 2:
aux = (st8 *)malloc(50);
if(aux == NULL)
if(!aux)
return NULL;
sprintf(aux, "@#0x%x", code);

View File

@ -1603,7 +1603,7 @@ decode_pcp_insn (memaddr, buffer, info)
break;
}
if (pop == NULL)
if (!pop)
{
/* No valid instruction was found; print it as a 16-bit word. */
DPRINT (DFILE, ".hword 0x%04lx", (insn & 0xffff));

View File

@ -332,7 +332,7 @@ print_insn_vax (bfd_vma memaddr, disassemble_info *info)
break;
}
}
if (argp == NULL)
if (!argp)
{
/* Handle undefined instructions. */
(*info->fprintf_func) (info->stream, ".word 0x%x",

View File

@ -515,7 +515,7 @@ static void own(struct state *s)
}
if (s->s_nop) {
assert(s->s_nopd == NULL);
assert(!s->s_nopd);
s->s_nopd = d;
} else {
last->d_next = d;
@ -555,7 +555,7 @@ static void own(struct state *s)
}
if (l) {
print_label(s, l);
assert(l->l_next == NULL);
assert(!l->l_next);
}
output(s, "\n\tENDMOD\n");

View File

@ -550,7 +550,7 @@ R_API RAsmCode* r_asm_massemble(RAsm *a, const char *buf) {
RAsmCode *acode = NULL;
RAsmOp op = {0};
ut64 off, pc;
if (buf == NULL)
if (!buf)
return NULL;
if (!(acode = r_asm_code_new ()))
return NULL;

View File

@ -89,7 +89,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
if (!buf_global)
return;
sprintf (tmp, "0x%08"PFMT64x"", (ut64)address);
strcat (buf_global, tmp);
@ -98,11 +98,11 @@ static void print_address(bfd_vma address, struct disassemble_info *info) {
static int buf_fprintf(void *stream, const char *format, ...) {
va_list ap;
char *tmp;
if (buf_global == NULL || format == NULL)
if (!buf_global || !format)
return false;
va_start (ap, format);
tmp = malloc (strlen (format)+strlen (buf_global)+2);
if (tmp == NULL) {
if (!tmp) {
va_end (ap);
return false;
}

View File

@ -40,7 +40,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
if (!buf_global)
return;
sprintf(tmp, "0x%08"PFMT64x"", (ut64)address);
strcat(buf_global, tmp);
@ -50,7 +50,7 @@ static int buf_fprintf(void *stream, const char *format, ...) {
int flen, glen;
va_list ap;
char *tmp;
if (buf_global == NULL)
if (!buf_global)
return 0;
va_start (ap, format);
flen = strlen (format);

View File

@ -41,7 +41,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
if (!buf_global)
return;
sprintf(tmp, "0x%08"PFMT64x"", (ut64)address);
strcat(buf_global, tmp);
@ -51,7 +51,7 @@ static int buf_fprintf(void *stream, const char *format, ...) {
int flen, glen;
va_list ap;
char *tmp;
if (buf_global == NULL)
if (!buf_global)
return 0;
va_start (ap, format);
flen = strlen (format);

View File

@ -31,7 +31,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
if (!buf_global)
return;
sprintf(tmp, "0x%08"PFMT64x"", (ut64)address);
strcat(buf_global, tmp);
@ -41,7 +41,7 @@ static int buf_fprintf(void *stream, const char *format, ...) {
int flen, glen;
va_list ap;
char *tmp;
if (buf_global == NULL)
if (!buf_global)
return 0;
va_start (ap, format);
flen = strlen (format);

View File

@ -33,7 +33,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
if (!buf_global)
return;
sprintf (tmp, "0x%08"PFMT64x, (ut64)address);
strcat (buf_global, tmp);
@ -42,11 +42,11 @@ static void print_address(bfd_vma address, struct disassemble_info *info) {
static int buf_fprintf(void *stream, const char *format, ...) {
va_list ap;
char *tmp;
if (buf_global == NULL || format == NULL)
if (!buf_global || !format)
return false;
va_start (ap, format);
tmp = malloc (strlen (format)+strlen (buf_global)+2);
if (tmp == NULL) {
if (!tmp) {
va_end (ap);
return false;
}

View File

@ -33,7 +33,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
if (!buf_global)
return;
sprintf(tmp, "0x%08"PFMT64x"", (ut64)address);
strcat(buf_global, tmp);
@ -43,7 +43,7 @@ static int buf_fprintf(void *stream, const char *format, ...) {
int flen, glen;
va_list ap;
char *tmp;
if (buf_global == NULL)
if (!buf_global)
return 0;
va_start (ap, format);
flen = strlen (format);

View File

@ -31,7 +31,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
if (!buf_global)
return;
sprintf(tmp, "0x%08"PFMT64x"", (ut64)address);
strcat(buf_global, tmp);
@ -41,7 +41,7 @@ static int buf_fprintf(void *stream, const char *format, ...) {
int flen, glen;
va_list ap;
char *tmp;
if (buf_global == NULL)
if (!buf_global)
return 0;
va_start (ap, format);
flen = strlen (format);

View File

@ -32,7 +32,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
if (!buf_global)
return;
sprintf (tmp, "0x%08"PFMT64x"", (ut64)address);
strcat (buf_global, tmp);
@ -42,7 +42,7 @@ static int buf_fprintf(void *stream, const char *format, ...) {
va_list ap;
char *tmp;
int ret;
if (buf_global == NULL)
if (!buf_global)
return 0;
tmp = malloc (strlen (format)+strlen (buf_global)+2);
if (!tmp)

View File

@ -29,7 +29,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
if (!buf_global)
return;
sprintf (tmp, "0x%08"PFMT64x"", (ut64)address);
strcat (buf_global, tmp);
@ -38,7 +38,7 @@ static void print_address(bfd_vma address, struct disassemble_info *info) {
static int buf_fprintf(void *stream, const char *format, ...) {
va_list ap;
char tmp[1024];
if (buf_global == NULL)
if (!buf_global)
return 0;
va_start (ap, format);
vsnprintf (tmp, sizeof (tmp), format, ap);

View File

@ -34,7 +34,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[64];
if (buf_global == NULL) {
if (!buf_global) {
return;
}
sprintf (tmp, "0x%08" PFMT64x, (ut64) address);
@ -47,7 +47,7 @@ static int buf_fprintf(void *stream, const char *format, ...) {
va_list ap;
char *tmp = NULL;
va_start (ap, format);
if (buf_global == NULL) {
if (!buf_global) {
return 0;
}
flen = strlen (format);

View File

@ -50,7 +50,7 @@ static int buf_fprintf(void *stream, const char *format, ...) {
int flen, glen;
va_list ap;
char *tmp;
if (buf_global == NULL)
if (!buf_global)
return 0;
va_start (ap, format);
flen = strlen (format);

View File

@ -62,7 +62,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
#if USE_ITER_API
{
size_t size = len;
if (insn == NULL)
if (!insn)
insn = cs_malloc (cd);
insn->size = 1;
memset (insn, 0, insn->size);

View File

@ -31,7 +31,7 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
if (!buf_global)
return;
sprintf(tmp, "0x%08"PFMT64x"", (ut64)address);
strcat(buf_global, tmp);
@ -41,7 +41,7 @@ static int buf_fprintf(void *stream, const char *format, ...) {
int flen, glen;
va_list ap;
char *tmp;
if (buf_global == NULL)
if (!buf_global)
return 0;
va_start (ap, format);
flen = strlen (format);

View File

@ -1416,7 +1416,7 @@ R_API int r_bin_is_string(RBin *bin, ut64 va) {
RBinString *string;
RListIter *iter;
RList *list;
if ((list = r_bin_get_strings (bin)) == NULL) return false;
if (!(list = r_bin_get_strings (bin))) return false;
r_list_foreach (list, iter, string) {
if (string->vaddr == va)
return true;

View File

@ -122,7 +122,7 @@ static int r_bin_coff_init_symtable(struct r_bin_coff_obj *obj) {
if (obj->hdr.f_nsyms >= 0xffff) // too much symbols, probably not allocatable
return 0;
obj->symbols = calloc (obj->hdr.f_nsyms, sizeof(struct coff_symbol));
if (obj->symbols == NULL)
if (!obj->symbols)
return 0;
(void)r_buf_fread_at (obj->b, obj->hdr.f_symptr, (ut8 *)obj->symbols,
obj->endian? "8c1I2S2c": "8c1i2s2c", obj->hdr.f_nsyms);

View File

@ -56,7 +56,7 @@ ut64 Elf_(r_bin_elf_resize_section)(struct Elf_(r_bin_elf_obj_t) *bin, const cha
if (!strcmp (&strtab[shdrp->sh_name], ".rel.plt")) {
Elf_(Rel) *rel, *relp;
rel = (Elf_(Rel) *)malloc (1+shdrp->sh_size);
if (rel == NULL) {
if (!rel) {
perror ("malloc");
return 0;
}
@ -77,7 +77,7 @@ ut64 Elf_(r_bin_elf_resize_section)(struct Elf_(r_bin_elf_obj_t) *bin, const cha
} else if (!strcmp (&strtab[shdrp->sh_name], ".rela.plt")) {
Elf_(Rela) *rel, *relp;
rel = (Elf_(Rela) *)malloc (1+shdrp->sh_size);
if (rel == NULL) {
if (!rel) {
perror("malloc");
return 0;
}

View File

@ -22,7 +22,7 @@ int r_bin_mz_get_entrypoint (const struct r_bin_mz_obj_t *bin)
int cmp_segs (const void *a, const void *b) {
const ut16 * const ma = (const ut16 * const)a;
const ut16 * const mb = (const ut16 * const)b;
if (ma == NULL || mb == NULL) return 0;
if (!ma || !mb) return 0;
return (int)(*ma-*mb);
}
@ -80,7 +80,7 @@ struct r_bin_mz_segment_t * r_bin_mz_get_segments (
return NULL;
}
segments = calloc (num_relocs, sizeof(*segments));
if (segments == NULL) {
if (!segments) {
eprintf ("Error: calloc (segments)\n");
btree_cleartree (tree, NULL);
return NULL;
@ -91,7 +91,7 @@ struct r_bin_mz_segment_t * r_bin_mz_get_segments (
num_segs = curr_seg - segments;
ret = calloc (num_segs + 1, sizeof(struct r_bin_mz_segment_t));
if (ret == NULL) {
if (!ret) {
free (segments);
btree_cleartree (tree, NULL);
eprintf ("Error: calloc (struct r_bin_mz_segment_t)\n");
@ -121,7 +121,7 @@ struct r_bin_mz_reloc_t *r_bin_mz_get_relocs (const struct r_bin_mz_obj_t *bin)
bin->relocation_entries;
relocs = calloc (num_relocs + 1, sizeof(*relocs));
if (relocs == NULL) {
if (!relocs) {
eprintf ("Error: calloc (struct r_bin_mz_reloc_t)\n");
return NULL;
}

View File

@ -118,9 +118,9 @@ static mach0_ut get_pointer(mach0_ut p, ut32 *offset, ut32 *left, RBinFile *arch
RListIter *iter = NULL;
RBinSection *s = NULL;
if (sctns == NULL) {
if (!sctns) {
sctns = r_bin_plugin_mach.sections (arch);
if (sctns == NULL) {
if (!sctns) {
// retain just for debug
// eprintf ("there is no sections\n");
return 0;

View File

@ -17,11 +17,11 @@ ut64 r_bin_te_get_stripped_delta(struct r_bin_te_obj_t *bin) {
static int r_bin_te_init_hdr(struct r_bin_te_obj_t *bin) {
if (!bin)
return false;
if (!(bin->header = malloc(sizeof(TE_image_file_header)))) {
if (!(bin->header = malloc (sizeof(TE_image_file_header)))) {
r_sys_perror ("malloc (header)");
return false;
}
if (r_buf_read_at (bin->b, 0, (ut8*)bin->header, sizeof(TE_image_file_header)) == -1) {
if (r_buf_read_at (bin->b, 0, (ut8*)bin->header, sizeof (TE_image_file_header)) == -1) {
eprintf("Error: read (header)\n");
return false;
}
@ -121,11 +121,11 @@ static int r_bin_te_init(struct r_bin_te_obj_t* bin) {
bin->header = NULL;
bin->section_header = NULL;
bin->endian = 0;
if (!r_bin_te_init_hdr(bin)) {
if (!r_bin_te_init_hdr (bin)) {
eprintf("Warning: File is not TE\n");
return false;
}
if (!r_bin_te_init_sections(bin)) {
if (!r_bin_te_init_sections (bin)) {
eprintf("Warning: Cannot initialize sections\n");
return false;
}
@ -138,27 +138,27 @@ char* r_bin_te_get_arch(struct r_bin_te_obj_t* bin) {
switch (bin->header->Machine) {
case TE_IMAGE_FILE_MACHINE_ALPHA:
case TE_IMAGE_FILE_MACHINE_ALPHA64:
arch = strdup("alpha");
arch = strdup ("alpha");
break;
case TE_IMAGE_FILE_MACHINE_ARM:
case TE_IMAGE_FILE_MACHINE_THUMB:
arch = strdup("arm");
arch = strdup ("arm");
break;
case TE_IMAGE_FILE_MACHINE_M68K:
arch = strdup("m68k");
arch = strdup ("m68k");
break;
case TE_IMAGE_FILE_MACHINE_MIPS16:
case TE_IMAGE_FILE_MACHINE_MIPSFPU:
case TE_IMAGE_FILE_MACHINE_MIPSFPU16:
case TE_IMAGE_FILE_MACHINE_WCEMIPSV2:
arch = strdup("mips");
arch = strdup ("mips");
break;
case TE_IMAGE_FILE_MACHINE_POWERPC:
case TE_IMAGE_FILE_MACHINE_POWERPCFP:
arch = strdup("ppc");
arch = strdup ("ppc");
break;
default:
arch = strdup("x86");
arch = strdup ("x86");
}
return arch;
}
@ -173,14 +173,14 @@ RBinAddr* r_bin_te_get_entrypoint(struct r_bin_te_obj_t* bin) {
if (!bin || !bin->header)
return NULL;
if ((entry = malloc(sizeof(RBinAddr))) == NULL) {
if (!(entry = malloc (sizeof (RBinAddr)))) {
perror("malloc (entrypoint)");
return NULL;
}
entry->vaddr = bin->header->AddressOfEntryPoint - r_bin_te_get_stripped_delta(bin);
entry->vaddr = bin->header->AddressOfEntryPoint - r_bin_te_get_stripped_delta (bin);
if (entry->vaddr == 0) // in TE if EP = 0 then EP = baddr
entry->vaddr = bin->header->ImageBase;
entry->paddr = r_bin_te_vaddr_to_paddr(bin, entry->vaddr);
entry->paddr = r_bin_te_vaddr_to_paddr (bin, entry->vaddr);
return entry;
}
@ -196,91 +196,91 @@ char* r_bin_te_get_machine(struct r_bin_te_obj_t* bin) {
if (!bin) return NULL;
switch (bin->header->Machine) {
case TE_IMAGE_FILE_MACHINE_ALPHA:
machine = strdup("Alpha");
machine = strdup ("Alpha");
break;
case TE_IMAGE_FILE_MACHINE_ALPHA64:
machine = strdup("Alpha 64");
machine = strdup ("Alpha 64");
break;
case TE_IMAGE_FILE_MACHINE_AM33:
machine = strdup("AM33");
machine = strdup ("AM33");
break;
case TE_IMAGE_FILE_MACHINE_AMD64:
machine = strdup("AMD 64");
machine = strdup ("AMD 64");
break;
case TE_IMAGE_FILE_MACHINE_ARM:
machine = strdup("ARM");
machine = strdup ("ARM");
break;
case TE_IMAGE_FILE_MACHINE_CEE:
machine = strdup("CEE");
machine = strdup ("CEE");
break;
case TE_IMAGE_FILE_MACHINE_CEF:
machine = strdup("CEF");
machine = strdup ("CEF");
break;
case TE_IMAGE_FILE_MACHINE_EBC:
machine = strdup("EBC");
machine = strdup ("EBC");
break;
case TE_IMAGE_FILE_MACHINE_I386:
machine = strdup("i386");
machine = strdup ("i386");
break;
case TE_IMAGE_FILE_MACHINE_IA64:
machine = strdup("ia64");
machine = strdup ("ia64");
break;
case TE_IMAGE_FILE_MACHINE_M32R:
machine = strdup("M32R");
machine = strdup ("M32R");
break;
case TE_IMAGE_FILE_MACHINE_M68K:
machine = strdup("M68K");
machine = strdup ("M68K");
break;
case TE_IMAGE_FILE_MACHINE_MIPS16:
machine = strdup("Mips 16");
machine = strdup ("Mips 16");
break;
case TE_IMAGE_FILE_MACHINE_MIPSFPU:
machine = strdup("Mips FPU");
machine = strdup ("Mips FPU");
break;
case TE_IMAGE_FILE_MACHINE_MIPSFPU16:
machine = strdup("Mips FPU 16");
machine = strdup ("Mips FPU 16");
break;
case TE_IMAGE_FILE_MACHINE_POWERPC:
machine = strdup("PowerPC");
machine = strdup ("PowerPC");
break;
case TE_IMAGE_FILE_MACHINE_POWERPCFP:
machine = strdup("PowerPC FP");
machine = strdup ("PowerPC FP");
break;
case TE_IMAGE_FILE_MACHINE_R10000:
machine = strdup("R10000");
machine = strdup ("R10000");
break;
case TE_IMAGE_FILE_MACHINE_R3000:
machine = strdup("R3000");
machine = strdup ("R3000");
break;
case TE_IMAGE_FILE_MACHINE_R4000:
machine = strdup("R4000");
machine = strdup ("R4000");
break;
case TE_IMAGE_FILE_MACHINE_SH3:
machine = strdup("SH3");
machine = strdup ("SH3");
break;
case TE_IMAGE_FILE_MACHINE_SH3DSP:
machine = strdup("SH3DSP");
machine = strdup ("SH3DSP");
break;
case TE_IMAGE_FILE_MACHINE_SH3E:
machine = strdup("SH3E");
machine = strdup ("SH3E");
break;
case TE_IMAGE_FILE_MACHINE_SH4:
machine = strdup("SH4");
machine = strdup ("SH4");
break;
case TE_IMAGE_FILE_MACHINE_SH5:
machine = strdup("SH5");
machine = strdup ("SH5");
break;
case TE_IMAGE_FILE_MACHINE_THUMB:
machine = strdup("Thumb");
machine = strdup ("Thumb");
break;
case TE_IMAGE_FILE_MACHINE_TRICORE:
machine = strdup("Tricore");
machine = strdup ("Tricore");
break;
case TE_IMAGE_FILE_MACHINE_WCEMIPSV2:
machine = strdup("WCE Mips V2");
machine = strdup ("WCE Mips V2");
break;
default:
machine = strdup("unknown");
machine = strdup ("unknown");
}
return machine;
}
@ -291,7 +291,7 @@ char* r_bin_te_get_os(struct r_bin_te_obj_t* bin) {
switch (bin->header->Subsystem) {
case TE_IMAGE_SUBSYSTEM_NATIVE:
os = strdup("native");
os = strdup ("native");
break;
case TE_IMAGE_SUBSYSTEM_WINDOWS_GUI:
case TE_IMAGE_SUBSYSTEM_WINDOWS_CUI:
@ -325,7 +325,7 @@ struct r_bin_te_section_t* r_bin_te_get_sections(struct r_bin_te_obj_t* bin) {
shdr = bin->section_header;
sections_count = bin->header->NumberOfSections;
if ((sections = calloc((sections_count + 1), sizeof(struct r_bin_te_section_t))) == NULL) {
if (!(sections = calloc ((sections_count + 1), sizeof (struct r_bin_te_section_t)))) {
perror ("malloc (sections)");
return NULL;
}
@ -333,10 +333,10 @@ struct r_bin_te_section_t* r_bin_te_get_sections(struct r_bin_te_obj_t* bin) {
memcpy (sections[i].name, shdr[i].Name, TE_IMAGE_SIZEOF_NAME);
// not a null terminated string if len==buflen
//sections[i].name[TE_IMAGE_SIZEOF_NAME] = '\0';
sections[i].vaddr = shdr[i].VirtualAddress - r_bin_te_get_stripped_delta(bin);
sections[i].vaddr = shdr[i].VirtualAddress - r_bin_te_get_stripped_delta (bin);
sections[i].size = shdr[i].SizeOfRawData;
sections[i].vsize = shdr[i].VirtualSize;
sections[i].paddr = shdr[i].PointerToRawData - r_bin_te_get_stripped_delta(bin);
sections[i].paddr = shdr[i].PointerToRawData - r_bin_te_get_stripped_delta (bin);
sections[i].flags = shdr[i].Characteristics;
sections[i].last = 0;
}
@ -350,37 +350,37 @@ char* r_bin_te_get_subsystem(struct r_bin_te_obj_t* bin) {
if (!bin) return NULL;
switch (bin->header->Subsystem) {
case TE_IMAGE_SUBSYSTEM_NATIVE:
subsystem = strdup("Native");
subsystem = strdup ("Native");
break;
case TE_IMAGE_SUBSYSTEM_WINDOWS_GUI:
subsystem = strdup("Windows GUI");
subsystem = strdup ("Windows GUI");
break;
case TE_IMAGE_SUBSYSTEM_WINDOWS_CUI:
subsystem = strdup("Windows CUI");
subsystem = strdup ("Windows CUI");
break;
case TE_IMAGE_SUBSYSTEM_POSIX_CUI:
subsystem = strdup("POSIX CUI");
subsystem = strdup ("POSIX CUI");
break;
case TE_IMAGE_SUBSYSTEM_WINDOWS_CE_GUI:
subsystem = strdup("Windows CE GUI");
subsystem = strdup ("Windows CE GUI");
break;
case TE_IMAGE_SUBSYSTEM_EFI_APPLICATION:
subsystem = strdup("EFI Application");
subsystem = strdup ("EFI Application");
break;
case TE_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:
subsystem = strdup("EFI Boot Service Driver");
subsystem = strdup ("EFI Boot Service Driver");
break;
case TE_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:
subsystem = strdup("EFI Runtime Driver");
subsystem = strdup ("EFI Runtime Driver");
break;
case TE_IMAGE_SUBSYSTEM_EFI_ROM:
subsystem = strdup("EFI ROM");
subsystem = strdup ("EFI ROM");
break;
case TE_IMAGE_SUBSYSTEM_XBOX:
subsystem = strdup("XBOX");
subsystem = strdup ("XBOX");
break;
default:
subsystem = strdup("Unknown");
subsystem = strdup ("Unknown");
}
return subsystem;
}
@ -399,16 +399,16 @@ struct r_bin_te_obj_t* r_bin_te_new(const char* file) {
struct r_bin_te_obj_t *bin = R_NEW0 (struct r_bin_te_obj_t);
if (!bin) return NULL;
bin->file = file;
if (!(buf = (ut8*)r_file_slurp(file, &bin->size)))
return r_bin_te_free(bin);
if (!(buf = (ut8*)r_file_slurp (file, &bin->size)))
return r_bin_te_free (bin);
bin->b = r_buf_new ();
if (!r_buf_set_bytes (bin->b, buf, bin->size)) {
free (buf);
return r_bin_te_free(bin);
return r_bin_te_free (bin);
}
free (buf);
if (!r_bin_te_init(bin))
return r_bin_te_free(bin);
if (!r_bin_te_init (bin))
return r_bin_te_free (bin);
return bin;
}
@ -419,9 +419,9 @@ struct r_bin_te_obj_t* r_bin_te_new_buf(struct r_buf_t *buf) {
bin->b = r_buf_new ();
bin->size = buf->length;
if (!r_buf_set_bytes (bin->b, buf->buf, bin->size)){
return r_bin_te_free(bin);
return r_bin_te_free (bin);
}
if (!r_bin_te_init(bin))
return r_bin_te_free(bin);
if (!r_bin_te_init (bin))
return r_bin_te_free (bin);
return bin;
}

View File

@ -508,7 +508,7 @@ d_dump (struct demangle_component *dc, int indent)
{
int i;
if (dc == NULL)
if (!dc)
{
if (indent == 0)
printf ("failed demangling\n");
@ -750,7 +750,7 @@ CP_STATIC_IF_GLIBCPP_V3
int
cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len)
{
if (p == NULL || s == NULL || len == 0)
if (!p || !s || len == 0)
return 0;
p->type = DEMANGLE_COMPONENT_NAME;
p->u.s_name.s = s;
@ -765,7 +765,7 @@ int
cplus_demangle_fill_extended_operator (struct demangle_component *p, int args,
struct demangle_component *name)
{
if (p == NULL || args < 0 || name == NULL)
if (!p || args < 0 || !name)
return 0;
p->type = DEMANGLE_COMPONENT_EXTENDED_OPERATOR;
p->u.s_extended_operator.args = args;
@ -781,8 +781,8 @@ cplus_demangle_fill_ctor (struct demangle_component *p,
enum gnu_v3_ctor_kinds kind,
struct demangle_component *name)
{
if (p == NULL
|| name == NULL
if (!p
|| !name
|| (int) kind < gnu_v3_complete_object_ctor
|| (int) kind > gnu_v3_object_ctor_group)
return 0;
@ -800,8 +800,8 @@ cplus_demangle_fill_dtor (struct demangle_component *p,
enum gnu_v3_dtor_kinds kind,
struct demangle_component *name)
{
if (p == NULL
|| name == NULL
if (!p
|| !name
|| (int) kind < gnu_v3_deleting_dtor
|| (int) kind > gnu_v3_object_dtor_group)
return 0;
@ -858,7 +858,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type,
case DEMANGLE_COMPONENT_COMPOUND_NAME:
case DEMANGLE_COMPONENT_VECTOR_TYPE:
case DEMANGLE_COMPONENT_CLONE:
if (left == NULL || right == NULL)
if (!left || !right)
return NULL;
break;
@ -893,7 +893,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type,
case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS:
case DEMANGLE_COMPONENT_NULLARY:
case DEMANGLE_COMPONENT_TRINARY_ARG2:
if (left == NULL)
if (!left)
return NULL;
break;
@ -901,7 +901,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type,
empty. */
case DEMANGLE_COMPONENT_ARRAY_TYPE:
case DEMANGLE_COMPONENT_INITIALIZER_LIST:
if (right == NULL)
if (!right)
return NULL;
break;
@ -967,7 +967,7 @@ d_make_builtin_type (struct d_info *di,
{
struct demangle_component *p;
if (type == NULL)
if (!type)
return NULL;
p = d_make_empty (di);
if (p != NULL)
@ -1143,7 +1143,7 @@ cplus_demangle_mangled_name (struct d_info *di, int top_level)
static int
has_return_type (struct demangle_component *dc)
{
if (dc == NULL)
if (!dc)
return 0;
switch (dc->type)
{
@ -1166,7 +1166,7 @@ has_return_type (struct demangle_component *dc)
static int
is_ctor_dtor_or_conversion (struct demangle_component *dc)
{
if (dc == NULL)
if (!dc)
return 0;
switch (dc->type)
{
@ -1238,7 +1238,7 @@ d_encoding (struct d_info *di, int top_level)
}
peek = d_peek_char (di);
if (dc == NULL || peek == '\0' || peek == 'E')
if (!dc || peek == '\0' || peek == 'E')
return dc;
return d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME, dc,
d_bare_function_type (di, has_return_type (dc)));
@ -1366,7 +1366,7 @@ d_nested_name (struct d_info *di)
return NULL;
pret = d_cv_qualifiers (di, &ret, 1);
if (pret == NULL)
if (!pret)
return NULL;
/* Parse the ref-qualifier now and then attach it
@ -1374,7 +1374,7 @@ d_nested_name (struct d_info *di)
rqual = d_ref_qualifier (di, NULL);
*pret = d_prefix (di);
if (*pret == NULL)
if (!*pret)
return NULL;
if (rqual)
@ -1441,7 +1441,7 @@ d_prefix (struct d_info *di)
dc = d_substitution (di, 1);
else if (peek == 'I')
{
if (ret == NULL)
if (!ret)
return NULL;
comb_type = DEMANGLE_COMPONENT_TEMPLATE;
dc = d_template_args (di);
@ -1455,7 +1455,7 @@ d_prefix (struct d_info *di)
/* Initializer scope for a lambda. We don't need to represent
this; the normal code will just treat the variable as a type
scope, which gives appropriate output. */
if (ret == NULL)
if (!ret)
return NULL;
d_advance (di, 1);
continue;
@ -1463,7 +1463,7 @@ d_prefix (struct d_info *di)
else
return NULL;
if (ret == NULL)
if (!ret)
ret = dc;
else
ret = d_make_comp (di, comb_type, ret, dc);
@ -1511,7 +1511,7 @@ d_unqualified_name (struct d_info *di)
d_advance (di, 1);
ret = d_source_name (di);
if (ret == NULL)
if (!ret)
return NULL;
if (! d_discriminator (di))
return NULL;
@ -1826,7 +1826,7 @@ d_java_resource (struct d_info *di)
str = d_str (di);
len -= i;
i = 0;
if (next == NULL)
if (!next)
return NULL;
}
/* ... or a sequence of characters. */
@ -1840,16 +1840,16 @@ d_java_resource (struct d_info *di)
str = d_str (di);
len -= i;
i = 0;
if (next == NULL)
if (!next)
return NULL;
}
if (p == NULL)
if (!p)
p = next;
else
{
p = d_make_comp (di, DEMANGLE_COMPONENT_COMPOUND_NAME, p, next);
if (p == NULL)
if (!p)
return NULL;
}
}
@ -2208,7 +2208,7 @@ cplus_demangle_type (struct d_info *di)
struct demangle_component **pret;
pret = d_cv_qualifiers (di, &ret, 0);
if (pret == NULL)
if (!pret)
return NULL;
if (d_peek_char (di) == 'F')
{
@ -2427,7 +2427,7 @@ cplus_demangle_type (struct d_info *di)
/* For demangling we don't care about the bits. */
d_number (di);
ret->u.s_fixed.length = cplus_demangle_type (di);
if (ret->u.s_fixed.length == NULL)
if (!ret->u.s_fixed.length)
return NULL;
d_number (di);
peek = d_next_char (di);
@ -2502,7 +2502,7 @@ d_cv_qualifiers (struct d_info *di,
}
*pret = d_make_comp (di, t, NULL, NULL);
if (*pret == NULL)
if (!*pret)
return NULL;
pret = &d_left (*pret);
@ -2610,10 +2610,10 @@ d_parmlist (struct d_info *di)
/* Function ref-qualifier, not a ref prefix for a parameter type. */
break;
type = cplus_demangle_type (di);
if (type == NULL)
if (!type)
return NULL;
*ptl = d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, type, NULL);
if (*ptl == NULL)
if (!*ptl)
return NULL;
ptl = &d_right (*ptl);
}
@ -2621,11 +2621,11 @@ d_parmlist (struct d_info *di)
/* There should be at least one parameter type besides the optional
return type. A function which takes no arguments will have a
single parameter type void. */
if (tl == NULL)
if (!tl)
return NULL;
/* If we have a single parameter type void, omit it. */
if (d_right (tl) == NULL
if (!d_right (tl)
&& d_left (tl)->type == DEMANGLE_COMPONENT_BUILTIN_TYPE
&& d_left (tl)->u.s_builtin.type->print == D_PRINT_VOID)
{
@ -2657,14 +2657,14 @@ d_bare_function_type (struct d_info *di, int has_return_type)
if (has_return_type)
{
return_type = cplus_demangle_type (di);
if (return_type == NULL)
if (!return_type)
return NULL;
}
else
return_type = NULL;
tl = d_parmlist (di);
if (tl == NULL)
if (!tl)
return NULL;
return d_make_comp (di, DEMANGLE_COMPONENT_FUNCTION_TYPE,
@ -2707,13 +2707,13 @@ d_array_type (struct d_info *di)
}
while (IS_DIGIT (peek));
dim = d_make_name (di, s, d_str (di) - s);
if (dim == NULL)
if (!dim)
return NULL;
}
else
{
dim = d_expression (di);
if (dim == NULL)
if (!dim)
return NULL;
}
@ -2742,7 +2742,7 @@ d_vector_type (struct d_info *di)
else
dim = d_number_component (di);
if (dim == NULL)
if (!dim)
return NULL;
if (! d_check_char (di, '_'))
@ -2764,7 +2764,7 @@ d_pointer_to_member_type (struct d_info *di)
return NULL;
cl = cplus_demangle_type (di);
if (cl == NULL)
if (!cl)
return NULL;
/* The ABI says, "The type of a non-static member function is considered
@ -2783,7 +2783,7 @@ d_pointer_to_member_type (struct d_info *di)
wrong type in the substitution table is harmless. */
mem = cplus_demangle_type (di);
if (mem == NULL)
if (!mem)
return NULL;
return d_make_comp (di, DEMANGLE_COMPONENT_PTRMEM_TYPE, cl, mem);
@ -2861,11 +2861,11 @@ d_template_args (struct d_info *di)
struct demangle_component *a;
a = d_template_arg (di);
if (a == NULL)
if (!a)
return NULL;
*pal = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, a, NULL);
if (*pal == NULL)
if (!*pal)
return NULL;
pal = &d_right (*pal);
@ -2931,11 +2931,11 @@ d_exprlist (struct d_info *di, char terminator)
while (1)
{
struct demangle_component *arg = d_expression (di);
if (arg == NULL)
if (!arg)
return NULL;
*p = d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, arg, NULL);
if (*p == NULL)
if (!*p)
return NULL;
p = &d_right (*p);
@ -3034,7 +3034,7 @@ d_expression (struct d_info *di)
d_advance (di, 2);
name = d_unqualified_name (di);
if (name == NULL)
if (!name)
return NULL;
if (d_peek_char (di) == 'I')
return d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, name,
@ -3060,7 +3060,7 @@ d_expression (struct d_info *di)
int args;
op = d_operator_name (di);
if (op == NULL)
if (!op)
return NULL;
if (op->type == DEMANGLE_COMPONENT_OPERATOR)
@ -3222,7 +3222,7 @@ d_expr_primary (struct d_info *di)
const char *s;
type = cplus_demangle_type (di);
if (type == NULL)
if (!type)
return NULL;
/* If we have a type we know how to print, we aren't going to
@ -3355,7 +3355,7 @@ d_lambda (struct d_info *di)
return NULL;
tl = d_parmlist (di);
if (tl == NULL)
if (!tl)
return NULL;
if (! d_check_char (di, 'E'))
@ -3441,7 +3441,7 @@ d_clone_suffix (struct d_info *di, struct demangle_component *encoding)
static int
d_add_substitution (struct d_info *di, struct demangle_component *dc)
{
if (dc == NULL)
if (!dc)
return 0;
if (di->next_sub >= di->num_subs)
return 0;
@ -3617,7 +3617,7 @@ d_growable_string_resize (struct d_growable_string *dgs, size_t need)
newalc <<= 1;
newbuf = (char *) realloc (dgs->buf, newalc);
if (newbuf == NULL)
if (!newbuf)
{
free (dgs->buf);
dgs->buf = NULL;
@ -3846,7 +3846,7 @@ d_index_template_argument (struct demangle_component *args, int i)
break;
--i;
}
if (i != 0 || a == NULL)
if (i != 0 || !a)
return NULL;
return d_left (a);
@ -3859,7 +3859,7 @@ static struct demangle_component *
d_lookup_template_argument (struct d_print_info *dpi,
const struct demangle_component *dc)
{
if (dpi->templates == NULL)
if (!dpi->templates)
{
d_print_error (dpi);
return NULL;
@ -3877,7 +3877,7 @@ d_find_pack (struct d_print_info *dpi,
const struct demangle_component *dc)
{
struct demangle_component *a;
if (dc == NULL)
if (!dc)
return NULL;
switch (dc->type)
@ -3966,7 +3966,7 @@ d_copy_templates (struct d_print_info *dpi)
struct d_print_template *dst =
(struct d_print_template *) malloc (sizeof (struct d_print_template));
if (dst == NULL)
if (!dst)
{
d_print_error (dpi);
break;
@ -3999,7 +3999,7 @@ d_print_comp (struct d_print_info *dpi, int options,
/* Nonzero if templates have been stored in the above variable. */
int need_template_restore = 0;
if (dc == NULL)
if (!dc)
{
d_print_error (dpi);
return;
@ -4083,7 +4083,7 @@ d_print_comp (struct d_print_info *dpi, int options,
typed_name = d_left (typed_name);
}
if (typed_name == NULL)
if (!typed_name)
{
d_print_error (dpi);
return;
@ -4209,7 +4209,7 @@ d_print_comp (struct d_print_info *dpi, int options,
if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST)
a = d_index_template_argument (a, dpi->pack_index);
if (a == NULL)
if (!a)
{
d_print_error (dpi);
return;
@ -4375,7 +4375,7 @@ d_print_comp (struct d_print_info *dpi, int options,
if (dpi->saved_scopes[i].container == sub)
scope = &dpi->saved_scopes[i];
if (scope == NULL)
if (!scope)
{
size_t size;
@ -4387,7 +4387,7 @@ d_print_comp (struct d_print_info *dpi, int options,
size = sizeof (struct d_saved_scope) * dpi->num_saved_scopes;
scopes = (struct d_saved_scope *) realloc (dpi->saved_scopes,
size);
if (scopes == NULL)
if (!scopes)
{
d_print_error (dpi);
return;
@ -4414,7 +4414,7 @@ d_print_comp (struct d_print_info *dpi, int options,
if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST)
a = d_index_template_argument (a, dpi->pack_index);
if (a == NULL)
if (!a)
{
if (need_template_restore)
dpi->templates = saved_templates;
@ -4973,7 +4973,7 @@ d_print_comp (struct d_print_info *dpi, int options,
int len;
int i;
struct demangle_component *a = d_find_pack (dpi, d_left (dc));
if (a == NULL)
if (!a)
{
/* d_find_pack won't find anything if the only packs involved
in this expansion are function parameter packs; in that
@ -5107,7 +5107,7 @@ d_print_mod_list (struct d_print_info *dpi, int options,
{
struct d_print_template *hold_dpt;
if (mods == NULL || d_print_saw_error (dpi))
if (!mods || d_print_saw_error (dpi))
return;
if (mods->printed
@ -5636,14 +5636,14 @@ __cxa_demangle (const char *mangled_name, char *output_buffer,
char *demangled;
size_t alc;
if (mangled_name == NULL)
if (!mangled_name)
{
if (status != NULL)
*status = -3;
return NULL;
}
if (output_buffer != NULL && length == NULL)
if (output_buffer != NULL && !length)
{
if (status != NULL)
*status = -3;
@ -5652,7 +5652,7 @@ __cxa_demangle (const char *mangled_name, char *output_buffer,
demangled = d_demangle (mangled_name, DMGL_PARAMS | DMGL_TYPES, &alc);
if (demangled == NULL)
if (!demangled)
{
if (status != NULL)
{
@ -5664,7 +5664,7 @@ __cxa_demangle (const char *mangled_name, char *output_buffer,
return NULL;
}
if (output_buffer == NULL)
if (!output_buffer)
{
if (length != NULL)
*length = alc;
@ -5721,7 +5721,7 @@ __gcclibcxx_demangle_callback (const char *mangled_name,
{
int status;
if (mangled_name == NULL || callback == NULL)
if (!mangled_name || !callback)
return -3;
status = d_demangle_callback (mangled_name, DMGL_PARAMS | DMGL_TYPES,

View File

@ -42,7 +42,7 @@ EDemanglerErr create_demangler(SDemangler **demangler)
*demangler = (SDemangler *) malloc(sizeof(SDemangler));
if (*demangler == NULL) {
if (!*demangler) {
err = eDemanglerErrMemoryAllocation;
goto create_demagler_err;
}

View File

@ -130,7 +130,7 @@ int copy_string(STypeCodeStr *type_code_str, char *str_for_copy, unsigned int co
((type_code_str->type_str_len + str_for_copy_len) << 1) + 1;
type_code_str->type_str = (char *) realloc( type_code_str->type_str,
type_code_str->type_str_len);
if (type_code_str->type_str == NULL) {
if (!type_code_str->type_str) {
res = 0;
goto copy_string_err;
}
@ -1342,7 +1342,7 @@ static EDemanglerErr parse_microsoft_mangled_name(char *sym, char **demangled_na
if (access_modifier) {
copy_string(&func_str, access_modifier, 0);
if (strstr(access_modifier, "static") == NULL) {
if (!strstr(access_modifier, "static")) {
copy_string(&func_str, ": ", 0);
} else {
copy_string(&func_str, " ", 0);

View File

@ -52,7 +52,7 @@ static RList* entries(RBinFile *arch) {
static RBinInfo* info(RBinFile *arch) {
RBinInfo *ret = NULL;
bool big_endian = 0;
if ((ret = R_NEW0 (RBinInfo)) == NULL)
if (!(ret = R_NEW0 (RBinInfo)))
return NULL;
ret->file = strdup (arch->file);
ret->bclass = strdup ("dyldcache");

View File

@ -159,7 +159,7 @@ static RList* sections(RBinFile *arch) {
static RBinInfo* info(RBinFile *arch) {
RBinInfo *ret = NULL;
const int bits = 16;
if ((ret = R_NEW0 (RBinInfo)) == NULL)
if (!(ret = R_NEW0 (RBinInfo)))
return NULL;
ret->file = strdup (arch->file);
ret->bclass = strdup ("bootloader");

View File

@ -164,7 +164,7 @@ static RBinInfo* info(RBinFile *arch) {
if (!(bina = r_bin_p9_get_arch (arch->buf->buf, &bits, &big_endian)))
return NULL;
if ((ret = R_NEW0 (RBinInfo)) == NULL)
if (!(ret = R_NEW0 (RBinInfo)))
return NULL;
ret->file = strdup (arch->file);
ret->bclass = strdup ("program");

View File

@ -10,7 +10,7 @@ R_API int r_bp_plugin_del(RBreakpoint *bp, const char *name) {
R_API int r_bp_plugin_add(RBreakpoint *bp, RBreakpointPlugin *foo) {
RListIter *iter;
RBreakpointPlugin *h;
if (bp == NULL) {
if (!bp) {
eprintf ("Cannot add plugin because dbg->bp is null and/or plugin is null\n");
return false;
}

View File

@ -76,16 +76,16 @@ R_API int r_bp_traptrace_add(RBreakpoint *bp, ut64 from, ut64 to) {
if (len >= ST32_MAX)
return false;
buf = (ut8*) malloc ((int)len);
if (buf == NULL)
if (!buf)
return false;
trap = (ut8*) malloc ((int)len+4);
if (trap == NULL) {
if (!trap) {
free (buf);
return false;
}
bitlen = (len>>4)+1;
bits = malloc (bitlen);
if (bits == NULL) {
if (!bits) {
free (buf);
free (trap);
return false;

View File

@ -215,7 +215,7 @@ R_API RConfigNode *r_config_set(RConfig *cfg, const char *name, const char *valu
free (node->value);
node->value = strdup (r_str_bool (b));
} else {
if (value == NULL) {
if (!value) {
free (node->value);
node->value = strdup ("");
node->i_value = 0;
@ -367,7 +367,7 @@ R_API int r_config_eval(RConfig *cfg, const char *str) {
memcpy (name, str, len);
str = r_str_chop (name);
if (str == NULL) return false;
if (!str) return false;
if (str[0] == '\0' || !strcmp (str, "help")) {
r_config_list (cfg, NULL, 0);

View File

@ -297,7 +297,7 @@ static void palloc(int moar) {
if (moar <= 0) {
return;
}
if (I.buffer == NULL) {
if (!I.buffer) {
int new_sz;
if ((INT_MAX - MOAR) < moar) {
return;

View File

@ -237,7 +237,7 @@ static int r_line_hist_down() {
if (I.history.index<I.history.size
&& I.history.data[I.history.index]) {
I.history.index++;
if (I.history.data[I.history.index] == NULL) {
if (!I.history.data[I.history.index]) {
I.buffer.data[0]='\0';
I.buffer.index = I.buffer.length = 0;
return 0;
@ -287,7 +287,7 @@ R_API int r_line_hist_load(const char *file) {
FILE *fd;
char buf[R_LINE_BUFSIZE],
*path = r_str_home (file);
if (path == NULL)
if (!path)
return false;
if (!(fd = fopen (path, "r"))) {
free (path);
@ -789,7 +789,7 @@ R_API const char *r_line_readline_cb_win(RLineReadCallback cb, void *user) {
// gcomp = 0;
if (I.history.data != NULL)
for (i=0; i<I.history.size; i++) {
if (I.history.data[i] == NULL)
if (!I.history.data[i])
break;
if (strstr (I.history.data[i], I.buffer.data)) {
gcomp_line = I.history.data[i];
@ -1316,7 +1316,7 @@ R_API const char *r_line_readline_cb(RLineReadCallback cb, void *user) {
gcomp_line = "";
if (I.history.data != NULL)
for (i=0; i<I.history.size; i++) {
if (I.history.data[i] == NULL)
if (!I.history.data[i])
break;
if (strstr (I.history.data[i], I.buffer.data)) {
gcomp_line = I.history.data[i];

View File

@ -186,7 +186,7 @@ R_API int r_cons_grepbuf(char *buf, int len) {
char *tline, *tbuf, *p, *out, *in = buf;
int ret, buffer_len = 0, l = 0, tl = 0;
if ((len == 0 || buf == NULL || buf[0] == '\0') &&
if ((len == 0 || !buf || buf[0] == '\0') &&
(cons->grep.json || cons->grep.less)) {
cons->grep.json = 0;
cons->grep.less = 0;

View File

@ -232,7 +232,7 @@ R_API int r_cons_fgets(char *buf, int len, int argc, const char **argv) {
fwrite (p, len, 1, stdout);
fflush (stdout);
}
if (fgets (buf, len, cons->fdin) == NULL) {
if (!fgets (buf, len, cons->fdin)) {
if (color) {
printf (Color_RESET);
fflush (stdout);

View File

@ -159,7 +159,7 @@ R_API int r_cons_less_str(const char *str, const char *exitkeys) {
const char *sreg;
RList **mla;
if (str == NULL || str[0] == '\0') return 0;
if (!str || !*str) return 0;
char *p = strdup (str);
if (!p) return 0;
int *lines = splitlines (p, &lines_count);

View File

@ -2532,7 +2532,7 @@ R_API int r_core_anal_data (RCore *core, ut64 addr, int count, int depth) {
count = R_MIN (count, len);
buf = malloc (len);
if (buf == NULL)
if (!buf)
return false;
memset (buf, 0xff, len);
r_io_read_at (core->io, addr, buf, len);
@ -3027,7 +3027,7 @@ R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) {
return;
}
buf = malloc (iend + 2);
if (buf == NULL) {
if (!buf) {
perror ("malloc");
return;
}

View File

@ -88,7 +88,7 @@ R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut6
tokens[0] = NULL;
for (tokcount=0; tokcount<(sizeof (tokens) / sizeof (char*)) - 1; tokcount++) {
tok = strtok (tokcount? NULL: ptr, ";");
if (tok == NULL)
if (!tok)
break;
tokens[tokcount] = r_str_trim_head_tail (tok);
}
@ -225,7 +225,7 @@ static int prune_hits_in_hit_range(RList *hits, RCoreAsmHit *hit){
RCoreAsmHit *to_check_hit;
int result = 0;
ut64 start_range, end_range;
if (hit == NULL || hits == NULL) return 0;
if (!hit || !hits) return 0;
start_range = hit->addr;
end_range = hit->addr + hit->len;
r_list_foreach_safe (hits, iter, iter_tmp, to_check_hit){
@ -393,7 +393,7 @@ R_API RList *r_core_asm_bwdisassemble (RCore *core, ut64 addr, int n, int len) {
}
buf = (ut8 *)malloc (len);
if (hits == NULL || buf == NULL ){
if (!hits || !buf) {
if (hits) {
r_list_free (hits);
}
@ -453,7 +453,7 @@ static RList * r_core_asm_back_disassemble_all(RCore *core, ut64 addr, ut64 len,
memset (&dummy_value, 0, sizeof (RCoreAsmHit));
if (hits == NULL || buf == NULL ){
if (!hits || !buf ){
if (hits) {
r_list_purge (hits);
free (hits);
@ -516,7 +516,7 @@ static RList *r_core_asm_back_disassemble (RCore *core, ut64 addr, int len, ut64
hits = r_core_asm_hit_list_new ();
buf = malloc (len + extra_padding);
if (hits == NULL || buf == NULL ){
if (!hits || !buf ){
if (hits) {
r_list_purge (hits);
free (hits);

View File

@ -460,7 +460,7 @@ static RCoreFile * r_core_file_set_first_valid(RCore *core) {
}
R_API int r_core_block_read(RCore *core) {
if (core->file == NULL && r_core_file_set_first_valid(core) == NULL) {
if (!core->file && !r_core_file_set_first_valid (core)) {
memset (core->block, core->io->Oxff, core->blocksize);
return -1;
}

View File

@ -66,7 +66,7 @@ R_API RAsmOp *r_core_disassemble (RCore *core, ut64 addr) {
ut8 buf[128];
static RBuffer *b = NULL; // XXX: never freed and non-thread safe. move to RCore
RAsmOp *op;
if (b == NULL) {
if (!b) {
b = r_buf_new ();
if (!b) return NULL;
if (!r_core_read_at (core, addr, buf, sizeof (buf)))
@ -1471,7 +1471,7 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd, char *colon) {
eprintf ("Slurping file '%s'\n", str);
free (core->oobi);
core->oobi = (ut8*)r_file_slurp (str, &core->oobi_len);
if (core->oobi == NULL)
if (!core->oobi)
eprintf ("cannot open file\n");
else if (ptr == cmd)
return r_core_cmd_buffer (core, (const char *)core->oobi);
@ -1912,7 +1912,7 @@ R_API int r_core_cmd_foreach3(RCore *core, const char *cmd, char *each) {
int origpid = dbg->pid;
RDebugPid *p;
list = dbg->h->threads (dbg, dbg->pid);
if (list == NULL)
if (!list)
return false;
r_list_foreach (list, iter, p) {
r_core_cmdf (core, "dp %d", p->pid);
@ -2190,7 +2190,7 @@ R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
if (r_cons_singleton ()->breaked)
break;
r_cmd_macro_call (&core->rcmd->macro, each+2);
if (core->rcmd->macro.brk_value == NULL)
if (!core->rcmd->macro.brk_value)
break;
addr = core->rcmd->macro._brk_value;
@ -2209,7 +2209,7 @@ R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
core->rcmd->macro.counter=0;
while (!feof (fd)) {
buf[0] = '\0';
if (fgets (buf, sizeof (buf), fd) == NULL)
if (!fgets (buf, sizeof (buf), fd))
break;
addr = r_num_math (core->num, buf);
eprintf ("0x%08"PFMT64x": %s\n", addr, cmd);
@ -2234,7 +2234,7 @@ R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) {
ch = str[i];
str[i] = '\0';
word = strdup (str + j);
if (word == NULL)
if (!word)
break;
str[i] = ch;
{
@ -2412,7 +2412,7 @@ R_API int r_core_cmd_command(RCore *core, const char *command) {
char *buf, *rcmd, *ptr;
char *cmd = r_core_sysenv_begin (core, command);
rcmd = ptr = buf = r_sys_cmd_str (cmd, 0, &len);
if (buf == NULL) {
if (!buf) {
free (cmd);
return -1;
}

View File

@ -403,7 +403,7 @@ R_API char *cmd_syscall_dostr(RCore *core, int n) {
}
}
RSyscallItem *item = r_syscall_get (core->anal->syscall, n, -1);
if (item == NULL) {
if (!item) {
res = r_str_concatf (res, "%d = unknown ()", n);
return res;
}

View File

@ -144,7 +144,7 @@ R_API int r_cmd_set_data(RCmd *cmd, void *data) {
R_API int r_cmd_add_long(RCmd *cmd, const char *lcmd, const char *scmd, const char *desc) {
RCmdLongItem *item = R_NEW (RCmdLongItem);
if (item == NULL)
if (!item)
return false;
strncpy (item->cmd, lcmd, sizeof (item->cmd)-1);
strncpy (item->cmd_short, scmd, sizeof (item->cmd_short)-1);
@ -162,7 +162,7 @@ R_API int r_cmd_add(RCmd *c, const char *cmd, const char *desc, r_cmd_callback(c
int idx = (ut8)cmd[0];
item = c->cmds[idx];
if (item == NULL) {
if (!item) {
item = R_NEW (RCmdItem);
c->cmds[idx] = item;
}
@ -226,7 +226,7 @@ R_API int r_cmd_call_long(RCmd *cmd, const char *input) {
int linp = strlen (input+c->cmd_len);
/// SLOW malloc on most situations. use stack
inp = malloc (lcmd+linp+2); // TODO: use static buffer with R_CMD_MAXLEN
if (inp == NULL)
if (!inp)
return -1;
memcpy (inp, c->cmd_short, lcmd);
memcpy (inp+lcmd, input+c->cmd_len, linp+1);
@ -276,7 +276,7 @@ R_API int r_cmd_macro_add(RCmdMacro *mac, const char *oname) {
}
name = strdup (oname);
if (name == NULL) {
if (!name) {
perror ("strdup");
return 0;
}
@ -316,7 +316,7 @@ R_API int r_cmd_macro_add(RCmdMacro *mac, const char *oname) {
}
if (ptr)
*ptr = ' ';
if (macro == NULL) {
if (!macro) {
macro = (struct r_cmd_macro_item_t *)malloc (
sizeof (struct r_cmd_macro_item_t));
macro->name = strdup (name);
@ -326,7 +326,7 @@ R_API int r_cmd_macro_add(RCmdMacro *mac, const char *oname) {
macro->code = (char *)malloc (macro->codelen);
*macro->code = '\0';
macro->nargs = 0;
if (args == NULL)
if (!args)
args = "";
macro->args = strdup (args);
ptr = strchr (macro->name, ' ');
@ -579,12 +579,12 @@ R_API int r_cmd_macro_call(RCmdMacro *mac, const char *name) {
struct r_cmd_macro_label_t labels[MACRO_LABELS];
str = strdup (name);
if (str == NULL) {
if (!str) {
perror ("strdup");
return false;
}
ptr = strchr (str, ')');
if (ptr == NULL) {
if (!ptr) {
eprintf ("Missing end ')' parenthesis.\n");
free (str);
return false;
@ -635,7 +635,7 @@ R_API int r_cmd_macro_call(RCmdMacro *mac, const char *name) {
/* Label handling */
ptr2 = r_cmd_macro_label_process (mac, &(labels[0]), &labels_n, ptr);
if (ptr2 == NULL) {
if (!ptr2) {
eprintf ("Oops. invalid label name\n");
break;
} else

View File

@ -59,7 +59,7 @@ R_API int r_core_cmpwatch_add (RCore *core, ut64 addr, int size, const char *cmd
snprintf (cmpw->cmd, sizeof (cmpw->cmd), "%s", cmd);
cmpw->odata = NULL;
cmpw->ndata = malloc (size);
if (cmpw->ndata == NULL) {
if (!cmpw->ndata) {
free (cmpw);
return false;
}
@ -115,7 +115,7 @@ R_API int r_core_cmpwatch_update (RCore *core, ut64 addr) {
free (w->odata);
w->odata = w->ndata;
w->ndata = malloc (w->size);
if (w->ndata == NULL)
if (!w->ndata)
return false;
r_io_read_at (core->io, w->addr, w->ndata, w->size);
}
@ -145,10 +145,10 @@ static int radare_compare_unified(RCore *core, ut64 of, ut64 od, int len) {
if (len<1)
return false;
f = malloc (len);
if (f == NULL)
if (!f)
return false;
d = malloc (len);
if (d == NULL) {
if (!d) {
free (f);
return false;
}
@ -412,13 +412,13 @@ static int cmd_cmp(void *data, const char *input) {
}
filled = (char*) malloc (strlen (input) + 1);
if (filled == NULL)
if (!filled)
return false;
memcpy (filled, input, strlen (input) + 1);
buf = (ut8*)malloc (strlen (input) + 1);
if (buf == NULL)
if (!buf)
return false;
ret = r_hex_bin2str (core->block, strlen (input) / 2, (char *)buf);
@ -449,7 +449,7 @@ static int cmd_cmp(void *data, const char *input) {
return 0;
}
fd = r_sandbox_fopen (input+2, "rb");
if (fd == NULL) {
if (!fd) {
eprintf ("Cannot open file '%s'\n", input+2);
return 0;
}

View File

@ -1107,7 +1107,7 @@ static int cmd_debug_map(RCore *core, const char *input) {
cmd_dbg_map_heap_glibc_32 (core, input + 1);
} else {
#define GLIBC_BITS_64 1
cmd_dbg_map_heap_glibc_64 (core, input + 1);
cmd_dbg_map_heap_glibc_64 (core, input + 1);
}
#else
eprintf ("MALLOC algorithm not supported\n");
@ -1759,7 +1759,7 @@ static void cmd_debug_reg(RCore *core, const char *str) {
} else {
off = r_debug_reg_get (core->dbg, str + 1);
// r = r_reg_get (core->dbg->reg, str+1, 0);
// if (r == NULL) eprintf ("Unknown register (%s)\n", str+1);
// if (!r) eprintf ("Unknown register (%s)\n", str+1);
r_cons_printf ("0x%08"PFMT64x"\n", off);
core->num->value = off;
}

View File

@ -218,7 +218,7 @@ R_API int r_core_process_input_pade(RCore *core, const char *input, char** hex,
char *str_clone = NULL,
*trimmed_clone = NULL;
if (input == NULL || hex == NULL || asm_arch == NULL || bits == NULL) {
if (!input || !hex || !asm_arch || !bits) {
return false;
}
@ -547,7 +547,7 @@ static void cmd_print_format(RCore *core, const char *_input, int len) {
}
/* store a new format */
if (space && (eq == NULL || space < eq)) {
if (space && (!eq || space < eq)) {
char *fields = NULL;
*space++ = 0;
fields = strchr (space, ' ');
@ -561,7 +561,7 @@ static void cmd_print_format(RCore *core, const char *_input, int len) {
return;
}
if (strchr (name, '.') == NULL && r_strht_get (core->print->formats, name) == NULL) {
if (!strchr (name, '.') && !r_strht_get (core->print->formats, name)) {
eprintf ("Cannot find '%s' format.\n", name);
free (name);
free (input);
@ -2283,7 +2283,7 @@ static int cmd_print(void *data, const char *input) {
//return false;
}
if (new_arch == NULL) new_arch = strdup (old_arch);
if (!new_arch) new_arch = strdup (old_arch);
if (new_bits == -1) new_bits = old_bits;
if (strcmp (new_arch, old_arch) != 0 || new_bits != old_bits){
@ -2538,7 +2538,7 @@ static int cmd_print(void *data, const char *input) {
}
l = use_blocksize;
if (new_arch == NULL) new_arch = strdup (old_arch);
if (!new_arch) new_arch = strdup (old_arch);
if (new_bits == -1) new_bits = old_bits;
if (strcmp (new_arch, old_arch) != 0 || new_bits != old_bits){

View File

@ -351,7 +351,7 @@ static ut64 num_callback(RNum *userptr, const char *str, int *ok) {
}
bptr = strdup (str+3);
ptr = strchr (bptr, '}');
if (ptr == NULL) {
if (!ptr) {
// invalid json
free (bptr);
break;
@ -936,7 +936,7 @@ R_API int r_core_fgets(char *buf, int len) {
rli->completion.argv = radare_argv;
rli->completion.run = autocomplete;
ptr = r_line_readline ();
if (ptr == NULL)
if (!ptr)
return -1;
strncpy (buf, ptr, len);
buf[len-1] = 0;
@ -1253,7 +1253,7 @@ static void r_core_setenv (RCore *core) {
R_API int r_core_init(RCore *core) {
core->blocksize = R_CORE_BLOCKSIZE;
core->block = (ut8*)malloc (R_CORE_BLOCKSIZE+1);
if (core->block == NULL) {
if (!core->block) {
eprintf ("Cannot allocate %d bytes\n", R_CORE_BLOCKSIZE);
/* XXX memory leak */
return false;
@ -1680,7 +1680,7 @@ R_API int r_core_block_size(RCore *core, int bsize) {
bsize = core->blocksize_max;
}
bump = realloc (core->block, bsize+1);
if (bump == NULL) {
if (!bump) {
eprintf ("Oops. cannot allocate that much (%u)\n", bsize);
ret = false;
} else {
@ -1753,7 +1753,7 @@ R_API int r_core_serve(RCore *core, RIODesc *file) {
ut64 x;
rior = (RIORap *)file->data;
if (rior == NULL|| rior->fd == NULL) {
if (!rior|| !rior->fd) {
eprintf ("rap: cannot listen.\n");
return -1;
}
@ -1771,7 +1771,7 @@ reaccept:
if (core->cons->breaked) {
return -1;
}
if (c == NULL) {
if (!c) {
eprintf ("rap: cannot accept\n");
/*r_socket_close (c);*/
r_socket_free (c);
@ -1798,7 +1798,7 @@ reaccept:
pipefd = -1;
ptr = malloc (cmd + 1);
//XXX cmd is ut8..so <256 if (cmd<RMT_MAX)
if (ptr == NULL) {
if (!ptr) {
eprintf ("Cannot malloc in rmt-open len = %d\n", cmd);
} else {
RCoreFile *file;
@ -2056,7 +2056,7 @@ reaccept:
R_API int r_core_search_cb(RCore *core, ut64 from, ut64 to, RCoreSearchCallback cb) {
int ret, len = core->blocksize;
ut8 *buf;
if ((buf = malloc (len)) == NULL)
if (!(buf = malloc (len)))
eprintf ("Cannot allocate blocksize\n");
else while (from<to) {
ut64 delta = to-from;

View File

@ -486,7 +486,7 @@ R_API int r_core_bin_load(RCore *r, const char *filenameuri, ut64 baddr) {
}
if (cf) {
if ((filenameuri == NULL || !*filenameuri)) {
if (!filenameuri || !*filenameuri) {
filenameuri = cf->desc->name;
} else if (cf->desc->name && strcmp (filenameuri, cf->desc->name)) {
// XXX - this needs to be handled appropriately
@ -700,12 +700,12 @@ R_API RCoreFile *r_core_file_open(RCore *r, const char *file, int flags, ut64 lo
}
r->io->bits = r->assembler->bits; // TODO: we need an api for this
fd = r_io_open_nomap (r->io, file, flags, 0644);
if (fd == NULL && openmany > 2) {
if (!fd && openmany > 2) {
// XXX - make this an actual option somewhere?
fh = r_core_file_open_many (r, file, flags, loadaddr);
if (fh) goto beach;
}
if (fd == NULL) {
if (!fd) {
if (flags & 2) {
if (!r_io_create (r->io, file, 0644, 0)) {
goto beach;

View File

@ -61,12 +61,12 @@ static void diffrow(ut64 addr, const char *name, ut32 size, int maxnamelen,
int digits, ut64 addr2, const char *name2, ut32 size2,
const char *match, double dist, int bare) {
if (bare) {
if (addr2 == UT64_MAX || name2 == NULL)
if (addr2 == UT64_MAX || !name2)
printf ("0x%016"PFMT64x" |%8s (%f)\n", addr, match, dist);
else printf ("0x%016"PFMT64x" |%8s (%f) | 0x%016"PFMT64x"\n", addr, match, dist, addr2);
return;
}
if (addr2 == UT64_MAX || name2 == NULL)
if (addr2 == UT64_MAX || !name2)
printf ("%*s %*d 0x%"PFMT64x" |%8s (%f)\n",
maxnamelen, name, digits, size, addr, match, dist);
else printf ("%*s %*d 0x%"PFMT64x" |%8s (%f) | 0x%"PFMT64x" %*d %s\n",

View File

@ -340,7 +340,7 @@ R_API bool r_core_project_save_rdb(RCore *core, const char *file, int opts) {
char *filename, *hl, *ohl = NULL;
int fd, fdold, tmp;
if (file == NULL || *file == '\0')
if (!file || *file == '\0')
return false;
filename = r_str_word_get_first (file);

View File

@ -224,7 +224,7 @@ R_API int r_core_yank_to(RCore *core, const char *_arg) {
free (arg);
return res;
}
if ((str == NULL) || (pos == -1) || (len == 0)) {
if (!str || pos == -1 || len == 0) {
eprintf ("Usage: yt [len] [dst-addr]\n");
free (arg);
return res;

View File

@ -427,7 +427,7 @@ R_API ut64 r_debug_execute(RDebug *dbg, const ut8 *buf, int len, int restore) {
if (ripc) {
r_debug_reg_sync (dbg, R_REG_TYPE_GPR, false);
orig = r_reg_get_bytes (dbg->reg, -1, &orig_sz);
if (orig == NULL) {
if (!orig) {
eprintf ("Cannot get register arena bytes\n");
return 0LL;
}
@ -435,7 +435,7 @@ R_API ut64 r_debug_execute(RDebug *dbg, const ut8 *buf, int len, int restore) {
rsp = r_reg_get_value (dbg->reg, risp);
backup = malloc (len);
if (backup == NULL) {
if (!backup) {
free (orig);
return 0LL;
}

View File

@ -155,7 +155,7 @@ R_API void r_debug_map_list_visual(RDebug *dbg, ut64 addr, int use_color, int co
R_API RDebugMap *r_debug_map_new(char *name, ut64 addr, ut64 addr_end, int perm, int user) {
RDebugMap *map;
/* range could be 0k on OpenBSD, it's a honeypot */
if (name == NULL || addr > addr_end) {
if (!name || addr > addr_end) {
eprintf ("r_debug_map_new: error assert(\
%"PFMT64x">%"PFMT64x")\n", addr, addr_end);
return NULL;

View File

@ -42,7 +42,7 @@ R_API int bfvm_init(BfvmCPU *c, ut32 size, int circular) {
/* data */
c->mem = (ut8 *)malloc (size);
if (c->mem == NULL)
if (!c->mem)
return 0;
memset (c->mem, '\0', size);
@ -112,7 +112,7 @@ R_API void bfvm_dec(BfvmCPU *c) {
R_API int bfvm_reg_set(BfvmCPU *c, const char *str) {
char *ptr = strchr (str, ' ');
if (ptr == NULL)
if (!ptr)
return 0;
if (strstr (str, "eip"))
c->eip = r_num_math (NULL, ptr+1);

View File

@ -447,7 +447,7 @@ static RList *r_debug_native_pids (int pid) {
/* list parents */
dh = opendir ("/proc");
if (dh == NULL) {
if (!dh) {
r_sys_perror ("opendir /proc");
r_list_free (list);
return NULL;
@ -571,7 +571,7 @@ static RList *r_debug_native_pids (int pid) {
static RList *r_debug_native_threads (RDebug *dbg, int pid) {
RList *list = r_list_new ();
if (list == NULL) {
if (!list) {
eprintf ("No list?\n");
return NULL;
}
@ -804,8 +804,8 @@ static RList *r_debug_native_sysctl_map (RDebug *dbg) {
if (sysctl (mib, 4, NULL, &len, NULL, 0) != 0) return NULL;
len = len * 4 / 3;
buf = malloc(len);
if (buf == NULL) return (NULL);
if (sysctl(mib, 4, buf, &len, NULL, 0) != 0) {
if (!buf) {return NULL};
if (sysctl (mib, 4, buf, &len, NULL, 0) != 0) {
free (buf);
return NULL;
}
@ -820,7 +820,7 @@ static RList *r_debug_native_sysctl_map (RDebug *dbg) {
kve = (struct kinfo_vmentry *)(uintptr_t)bp;
map = r_debug_map_new (kve->kve_path, kve->kve_start,
kve->kve_end, kve->kve_protection, 0);
if (map == NULL) break;
if (!map) break;
r_list_append (list, map);
bp += kve->kve_structsize;
}
@ -1425,7 +1425,7 @@ static RList *r_debug_desc_native_list (int pid) {
if (sysctl (mib, 4, NULL, &len, NULL, 0) != 0) return NULL;
len = len * 4 / 3;
buf = malloc(len);
if (buf == NULL) return (NULL);
if (!buf) {return NULL};
if (sysctl (mib, 4, buf, &len, NULL, 0) != 0) {
free (buf);
return NULL;
@ -1478,7 +1478,7 @@ static RList *r_debug_desc_native_list (int pid) {
perm |= (kve->kf_flags & KF_FLAG_WRITE)?R_IO_WRITE:0;
desc = r_debug_desc_new (kve->kf_fd, str, perm, type,
kve->kf_offset);
if (desc == NULL) break;
if (!desc) break;
r_list_append (ret, desc);
}

View File

@ -35,7 +35,7 @@ static RList *r_debug_native_frames(RDebug *dbg, ut64 at) {
}
}
}
if (cb == NULL) {
if (!cb) {
if (dbg->bits == R_SYS_BITS_64) {
cb = backtrace_x86_64;
} else {

View File

@ -153,7 +153,7 @@ static RList *ios_dbg_maps(RDebug *dbg) {
//""); //module_name);
mr = r_debug_map_new (buf, address, address+size,
xwr2rwx (info.protection), 0);
if (mr == NULL) {
if (!mr) {
eprintf ("Cannot create r_debug_map_new\n");
break;
}
@ -258,7 +258,7 @@ static RList *osx_dbg_maps (RDebug *dbg) {
// :: prev_info.max_protection
mr = r_debug_map_new (buf, prev_address, prev_address+prev_size,
xwr2rwx (prev_info.protection), 0);
if (mr == NULL) {
if (!mr) {
eprintf ("Cannot create r_debug_map_new\n");
break;
}

View File

@ -9,7 +9,7 @@ static RList *w32_dbg_modules(RDebug *dbg) {
RList *list = r_list_new ();
hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, pid );
if( hModuleSnap == NULL ) {
if(!hModuleSnap ) {
print_lasterr ((char *)__FUNCTION__, "CreateToolhelp32Snapshot");
CloseHandle( hModuleSnap );
return NULL;
@ -57,7 +57,7 @@ static RList *w32_dbg_maps(RDebug *dbg) {
if (!list) return NULL;
hModuleSnap = CreateToolhelp32Snapshot (TH32CS_SNAPMODULE, pid);
if( hModuleSnap == NULL ) {
if(!hModuleSnap ) {
print_lasterr ((char *)__FUNCTION__, "CreateToolhelp32Snapshot");
CloseHandle( hModuleSnap );
return NULL;
@ -123,11 +123,11 @@ static RList *w32_dbg_maps(RDebug *dbg) {
MEMORY_BASIC_INFORMATION mbi;
memset (&SysInfo, 0, sizeof (SysInfo));
GetSystemInfo (&SysInfo); // TODO: check return value
if (gmi == NULL) {
if (!gmi) {
eprintf ("w32dbg: no gmi\n");
return 0;
}
if (gmbn == NULL) {
if (!gmbn) {
eprintf ("w32dbg: no gmn\n");
return 0;
}
@ -148,11 +148,11 @@ static RList *w32_dbg_maps(RDebug *dbg) {
if (ret_len == sizeof (PeHeader) && CheckValidPE (PeHeader)) {
dos_header = (IMAGE_DOS_HEADER *)PeHeader;
if (dos_header == NULL)
if (!dos_header)
break;
nt_headers = (IMAGE_NT_HEADERS *)((char *)dos_header
+ dos_header->e_lfanew);
if (nt_headers == NULL) {
if (!nt_headers) {
// skip before failing
break;
}
@ -174,7 +174,7 @@ static RList *w32_dbg_maps(RDebug *dbg) {
(ut64)(size_t) (SectionHeader->VirtualAddress + page + SectionHeader->Misc.VirtualSize),
SectionHeader->Characteristics, // XXX?
0);
if (mr == NULL)
if (!mr)
return NULL;
r_list_append (list, mr);
SectionHeader++;
@ -203,7 +203,7 @@ static RList *w32_dbg_maps(RDebug *dbg) {
} else {
mr = r_debug_map_new ("unk", (ut64)(size_t)(page),
(ut64)(size_t)(page+mbi.RegionSize), mbi.Protect, 0);
if (mr == NULL) {
if (!mr) {
eprintf ("Cannot create r_debug_map_new\n");
// XXX leak
return NULL;

View File

@ -184,7 +184,7 @@ static bool w32dbg_SeDebugPrivilege() {
if (!OpenProcessToken (GetCurrentProcess (),
TOKEN_ADJUST_PRIVILEGES, &hToken))
return false;
if (!LookupPrivilegeValue (NULL, SE_DEBUG_NAME, &luidDebug)) {
CloseHandle (hToken);
return false;
@ -250,7 +250,7 @@ static int w32_dbg_init() {
GetProcAddress (GetModuleHandle ("kernel32"), "QueryFullProcessImageNameA");
lib = LoadLibrary ("psapi.dll");
if(lib == NULL) {
if(!lib) {
eprintf ("Cannot load psapi.dll. Aborting\n");
return false;
}
@ -269,8 +269,8 @@ static int w32_dbg_init() {
w32_ntqueryobject = (NTSTATUS WINAPI (*)(HANDLE, ULONG, PVOID, ULONG, PULONG))
GetProcAddress(lib,"NtQueryObject");
if (w32_detach == NULL || w32_openthread == NULL || w32_dbgbreak == NULL ||
gmbn == NULL || gmi == NULL) {
if (!w32_detach || !w32_openthread || !w32_dbgbreak ||
!gmbn || !gmi) {
// OOPS!
eprintf ("debug_init_calls:\n"
"DebugActiveProcessStop: 0x%p\n"
@ -294,12 +294,12 @@ static HANDLE w32_open_process (DWORD access, BOOL inherit, DWORD pid) {
#if 0
static HANDLE w32_t2h(pid_t tid) {
TH_INFO *th = get_th (tid);
if(th == NULL) {
if(!th) {
/* refresh thread list */
w32_dbg_threads (tid);
/* try to search thread */
if((th = get_th (tid)) == NULL)
if(!(th = get_th (tid)))
return NULL;
}
return th->ht;
@ -324,7 +324,7 @@ static int w32_first_thread(int pid) {
THREADENTRY32 te32;
te32.dwSize = sizeof (THREADENTRY32);
if (w32_openthread == NULL) {
if (!w32_openthread) {
eprintf("w32_thread_list: no w32_openthread?\n");
return -1;
}
@ -342,7 +342,7 @@ static int w32_first_thread(int pid) {
/* get all threads of process */
if (te32.th32OwnerProcessID == pid) {
thid = w32_openthread (THREAD_ALL_ACCESS, 0, te32.th32ThreadID);
if (thid == NULL) {
if (!thid) {
print_lasterr ((char *)__FUNCTION__, "OpenThread");
goto err_load_th;
}
@ -438,7 +438,7 @@ static char *get_file_name_from_handle (HANDLE handle_file) {
CloseHandle (handle_file_map);
return NULL;
}
TCHAR name[MAX_PATH];
TCHAR drive[3] = TEXT (" :");
BOOL found = FALSE;
@ -493,7 +493,7 @@ static void r_debug_lstLibAdd(DWORD pid,LPVOID lpBaseOfDll, HANDLE hFile,char *
lstLib = VirtualAlloc (0, PLIB_MAX * sizeof (LIB_ITEM), MEM_COMMIT, PAGE_READWRITE);
lstLibPtr = (PLIB_ITEM)lstLib;
for (x=0; x<PLIB_MAX; x++) {
if (lstLibPtr->hFile == NULL) {
if (!lstLibPtr->hFile) {
lstLibPtr->pid = pid;
lstLibPtr->hFile = hFile; //DBGEvent->u.LoadDll.hFile;
lstLibPtr->BaseOfDll = lpBaseOfDll;//DBGEvent->u.LoadDll.lpBaseOfDll;
@ -672,7 +672,7 @@ RList *w32_thread_list (int pid, RList *list) {
te32.dwSize = sizeof(THREADENTRY32);
if (w32_openthread == NULL) {
if (!w32_openthread) {
eprintf("w32_thread_list: no w32_openthread?\n");
return list;
}
@ -696,7 +696,7 @@ RList *w32_thread_list (int pid, RList *list) {
82 DWORD dwFlags;
#endif
thid = w32_openthread (THREAD_ALL_ACCESS, 0, te32.th32ThreadID);
if (thid == NULL) {
if (!thid) {
print_lasterr((char *)__FUNCTION__, "OpenThread");
goto err_load_th;
}
@ -713,7 +713,7 @@ static RDebugPid *build_debug_pid(PROCESSENTRY32 *pe) {
HANDLE process = w32_open_process (0x1000, //PROCESS_QUERY_LIMITED_INFORMATION,
FALSE, pe->th32ProcessID);
if (process == INVALID_HANDLE_VALUE || w32_queryfullprocessimagename == NULL) {
if (process == INVALID_HANDLE_VALUE || !w32_queryfullprocessimagename) {
return r_debug_pid_new (pe->szExeFile, pe->th32ProcessID, 's', 0);
}
@ -751,7 +751,7 @@ RList *w32_pids (int pid, RList *list) {
if (show_all_pids ||
pe.th32ProcessID == pid ||
pe.th32ParentProcessID == pid) {
RDebugPid *debug_pid = build_debug_pid (&pe);
if (debug_pid) {
r_list_append (list, debug_pid);
@ -805,7 +805,7 @@ void w32_break_process (void *d) {
return;
}
lib = LoadLibrary ("kernel32.dll");
if (lib == NULL) {
if (!lib) {
print_lasterr ((char *)__FUNCTION__, "LoadLibrary");
CloseHandle (process);
return;

View File

@ -878,7 +878,7 @@ RDebugPid *xnu_get_pid (int pid) {
#endif
/* Allocate space for the arguments. */
procargs = (char *)malloc (argmax);
if (procargs == NULL) {
if (!procargs) {
eprintf ("getcmdargs(): insufficient memory for procargs %d\n",
(int)(size_t)argmax);
return NULL;

View File

@ -32,7 +32,7 @@ R_API int r_debug_pid_list(RDebug *dbg, int pid, char fmt) {
RDebugPid *p;
if (dbg && dbg->h && dbg->h->pids) {
list = dbg->h->pids (R_MAX (0, pid));
if (list == NULL)
if (!list)
return false;
if (fmt == 'j')
dbg->cb_printf ("[");
@ -68,7 +68,7 @@ R_API int r_debug_thread_list(RDebug *dbg, int pid) {
}
if (dbg && dbg->h && dbg->h->threads) {
list = dbg->h->threads (dbg, pid);
if (list == NULL) return false;
if (!list) return false;
if (pid == -'j') {
dbg->cb_printf ("[");
r_list_foreach (list, iter, p) {

Some files were not shown because too many files have changed in this diff Show More