From f8a35da205b26352ea3c851f9fa3dff154f46266 Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 15 Mar 2022 19:54:04 +0100 Subject: [PATCH] Dont use != NULL as its implicit in C, even for bool casts ##refactor $ find binr libr -name "*.c" -exec sed -i -e 's/ != NULL//g' {} \; --- libr/anal/arch/z80/expressions.c | 2 +- libr/anal/dwarf_process.c | 4 +- libr/anal/jmptbl.c | 4 +- libr/anal/meta.c | 2 +- libr/anal/p/anal_avr.c | 2 +- libr/anal/p/anal_or1k.c | 4 +- libr/anal/rtti_msvc.c | 6 +- libr/anal/sign.c | 2 +- libr/asm/arch/6502/6502dis.c | 2 +- libr/asm/arch/amd29k/amd29k.c | 2 +- libr/asm/arch/arc/gnu/arc-ext.c | 4 +- libr/asm/arch/arc/gnu/arc-opc.c | 14 +-- libr/asm/arch/arc/gnu/arcompact-dis.c | 6 +- libr/asm/arch/arm/aarch64/aarch64-dis.c | 8 +- libr/asm/arch/arm/aarch64/aarch64-opc.c | 6 +- libr/asm/arch/arm/armass.c | 2 +- libr/asm/arch/arm/armass64.c | 2 +- libr/asm/arch/arm/gnu/arm-dis.c | 20 ++-- libr/asm/arch/avr/assemble.c | 2 +- libr/asm/arch/avr/format.c | 4 +- libr/asm/arch/cris/gnu/cris-dis.c | 18 +-- libr/asm/arch/mips/gnu/mips-dis.c | 26 ++--- libr/asm/arch/nios/gnu/nios2-dis.c | 8 +- libr/asm/arch/ppc/gnu/ppc-dis.c | 32 +++--- libr/asm/arch/s390/gnu/s390-dis.c | 8 +- libr/asm/arch/sparc/gnu/sparc-dis.c | 2 +- .../arch/tms320/c55x_plus/c55plus_decode.c | 2 +- libr/asm/arch/tms320/c55x_plus/decode_funcs.c | 10 +- libr/asm/arch/tricore/gnu/tricore-dis.c | 6 +- libr/asm/arch/vax/vax-dis.c | 2 +- libr/asm/arch/xtensa/gnu/elf32-xtensa.c | 106 +++++++++--------- libr/asm/p/asm_or1k.c | 2 +- libr/asm/p/asm_xap.c | 2 +- libr/bin/bfile.c | 4 +- libr/bin/dwarf.c | 2 +- libr/bin/format/elf/elf.c | 24 ++-- libr/bin/format/pe/dotnet.c | 18 +-- libr/bin/format/pe/pe.c | 2 +- libr/bin/format/pe/pe64_write.c | 2 +- libr/bin/mangling/cxx/cp-demangle.c | 82 +++++++------- libr/bin/mangling/microsoft_demangle.c | 2 +- libr/bin/p/bin_coff.c | 2 +- libr/bin/p/bin_dex.c | 2 +- libr/bin/p/bin_fs.c | 2 +- libr/bin/p/bin_ninds.c | 2 +- libr/bin/p/bin_ningb.c | 2 +- libr/bin/p/bin_nro.c | 2 +- libr/bin/p/bin_nso.c | 2 +- libr/bin/p/bin_omf.c | 2 +- libr/bin/p/bin_xtr_fatmach0.c | 2 +- libr/bin/p/bin_xtr_sep64.c | 2 +- libr/bin/p/bin_zimg.c | 2 +- libr/bin/pdb/pdb.c | 2 +- libr/bin/pdb/tpi.c | 2 +- libr/cons/cutf8.c | 2 +- libr/cons/dietline.c | 4 +- libr/core/agraph.c | 8 +- libr/core/anal_tp.c | 4 +- libr/core/canal.c | 2 +- libr/core/casm.c | 2 +- libr/core/cbin.c | 41 ++++--- libr/core/cmd.c | 8 +- libr/core/cmd_anal.c | 8 +- libr/core/cmd_api.c | 2 +- libr/core/cmd_cmp.c | 2 +- libr/core/cmd_debug.c | 2 +- libr/core/cmd_flag.c | 2 +- libr/core/cmd_help.c | 2 +- libr/core/cmd_info.c | 2 +- libr/core/cmd_seek.c | 2 +- libr/core/cmd_write.c | 2 +- libr/core/rvc.c | 2 +- libr/core/vmenus.c | 4 +- libr/crypto/crypto.c | 2 +- libr/debug/debug.c | 6 +- libr/debug/dreg.c | 2 +- libr/debug/p/bfvm.c | 4 +- libr/debug/p/native/bsd/bsd_debug.c | 2 +- libr/debug/p/native/bt/generic_x86.c | 2 +- libr/debug/p/native/w32.c | 6 +- libr/debug/p/native/windows/windows_debug.c | 2 +- libr/debug/p/native/windows/windows_message.c | 2 +- libr/egg/egg.c | 2 +- libr/egg/rlcc/rlcc.c | 2 +- libr/io/io_fd.c | 2 +- libr/io/io_map.c | 2 +- libr/io/p/io_ar.c | 2 +- libr/io/p/io_bfdbg.c | 2 +- libr/io/p/io_mmap.c | 2 +- libr/io/p/io_rap.c | 2 +- libr/io/p/io_zip.c | 2 +- libr/lang/p/pipe.c | 2 +- libr/magic/apprentice.c | 6 +- libr/magic/fsmagic.c | 2 +- libr/magic/magic.c | 4 +- libr/parse/c/tccgen.c | 10 +- libr/parse/c/tccpp.c | 2 +- libr/parse/p/parse_6502_pseudo.c | 4 +- libr/parse/p/parse_att2intel.c | 8 +- libr/parse/p/parse_avr_pseudo.c | 8 +- libr/parse/p/parse_dalvik_pseudo.c | 8 +- libr/parse/p/parse_m68k_pseudo.c | 8 +- libr/parse/p/parse_mips_pseudo.c | 8 +- libr/parse/p/parse_ppc_pseudo.c | 4 +- libr/parse/p/parse_sh_pseudo.c | 8 +- libr/parse/p/parse_z80_pseudo.c | 8 +- libr/search/bytepat.c | 4 +- libr/search/keyword.c | 4 +- libr/util/calc.c | 2 +- libr/util/format.c | 25 ++--- libr/util/idpool.c | 2 +- libr/util/lib.c | 2 +- libr/util/new_rbtree.c | 2 +- libr/util/qrcode.c | 3 +- libr/util/regex/engine.c | 14 +-- libr/util/regex/regcomp.c | 8 +- libr/util/str.c | 4 +- libr/util/str_constpool.c | 2 +- libr/util/table.c | 2 +- libr/util/unum.c | 2 +- shlr/gdb/src/gdbclient/xml.c | 20 ++-- 121 files changed, 409 insertions(+), 408 deletions(-) diff --git a/libr/anal/arch/z80/expressions.c b/libr/anal/arch/z80/expressions.c index 47b3bbfa29..101060ad8c 100644 --- a/libr/anal/arch/z80/expressions.c +++ b/libr/anal/arch/z80/expressions.c @@ -268,7 +268,7 @@ rd_label (const char **p, int *exists, struct label **previous, int level, /* Return a value to discriminate between non-existing and invalid */ if (verbose >= 7) fprintf (stderr, "rd_label returns invalid value\n"); - return l != NULL; + return (int)(bool)l; } if (exists) *exists = 1; diff --git a/libr/anal/dwarf_process.c b/libr/anal/dwarf_process.c index 7fbcbe182e..d441a0973f 100644 --- a/libr/anal/dwarf_process.c +++ b/libr/anal/dwarf_process.c @@ -110,7 +110,7 @@ static bool strbuf_rev_prepend_char(RStrBuf *sb, const char *s, int c) { memcpy (ns + idx, s, l); memcpy (ns + idx + l, sb_str + idx, sb->len - idx); ns[newlen] = 0; - ret = r_strbuf_set (sb, ns) != NULL; + ret = r_strbuf_set (sb, ns); free (ns); } return ret; @@ -145,7 +145,7 @@ static bool strbuf_rev_append_char(RStrBuf *sb, const char *s, const char *needl memcpy (ns + idx, s, l); memcpy (ns + idx + l, sb_str + idx, sb->len - idx); ns[newlen] = 0; - ret = r_strbuf_set (sb, ns) != NULL; + ret = r_strbuf_set (sb, ns); free (ns); } return ret; diff --git a/libr/anal/jmptbl.c b/libr/anal/jmptbl.c index 4864590e3b..1fc7d3eaa2 100644 --- a/libr/anal/jmptbl.c +++ b/libr/anal/jmptbl.c @@ -429,8 +429,8 @@ R_API bool try_get_jmptbl_info(RAnal *anal, RAnalFunction *fcn, ut64 addr, RAnal /* if UJMP is in .plt section just skip it */ RBinSection *s = anal->binb.get_vsect_at (anal->binb.bin, addr); if (s && s->name[0]) { - bool in_plt = strstr (s->name, ".plt") != NULL; - if (!in_plt && strstr (s->name, "_stubs") != NULL) { + bool in_plt = strstr (s->name, ".plt"); + if (!in_plt && strstr (s->name, "_stubs")) { /* for mach0 */ in_plt = true; } diff --git a/libr/anal/meta.c b/libr/anal/meta.c index b6d3e4e494..3a6aff1399 100644 --- a/libr/anal/meta.c +++ b/libr/anal/meta.c @@ -237,7 +237,7 @@ R_API const char *r_meta_type_to_string(int type) { } R_API void r_meta_print(RAnal *a, RAnalMetaItem *d, ut64 start, ut64 size, int rad, PJ *pj, bool show_full) { - r_return_if_fail (!(rad == 'j' && !pj)); // rad == 'j' => pj != NULL + r_return_if_fail (!(rad == 'j' && !pj)); // rad == 'j' => pj char *pstr, *base64_str; RCore *core = a->coreb.core; bool esc_bslash = core ? core->print->esc_bslash : false; diff --git a/libr/anal/p/anal_avr.c b/libr/anal/p/anal_avr.c index e48c4be81a..c940a1c1c3 100644 --- a/libr/anal/p/anal_avr.c +++ b/libr/anal/p/anal_avr.c @@ -243,7 +243,7 @@ static CPU_CONST *const_by_value(CPU_MODEL *cpu, int type, ut32 v) { static RStrBuf *__generic_io_dest(ut8 port, int write, CPU_MODEL *cpu) { RStrBuf *r = r_strbuf_new (""); CPU_CONST *c = const_by_value (cpu, CPU_CONST_REG, port); - if (c != NULL) { + if (c) { r_strbuf_set (r, c->key); if (write) { r_strbuf_append (r, ",="); diff --git a/libr/anal/p/anal_or1k.c b/libr/anal/p/anal_or1k.c index 173aff73fa..fa9d896e24 100644 --- a/libr/anal/p/anal_or1k.c +++ b/libr/anal/p/anal_or1k.c @@ -172,9 +172,9 @@ static int or1k_op(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *data, int len, R /* if name is null, but extra is present, it means 6 most significant bits * are not enough to decode instruction */ - if ((insn_descr->name == NULL) && (insn_descr->extra != NULL)) { + if ((insn_descr->name == NULL) && (insn_descr->extra)) { extra_descr = find_extra_descriptor(insn_descr->extra, insn); - if (extra_descr != NULL) { + if (extra_descr) { insn_to_op(a, op, addr, insn_descr, extra_descr, insn); } } diff --git a/libr/anal/rtti_msvc.c b/libr/anal/rtti_msvc.c index 07ca71f0d3..29e84e6b8e 100644 --- a/libr/anal/rtti_msvc.c +++ b/libr/anal/rtti_msvc.c @@ -781,7 +781,7 @@ RecoveryCompleteObjectLocator *recovery_anal_complete_object_locator(RRTTIMSVCAn RecoveryTypeDescriptor *recovery_anal_type_descriptor(RRTTIMSVCAnalContext *context, ut64 addr, RecoveryCompleteObjectLocator *col) { RecoveryTypeDescriptor *td = ht_up_find (context->addr_td, addr, NULL); if (td) { - if (col != NULL) { + if (col) { td->col = col; } return td; @@ -901,7 +901,7 @@ static const char *recovery_apply_complete_object_locator(RRTTIMSVCAnalContext * RAnal *anal = context->vt_context->anal; const char *existing = ht_up_find (context->col_td_classes, col->addr, NULL); - if (existing != NULL) { + if (existing) { return existing; } @@ -942,7 +942,7 @@ static const char *recovery_apply_type_descriptor(RRTTIMSVCAnalContext *context, RAnal *anal = context->vt_context->anal; const char *existing = ht_up_find (context->col_td_classes, td->addr, NULL); - if (existing != NULL) { + if (existing) { return existing; } diff --git a/libr/anal/sign.c b/libr/anal/sign.c index e3a20d4d30..4cbf2b11f9 100644 --- a/libr/anal/sign.c +++ b/libr/anal/sign.c @@ -661,7 +661,7 @@ R_API bool r_sign_add_item(RAnal *a, RSignItem *it) { static RSignItem *item_new_named(RAnal *a, const char *n) { RSignItem *it = r_sign_item_new (); - if (it && (it->name = strdup (n)) != NULL) { + if (it && (it->name = strdup (n))) { it->space = r_spaces_current (&a->zign_spaces); return it; } diff --git a/libr/asm/arch/6502/6502dis.c b/libr/asm/arch/6502/6502dis.c index e7554a1e62..cc2fc56ed3 100644 --- a/libr/asm/arch/6502/6502dis.c +++ b/libr/asm/arch/6502/6502dis.c @@ -137,7 +137,7 @@ static struct { static int _6502Disass(ut64 pc, RAsmOp *op, const ut8 *buf, ut64 len) { int i; r_strf_buffer (64); - for (i = 0; ops[i].name != NULL; i++) { + for (i = 0; ops[i].name; i++) { if (ops[i].op == buf[0]) { const char *buf_asm = "invalid"; int len = ops[i].len; diff --git a/libr/asm/arch/amd29k/amd29k.c b/libr/asm/arch/amd29k/amd29k.c index 8300bdd6dc..faa82ca50f 100644 --- a/libr/asm/arch/amd29k/amd29k.c +++ b/libr/asm/arch/amd29k/amd29k.c @@ -585,4 +585,4 @@ void amd29k_instr_print(char* string, int string_size, ut64 address, amd29k_inst #undef AMD29K_IS_2 #undef AMD29K_IS_3 #undef AMD29K_IS_4 -#undef AMD29K_IS_5 \ No newline at end of file +#undef AMD29K_IS_5 diff --git a/libr/asm/arch/arc/gnu/arc-ext.c b/libr/asm/arch/arc/gnu/arc-ext.c index bc8bd748e4..f8a08abb79 100644 --- a/libr/asm/arch/arc/gnu/arc-ext.c +++ b/libr/asm/arch/arc/gnu/arc-ext.c @@ -460,7 +460,7 @@ build_ARC_extmap (void *text_bfd) */ destroy_map(); - for (sect = text_bfd->sections; sect != NULL; sect = sect->next) + for (sect = text_bfd->sections; sect; sect = sect->next) if (!strncmp (sect->name, ".gnu.linkonce.arcextmap.", sizeof (".gnu.linkonce.arcextmap.") - 1) @@ -497,7 +497,7 @@ void dump_ARC_extmap (void) { struct ExtInstruction *insn; - for (insn = arc_extension_map.instructions[i]; insn != NULL; insn = insn->next) { + for (insn = arc_extension_map.instructions[i]; insn; insn = insn->next) { printf ("INST: %d %d %x %s\n", insn->major, insn->minor, insn->flags, insn->name); } } diff --git a/libr/asm/arch/arc/gnu/arc-opc.c b/libr/asm/arch/arc/gnu/arc-opc.c index 8930bb6bbb..5c9fe94167 100644 --- a/libr/asm/arch/arc/gnu/arc-opc.c +++ b/libr/asm/arch/arc/gnu/arc-opc.c @@ -1454,7 +1454,7 @@ insert_base (arc_insn insn,long *ex ATTRIBUTE_UNUSED, long value, const char **errmsg) { - if (reg != NULL) + if (reg) { arc_insn myinsn; if (!arc_mach_a4 && ('g' == operand->fmt)) { @@ -1511,7 +1511,7 @@ insert_offset (arc_insn insn,long *ex ATTRIBUTE_UNUSED, { long minval, maxval; - if (reg != NULL) + if (reg) { if (arc_mach_a4) { @@ -2243,7 +2243,7 @@ extract_reg (arc_insn *insn, if (!reg) { return 0; } - if (opval != NULL) { + if (opval) { *opval = reg; } value = regno; @@ -2257,7 +2257,7 @@ extract_reg (arc_insn *insn, /* This is really a constant, but tell the caller it has a special name. */ - if (reg != NULL && opval != NULL) { + if (reg && opval) { *opval = reg; } } @@ -2310,7 +2310,7 @@ extract_flag (arc_insn *insn, } flag_p = 1; val = arc_opcode_lookup_suffix (operand, 1); - if (opval != NULL && val != NULL) { + if (opval && val) { *opval = val; } return val?val->value:0; @@ -2340,7 +2340,7 @@ extract_cond (arc_insn *insn, /* Ignore NULL values of `val'. Several condition code values are reserved for extensions. */ - if (opval != NULL && val != NULL) { + if (opval && val) { *opval = val; } return cond; @@ -2454,7 +2454,7 @@ extract_unopmacro (arc_insn *insn, C == ARC_REG_SHIMM (or vice versa). No big deal. Those insns will get printed as "and"s. */ if (((*insn >> ARC_SHIFT_REGB) & ARC_MASK_REG) != ((*insn >> ARC_SHIFT_REGC) & ARC_MASK_REG)) { - if (invalid != NULL) { + if (invalid) { *invalid = 1; } } diff --git a/libr/asm/arch/arc/gnu/arcompact-dis.c b/libr/asm/arch/arc/gnu/arcompact-dis.c index b89e46f416..a93518c218 100644 --- a/libr/asm/arch/arc/gnu/arcompact-dis.c +++ b/libr/asm/arch/arc/gnu/arcompact-dis.c @@ -3772,7 +3772,7 @@ static void parse_disassembler_options (char *options) { const char *p; - for (p = options; p != NULL; ) + for (p = options; p; ) { if (CONST_STRNEQ (p, "simd")) { @@ -3785,7 +3785,7 @@ parse_disassembler_options (char *options) p = strchr (p, ','); - if (p != NULL) { + if (p) { p++; } } @@ -3894,7 +3894,7 @@ ARCompact_decodeInstr (bfd_vma address, /* Address of this instruct } /* if the operand is actually in the instruction buffer */ - if ((space != NULL) && (operand[0] == '\0')) + if ((space) && (operand[0] == '\0')) { *space = '\0'; operand = space + 1; diff --git a/libr/asm/arch/arm/aarch64/aarch64-dis.c b/libr/asm/arch/arm/aarch64/aarch64-dis.c index df4567c070..7730325144 100644 --- a/libr/asm/arch/arm/aarch64/aarch64-dis.c +++ b/libr/asm/arch/arm/aarch64/aarch64-dis.c @@ -1315,7 +1315,7 @@ aarch64_ext_hint (const aarch64_operand *self ATTRIBUTE_UNUSED, hint_number = extract_fields (code, 0, 2, FLD_CRm, FLD_op2); - for (i = 0; aarch64_hint_options[i].name != NULL; i++) + for (i = 0; aarch64_hint_options[i].name; i++) { if (hint_number == aarch64_hint_options[i].value) { @@ -2964,7 +2964,7 @@ aarch64_decode_insn (aarch64_insn insn, aarch64_inst *inst, const aarch64_opcode *tmp = opcode; printf ("\n"); DEBUG_TRACE ("opcode lookup:"); - while (tmp != NULL) + while (tmp) { aarch64_verbose (" %s", tmp->name); tmp = aarch64_find_next_opcode (tmp); @@ -2977,7 +2977,7 @@ aarch64_decode_insn (aarch64_insn insn, aarch64_inst *inst, opcode field and value, apart from the difference that one of them has an extra field as part of the opcode, but such a field is used for operand encoding in other opcode(s) ('immh' in the case of the example). */ - while (opcode != NULL) + while (opcode) { /* But only one opcode can be decoded successfully for, as the decoding routine will check the constraint carefully. */ @@ -3213,7 +3213,7 @@ get_sym_code_type (struct disassemble_info *info, int n, const char *name; /* If the symbol is in a different section, ignore it. */ - if (info->section != NULL && info->section != info->symtab[n]->section) + if (info->section && info->section != info->symtab[n]->section) return FALSE; es = *(elf_symbol_type **)(info->symtab + n); diff --git a/libr/asm/arch/arm/aarch64/aarch64-opc.c b/libr/asm/arch/arm/aarch64/aarch64-opc.c index 817ce1172b..44917d526a 100644 --- a/libr/asm/arch/arm/aarch64/aarch64-opc.c +++ b/libr/asm/arch/arm/aarch64/aarch64-opc.c @@ -1062,7 +1062,7 @@ aarch64_wide_constant_p (int64_t value, int is32, unsigned int *shift_amount) return FALSE; } - if (shift_amount != NULL) + if (shift_amount) *shift_amount = amount; DEBUG_TRACE ("exit TRUE with amount %d", amount); @@ -1238,7 +1238,7 @@ aarch64_logical_immediate_p (uint64_t value, int esize, aarch64_insn *encoding) DEBUG_TRACE ("exit with FALSE"); return FALSE; } - if (encoding != NULL) + if (encoding) *encoding = imm_encoding->encoding; DEBUG_TRACE ("exit with TRUE"); return TRUE; @@ -3626,7 +3626,7 @@ aarch64_print_operand (char *buf, size_t size, bfd_vma pc, break; case AARCH64_OPND_PRFOP: - if (opnd->prfop->name != NULL) + if (opnd->prfop->name) snprintf (buf, size, "%s", opnd->prfop->name); else snprintf (buf, size, "0x%02x", opnd->prfop->value); diff --git a/libr/asm/arch/arm/armass.c b/libr/asm/arch/arm/armass.c index 6f535cfc1c..7f27473bdf 100644 --- a/libr/asm/arch/arm/armass.c +++ b/libr/asm/arch/arm/armass.c @@ -977,7 +977,7 @@ void collect_list(ArmOpcode *ao) { int conc = 0; int start = 0, end = 0; int arrsz; - for (arrsz = 1; input[arrsz] != NULL; arrsz++) { + for (arrsz = 1; input[arrsz]; arrsz++) { ; } diff --git a/libr/asm/arch/arm/armass64.c b/libr/asm/arch/arm/armass64.c index 821ee3df5f..90a58f7730 100644 --- a/libr/asm/arch/arm/armass64.c +++ b/libr/asm/arch/arm/armass64.c @@ -1272,7 +1272,7 @@ static bool parseOpcode(const char *str, ArmOp *op) { space[0] = '\0'; op->mnemonic = in; space ++; - op->writeback = strstr (space, "]!") != NULL; + op->writeback = strstr (space, "]!"); return parseOperands (space, op); } diff --git a/libr/asm/arch/arm/gnu/arm-dis.c b/libr/asm/arch/arm/gnu/arm-dis.c index 35f235c5df..1e01742bb2 100644 --- a/libr/asm/arch/arm/gnu/arm-dis.c +++ b/libr/asm/arch/arm/gnu/arm-dis.c @@ -5014,7 +5014,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info, long given) sysm |= (given & 0x300) >> 4; name = banked_regname (sysm); - if (name != NULL) { + if (name) { func (stream, "%s", name); } else { func (stream, "(UNDEF: %lu)", (unsigned long)sysm); @@ -5047,7 +5047,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info, long given) } } else { const char *opt = data_barrier_option (given & 0xf); - if (opt != NULL) { + if (opt) { func (stream, "%s", opt); } else { func (stream, "%d", (int)given & 0xf); @@ -5184,7 +5184,7 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info, long given) sysm |= (given & 0x300) >> 4; name = banked_regname (sysm); - if (name != NULL) { + if (name) { func (stream, "%s", name); } else { func (stream, "(UNDEF: %lu)", (unsigned long)sysm); @@ -5921,7 +5921,7 @@ print_insn_thumb32 (bfd_vma pc, struct disassemble_info *info, long given) } } else { const char *opt = data_barrier_option (given & 0xf); - if (opt != NULL) { + if (opt) { func (stream, "%s", opt); } else { func (stream, "%d", (int)given & 0xf); @@ -5952,7 +5952,7 @@ print_insn_thumb32 (bfd_vma pc, struct disassemble_info *info, long given) sysm |= (given & 0x00100000) >> 14; name = banked_regname (sysm); - if (name != NULL) { + if (name) { func (stream, "%s", name); } else { func (stream, "(UNDEF: %lu)", (unsigned long)sysm); @@ -5971,7 +5971,7 @@ print_insn_thumb32 (bfd_vma pc, struct disassemble_info *info, long given) sm |= (given & 0x00100000) >> 14; name = banked_regname (sm); - if (name != NULL) { + if (name) { func (stream, "%s", name); } else { func (stream, "(UNDEF: %lu)", (unsigned long)sm); @@ -6319,7 +6319,7 @@ get_map_sym_type (struct disassemble_info *info, enum map_type *map_type) { /* If the symbol is in a different section, ignore it. */ - if (info->section != NULL && info->section != info->symtab[n]->section) { + if (info->section && info->section != info->symtab[n]->section) { return FALSE; } @@ -6340,7 +6340,7 @@ return FALSE; unsigned int type; /* If the symbol is in a different section, ignore it. */ - if (info->section != NULL && info->section != info->symtab[n]->section) + if (info->section && info->section != info->symtab[n]->section) return FALSE; es = *(elf_symbol_type **)(info->symtab + n); @@ -6853,7 +6853,7 @@ print_insn_big_arm (bfd_vma pc, struct disassemble_info *info) /* Detect BE8-ness and record it in the disassembler info. */ #if 0 if (info->flavour == bfd_target_elf_flavour - && info->section != NULL + && info->section && (elf_elfheader (info->section->owner)->e_flags & EF_ARM_BE8)) info->endian_code = BFD_ENDIAN_LITTLE; #endif @@ -6881,7 +6881,7 @@ disassembler_options_arm (void) for (i = 0; i < NUM_ARM_OPTIONS; i++) { opts->name[i] = regnames[i].name; - if (regnames[i].description != NULL) { + if (regnames[i].description) { opts->description[i] = _ (regnames[i].description); } else { opts->description[i] = NULL; diff --git a/libr/asm/arch/avr/assemble.c b/libr/asm/arch/avr/assemble.c index 345e819f4a..be9c2a3aaa 100644 --- a/libr/asm/arch/avr/assemble.c +++ b/libr/asm/arch/avr/assemble.c @@ -48,7 +48,7 @@ int avr_encode(RAsm *a, RAsmOp *ao, const char *str) { // simple tokenizer -- creates an array of maximum three tokens // the delimiters are ' ' and ',' token = strtok ((char *)str, TOKEN_DELIM); - while (token != NULL && tokens_cnt < 3) { + while (token && tokens_cnt < 3) { memset (tokens[tokens_cnt], 0, MAX_TOKEN_SIZE); strncpy (tokens[tokens_cnt], token, MAX_TOKEN_SIZE-1); token = strtok (NULL, TOKEN_DELIM); diff --git a/libr/asm/arch/avr/format.c b/libr/asm/arch/avr/format.c index ee3d131556..e142e54b84 100644 --- a/libr/asm/arch/avr/format.c +++ b/libr/asm/arch/avr/format.c @@ -169,7 +169,7 @@ static int formatDisassembledOperand(RAsm *a, avrDisassembleContext *context, ch #if 0 /* If we have an address label, print it, otherwise just print the * relative distance to the destination address. */ - if ((fOptions.options & FORMAT_OPTION_ADDRESS_LABEL) && fOptions.addressLabelPrefix != NULL) { + if ((fOptions.options & FORMAT_OPTION_ADDRESS_LABEL) && fOptions.addressLabelPrefix) { retVal = sprintf(strOperand, "%s%0*X", fOptions.addressLabelPrefix, fOptions.addressFieldWidth, @@ -512,7 +512,7 @@ static int analFormatDisassembledOperand(RAnal *a, avrDisassembleContext *contex #if 0 /* If we have an address label, print it, otherwise just print the * relative distance to the destination address. */ - if ((fOptions.options & FORMAT_OPTION_ADDRESS_LABEL) && fOptions.addressLabelPrefix != NULL) { + if ((fOptions.options & FORMAT_OPTION_ADDRESS_LABEL) && fOptions.addressLabelPrefix) { retVal = sprintf(strOperand, "%s%0*X", fOptions.addressLabelPrefix, fOptions.addressFieldWidth, diff --git a/libr/asm/arch/cris/gnu/cris-dis.c b/libr/asm/arch/cris/gnu/cris-dis.c index 42ba9088b6..32de6662bb 100644 --- a/libr/asm/arch/cris/gnu/cris-dis.c +++ b/libr/asm/arch/cris/gnu/cris-dis.c @@ -127,7 +127,7 @@ spec_reg_info (unsigned int sreg, enum cris_disass_family distype) { int i; - for (i = 0; cris_spec_regs[i].name != NULL; i++) + for (i = 0; cris_spec_regs[i].name; i++) { if (cris_spec_regs[i].number == sreg) { @@ -237,7 +237,7 @@ get_opcode_entry (unsigned int insn, if (prefix_insn != NO_CRIS_PREFIX) { const struct cris_opcode *popcodep - = (opc_table[prefix_insn] != NULL + = (opc_table[prefix_insn] ? opc_table[prefix_insn] : get_opcode_entry (prefix_insn, NO_CRIS_PREFIX, disdata)); @@ -282,16 +282,16 @@ get_opcode_entry (unsigned int insn, } } - if (prefix_insn != NO_CRIS_PREFIX && prefix_opc_table[insn] != NULL) { + if (prefix_insn != NO_CRIS_PREFIX && prefix_opc_table[insn]) { max_matchedp = prefix_opc_table[insn]; - } else if (prefix_insn == NO_CRIS_PREFIX && opc_table[insn] != NULL) { + } else if (prefix_insn == NO_CRIS_PREFIX && opc_table[insn]) { max_matchedp = opc_table[insn]; } else { const struct cris_opcode *opcodep; int max_level_of_match = -1; for (opcodep = cris_opcodes; - opcodep->name != NULL; + opcodep->name; opcodep++) { int level_of_match; @@ -512,7 +512,7 @@ cris_constraint (const char *cs, for a move from a special register is matched in the register constraint. */ - if (sregp != NULL) { + if (sregp) { retval += 3; break; } else { @@ -613,7 +613,7 @@ format_sup_reg (unsigned int regno, *outbuffer++ = REGISTER_PREFIX_CHAR; } - for (i = 0; cris_support_regs[i].name != NULL; i++) { + for (i = 0; cris_support_regs[i].name; i++) { if (cris_support_regs[i].number == regno) { sprintf (outbuffer, "%s", cris_support_regs[i].name); return outbuffer_start + strlen (outbuffer_start); @@ -1480,7 +1480,7 @@ print_insn_cris_generic (bfd_vma memaddr, /* Check if we're supposed to write out prefixes as address modes and if this was a prefix. */ - if (matchedp != NULL && PARSE_PREFIX && matchedp->args[0] == 'p') { + if (matchedp && PARSE_PREFIX && matchedp->args[0] == 'p') { /* If it's a prefix, put it into the prefix vars and get the main insn. */ prefix_size = bytes_to_skip (prefix_insn, matchedp, @@ -1490,7 +1490,7 @@ print_insn_cris_generic (bfd_vma memaddr, insn = bufp[prefix_size] + bufp[prefix_size + 1] * 256; matchedp = get_opcode_entry (insn, prefix_insn, disdata); - if (matchedp != NULL) { + if (matchedp) { addr += prefix_size; bufp += prefix_size; advance += prefix_size; diff --git a/libr/asm/arch/mips/gnu/mips-dis.c b/libr/asm/arch/mips/gnu/mips-dis.c index 1154be2416..becd6676ac 100644 --- a/libr/asm/arch/mips/gnu/mips-dis.c +++ b/libr/asm/arch/mips/gnu/mips-dis.c @@ -760,7 +760,7 @@ choose_arch_by_number (unsigned long mach) /* We optimize this because even if the user specifies no flags, this will be done for every instruction! */ if (hint_bfd_mach == mach - && hint_arch_choice != NULL + && hint_arch_choice && hint_arch_choice->bfd_mach == hint_bfd_mach) return hint_arch_choice; @@ -890,7 +890,7 @@ set_default_mips_dis_options (struct disassemble_info *info) mips_ase = mips_target_info.ase; #else chosen_arch = choose_arch_by_number (info->mach); - if (chosen_arch != NULL) + if (chosen_arch) { mips_processor = chosen_arch->processor; mips_isa = chosen_arch->isa; @@ -903,7 +903,7 @@ set_default_mips_dis_options (struct disassemble_info *info) } /* Update settings according to the ELF file header flags. */ - if (info->flavour == bfd_target_elf_flavour && info->section != NULL) + if (info->flavour == bfd_target_elf_flavour && info->section) { struct bfd *abfd = info->section->owner; Elf_Internal_Ehdr *header = elf_elfheader (abfd); @@ -1051,7 +1051,7 @@ parse_mips_dis_option (const char *option, unsigned int len) && strlen ("gpr-names") == optionlen) { chosen_abi = choose_abi_by_name (val, vallen); - if (chosen_abi != NULL) + if (chosen_abi) mips_gpr_names = chosen_abi->gpr_names; return; } @@ -1060,7 +1060,7 @@ parse_mips_dis_option (const char *option, unsigned int len) && strlen ("fpr-names") == optionlen) { chosen_abi = choose_abi_by_name (val, vallen); - if (chosen_abi != NULL) + if (chosen_abi) mips_fpr_names = chosen_abi->fpr_names; return; } @@ -1069,7 +1069,7 @@ parse_mips_dis_option (const char *option, unsigned int len) && strlen ("cp0-names") == optionlen) { chosen_arch = choose_arch_by_name (val, vallen); - if (chosen_arch != NULL) + if (chosen_arch) { mips_cp0_names = chosen_arch->cp0_names; mips_cp0sel_names = chosen_arch->cp0sel_names; @@ -1082,7 +1082,7 @@ parse_mips_dis_option (const char *option, unsigned int len) && strlen ("cp1-names") == optionlen) { chosen_arch = choose_arch_by_name (val, vallen); - if (chosen_arch != NULL) + if (chosen_arch) mips_cp1_names = chosen_arch->cp1_names; return; } @@ -1091,7 +1091,7 @@ parse_mips_dis_option (const char *option, unsigned int len) && strlen ("hwr-names") == optionlen) { chosen_arch = choose_arch_by_name (val, vallen); - if (chosen_arch != NULL) + if (chosen_arch) mips_hwr_names = chosen_arch->hwr_names; return; } @@ -1104,13 +1104,13 @@ parse_mips_dis_option (const char *option, unsigned int len) numeric register names for all registers. Other than that, a given name probably won't match both. */ chosen_abi = choose_abi_by_name (val, vallen); - if (chosen_abi != NULL) + if (chosen_abi) { mips_gpr_names = chosen_abi->gpr_names; mips_fpr_names = chosen_abi->fpr_names; } chosen_arch = choose_arch_by_name (val, vallen); - if (chosen_arch != NULL) + if (chosen_arch) { mips_cp0_names = chosen_arch->cp0_names; mips_cp0sel_names = chosen_arch->cp0sel_names; @@ -1871,7 +1871,7 @@ print_insn_args (struct disassemble_info *info, n = lookup_mips_cp0sel_name (mips_cp0sel_names, mips_cp0sel_names_len, reg, sel); - if (n != NULL) + if (n) infprintf (is, "%s", n->name); else infprintf (is, "$%d,%d", reg, sel); @@ -1955,7 +1955,7 @@ print_insn_mips (bfd_vma memaddr, info->target2 = 0; op = mips_hash[GET_OP (word, OP)]; - if (op != NULL) + if (op) { for (; op < &mips_opcodes[NUMOPCODES]; op++) { @@ -2364,7 +2364,7 @@ print_insn_mips16 (bfd_vma memaddr, struct disassemble_info *info) n = lookup_mips_cp0sel_name (mips_cp0sel_names, mips_cp0sel_names_len, reg, sel); - if (n != NULL) + if (n) infprintf (is, "%s", n->name); else infprintf (is, "$%d,%d", reg, sel); diff --git a/libr/asm/arch/nios/gnu/nios2-dis.c b/libr/asm/arch/nios/gnu/nios2-dis.c index af1112aa96..2a51265c19 100644 --- a/libr/asm/arch/nios/gnu/nios2-dis.c +++ b/libr/asm/arch/nios/gnu/nios2-dis.c @@ -98,7 +98,7 @@ nios2_init_opcode_hash (void) { nios2_opcode_hash *tmp_hash = nios2_hash[i]; printf ("index: 0x%02X ops: ", i); - while (tmp_hash != NULL) + while (tmp_hash) { printf ("%s ", tmp_hash->opcode->name); tmp_hash = tmp_hash->next; @@ -110,7 +110,7 @@ nios2_init_opcode_hash (void) { nios2_opcode_hash *tmp_hash = nios2_ps_hash[i]; printf ("index: 0x%02X ops: ", i); - while (tmp_hash != NULL) + while (tmp_hash) { printf ("%s ", tmp_hash->opcode->name); tmp_hash = tmp_hash->next; @@ -337,7 +337,7 @@ nios2_disassemble (bfd_vma address, unsigned long opcode, the instruction and its arguments. */ op = nios2_find_opcode_hash (opcode); - if (op != NULL) + if (op) { bfd_boolean is_nop = FALSE; if (op->pinfo == NIOS2_INSN_MACRO_MOV) @@ -360,7 +360,7 @@ nios2_disassemble (bfd_vma address, unsigned long opcode, if (!is_nop) { const char *argstr = op->args; - if (argstr != NULL && *argstr != '\0') + if (argstr && *argstr != '\0') { (*info->fprintf_func) (info->stream, " "); while (*argstr != '\0') diff --git a/libr/asm/arch/ppc/gnu/ppc-dis.c b/libr/asm/arch/ppc/gnu/ppc-dis.c index 1b0c3a90dd..afa70ebce5 100644 --- a/libr/asm/arch/ppc/gnu/ppc-dis.c +++ b/libr/asm/arch/ppc/gnu/ppc-dis.c @@ -84,57 +84,57 @@ powerpc_init_dialect (struct disassemble_info *info) dialect |= PPC_OPCODE_64; } - if (info->disassembler_options && strstr (info->disassembler_options, "ppcps") != NULL) { + if (info->disassembler_options && strstr (info->disassembler_options, "ppcps")) { dialect |= PPC_OPCODE_PPCPS; - } else if (info->disassembler_options && strstr (info->disassembler_options, "booke") != NULL) { + } else if (info->disassembler_options && strstr (info->disassembler_options, "booke")) { dialect |= PPC_OPCODE_BOOKE | PPC_OPCODE_BOOKE64; - } else if ((info->mach == bfd_mach_ppc_e500mc) || (info->disassembler_options && strstr (info->disassembler_options, "e500mc") != NULL)) { + } else if ((info->mach == bfd_mach_ppc_e500mc) || (info->disassembler_options && strstr (info->disassembler_options, "e500mc"))) { dialect |= (PPC_OPCODE_BOOKE | PPC_OPCODE_ISEL | PPC_OPCODE_PMR | PPC_OPCODE_CACHELCK | PPC_OPCODE_RFMCI | PPC_OPCODE_E500MC); - } else if ((info->mach == bfd_mach_ppc_e500) || (info->disassembler_options && strstr (info->disassembler_options, "e500") != NULL)) { + } else if ((info->mach == bfd_mach_ppc_e500) || (info->disassembler_options && strstr (info->disassembler_options, "e500"))) { dialect |= (PPC_OPCODE_BOOKE | PPC_OPCODE_SPE | PPC_OPCODE_ISEL | PPC_OPCODE_EFS | PPC_OPCODE_BRLOCK | PPC_OPCODE_PMR | PPC_OPCODE_CACHELCK | PPC_OPCODE_RFMCI | PPC_OPCODE_E500MC); - } else if (info->disassembler_options && strstr (info->disassembler_options, "efs") != NULL) { + } else if (info->disassembler_options && strstr (info->disassembler_options, "efs")) { dialect |= PPC_OPCODE_EFS; - } else if (info->disassembler_options && strstr (info->disassembler_options, "e300") != NULL) { + } else if (info->disassembler_options && strstr (info->disassembler_options, "e300")) { dialect |= PPC_OPCODE_E300 | PPC_OPCODE_CLASSIC | PPC_OPCODE_COMMON; - } else if (info->disassembler_options && (strstr (info->disassembler_options, "440") != NULL || strstr (info->disassembler_options, "464") != NULL)) { + } else if (info->disassembler_options && (strstr (info->disassembler_options, "440") || strstr (info->disassembler_options, "464"))) { dialect |= PPC_OPCODE_BOOKE | PPC_OPCODE_32 | PPC_OPCODE_440 | PPC_OPCODE_ISEL | PPC_OPCODE_RFMCI; } else { dialect |= (PPC_OPCODE_403 | PPC_OPCODE_601 | PPC_OPCODE_CLASSIC | PPC_OPCODE_COMMON | PPC_OPCODE_ALTIVEC); } - if (info->disassembler_options && strstr (info->disassembler_options, "power4") != NULL) { + if (info->disassembler_options && strstr (info->disassembler_options, "power4")) { dialect |= PPC_OPCODE_POWER4; } - if (info->disassembler_options && strstr (info->disassembler_options, "power5") != NULL) { + if (info->disassembler_options && strstr (info->disassembler_options, "power5")) { dialect |= PPC_OPCODE_POWER4 | PPC_OPCODE_POWER5; } - if (info->disassembler_options && strstr (info->disassembler_options, "cell") != NULL) { + if (info->disassembler_options && strstr (info->disassembler_options, "cell")) { dialect |= PPC_OPCODE_POWER4 | PPC_OPCODE_CELL | PPC_OPCODE_ALTIVEC; } - if (info->disassembler_options && strstr (info->disassembler_options, "power6") != NULL) { + if (info->disassembler_options && strstr (info->disassembler_options, "power6")) { dialect |= PPC_OPCODE_POWER4 | PPC_OPCODE_POWER5 | PPC_OPCODE_POWER6 | PPC_OPCODE_ALTIVEC; } - if (info->disassembler_options && strstr (info->disassembler_options, "power7") != NULL) { + if (info->disassembler_options && strstr (info->disassembler_options, "power7")) { dialect |= PPC_OPCODE_POWER4 | PPC_OPCODE_POWER5 | PPC_OPCODE_POWER6 | PPC_OPCODE_ALTIVEC | PPC_OPCODE_VSX; } - if (info->disassembler_options && strstr (info->disassembler_options, "vsx") != NULL) { + if (info->disassembler_options && strstr (info->disassembler_options, "vsx")) { dialect |= PPC_OPCODE_VSX; } - if (info->disassembler_options && strstr (info->disassembler_options, "any") != NULL) { + if (info->disassembler_options && strstr (info->disassembler_options, "any")) { dialect |= PPC_OPCODE_ANY; } if (info->disassembler_options) { - if (strstr (info->disassembler_options, "32") != NULL) { + if (strstr (info->disassembler_options, "32")) { dialect &= ~PPC_OPCODE_64; - } else if (strstr (info->disassembler_options, "64") != NULL) { + } else if (strstr (info->disassembler_options, "64")) { dialect |= PPC_OPCODE_64; } } diff --git a/libr/asm/arch/s390/gnu/s390-dis.c b/libr/asm/arch/s390/gnu/s390-dis.c index 6acca0f1c1..cf2f49128d 100644 --- a/libr/asm/arch/s390/gnu/s390-dis.c +++ b/libr/asm/arch/s390/gnu/s390-dis.c @@ -64,7 +64,7 @@ disassemble_init_s390 (struct disassemble_info *info) current_arch_mask = 1 << S390_OPCODE_ZARCH; option_use_insn_len_bits_p = 0; - for (p = info->disassembler_options; p != NULL; ) + for (p = info->disassembler_options; p; ) { if (CONST_STRNEQ (p, "esa")) current_arch_mask = 1 << S390_OPCODE_ESA; @@ -78,7 +78,7 @@ disassemble_init_s390 (struct disassemble_info *info) } p = strchr (p, ','); - if (p != NULL) + if (p) p++; } } @@ -328,7 +328,7 @@ print_insn_s390 (bfd_vma memaddr, struct disassemble_info *info) opcode = op; } - if (opcode != NULL) + if (opcode) { /* The instruction is valid. Print it and return its size. */ s390_print_insn_with_opcode (memaddr, info, buffer, opcode); @@ -340,7 +340,7 @@ print_insn_s390 (bfd_vma memaddr, struct disassemble_info *info) according to their length bits. */ if (status == 0 && option_use_insn_len_bits_p - && info->section != NULL + && info->section && (info->section->flags & SEC_CODE)) bytes_to_dump = opsize; else diff --git a/libr/asm/arch/sparc/gnu/sparc-dis.c b/libr/asm/arch/sparc/gnu/sparc-dis.c index 8dd2baaa4c..54d40c3aa4 100644 --- a/libr/asm/arch/sparc/gnu/sparc-dis.c +++ b/libr/asm/arch/sparc/gnu/sparc-dis.c @@ -430,7 +430,7 @@ build_hash_table (const sparc_opcode **opcode_table, memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0])); memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0])); - if (hash_buf != NULL) { + if (hash_buf) { free (hash_buf); } hash_buf = calloc (sizeof (* hash_buf), num_opcodes); diff --git a/libr/asm/arch/tms320/c55x_plus/c55plus_decode.c b/libr/asm/arch/tms320/c55x_plus/c55plus_decode.c index 779d037754..633976e904 100644 --- a/libr/asm/arch/tms320/c55x_plus/c55plus_decode.c +++ b/libr/asm/arch/tms320/c55x_plus/c55plus_decode.c @@ -377,7 +377,7 @@ static char *do_decode(ut32 ins_off, ut32 ins_pos, ut32 two_ins, ut32 *next_ins_ hash_aux = 0x223; } - if (ins_hash_code != NULL) { + if (ins_hash_code) { *ins_hash_code = hash_code; } diff --git a/libr/asm/arch/tms320/c55x_plus/decode_funcs.c b/libr/asm/arch/tms320/c55x_plus/decode_funcs.c index 7235c63cc9..79d158938b 100644 --- a/libr/asm/arch/tms320/c55x_plus/decode_funcs.c +++ b/libr/asm/arch/tms320/c55x_plus/decode_funcs.c @@ -258,7 +258,7 @@ char *get_reg_pair(ut32 idx) { default: res = NULL; } - if (res != NULL) { + if (res) { res = strdup (res); } @@ -323,7 +323,7 @@ char *get_reg_name_3(ut32 idx) { default: res = NULL; } - if (res != NULL) { + if (res) { res = strdup (res); } return res; @@ -379,7 +379,7 @@ char *get_reg_name_2(ut32 idx) { default: res = NULL; } - if (res != NULL) { + if (res) { res = strdup (res); } @@ -634,7 +634,7 @@ char *get_reg_name_1(ut32 idx) { default: res = NULL; } - if (res != NULL) { + if (res) { res = strdup (res); } @@ -850,7 +850,7 @@ char *get_status_regs_and_bits(char *reg_arg, int reg_bit) { } } - if (res != NULL) { + if (res) { res = strdup (res); } diff --git a/libr/asm/arch/tricore/gnu/tricore-dis.c b/libr/asm/arch/tricore/gnu/tricore-dis.c index 702f82ac02..8dee903453 100644 --- a/libr/asm/arch/tricore/gnu/tricore-dis.c +++ b/libr/asm/arch/tricore/gnu/tricore-dis.c @@ -1143,7 +1143,7 @@ find_core_reg (addr) struct sfrlist *psfr; int idx = addr & 0xff; - for (psfr = sfrs[idx]; psfr != NULL; psfr = psfr->next) { + for (psfr = sfrs[idx]; psfr; psfr = psfr->next) { if ((psfr->sfr->addr == addr) && MATCHES_ISA (psfr->sfr->isa)) { return psfr->sfr->name; } @@ -1556,7 +1556,7 @@ decode_tricore_insn (memaddr, insn, len32, info) tricore_fmt fmt; /* Try to find the instruction matching the given opcode. */ - for (pinsn = insns[idx]; pinsn != NULL; pinsn = pinsn->next) + for (pinsn = insns[idx]; pinsn; pinsn = pinsn->next) { if ((pinsn->code->len32 != len32) || (insn & pinsn->code->lose)) { continue; @@ -1613,7 +1613,7 @@ decode_pcp_insn (memaddr, buffer, info) /* Try to find the PCP instruction matching the given opcode. */ insn = bfd_getl16 (buffer); idx = (insn >> 11) & 0x1f; - for (pinsn = pcpinsns[idx]; pinsn != NULL; pinsn = pinsn->next) + for (pinsn = pcpinsns[idx]; pinsn; pinsn = pinsn->next) { if (((insn & pinsn->code->opcode) != pinsn->code->opcode) || (insn & pinsn->code->lose)) { continue; diff --git a/libr/asm/arch/vax/vax-dis.c b/libr/asm/arch/vax/vax-dis.c index 2dec8f2ef4..e194096044 100644 --- a/libr/asm/arch/vax/vax-dis.c +++ b/libr/asm/arch/vax/vax-dis.c @@ -404,7 +404,7 @@ print_insn_vax (bfd_vma memaddr, disassemble_info *info) priv.insn_start = memaddr; if (! parsed_disassembler_options - && info->disassembler_options != NULL) + && info->disassembler_options) { parse_disassembler_options (info->disassembler_options); diff --git a/libr/asm/arch/xtensa/gnu/elf32-xtensa.c b/libr/asm/arch/xtensa/gnu/elf32-xtensa.c index 9883171d93..e832f2e733 100644 --- a/libr/asm/arch/xtensa/gnu/elf32-xtensa.c +++ b/libr/asm/arch/xtensa/gnu/elf32-xtensa.c @@ -506,7 +506,7 @@ elf_xtensa_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, unsigned int i; for (i = 0; i < sizeof (elf_howto_table) / sizeof (elf_howto_table[0]); i++) - if (elf_howto_table[i].name != NULL + if (elf_howto_table[i].name && r_str_casecmp (elf_howto_table[i].name, r_name) == 0) return &elf_howto_table[i]; @@ -623,7 +623,7 @@ struct elf_xtensa_obj_tdata #define is_xtensa_elf(bfd) \ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \ - && elf_tdata (bfd) != NULL \ + && elf_tdata (bfd) \ && elf_object_id (bfd) == XTENSA_ELF_DATA) static bfd_boolean @@ -684,7 +684,7 @@ elf_xtensa_link_hash_newfunc (struct bfd_hash_entry *entry, /* Call the allocation method of the superclass. */ entry = _bfd_elf_link_hash_newfunc (entry, table, string); - if (entry != NULL) + if (entry) { struct elf_xtensa_link_hash_entry *eh = elf_xtensa_hash_entry (entry); eh->tlsfunc_refcount = 0; @@ -1124,8 +1124,8 @@ elf_xtensa_check_relocs (bfd *abfd, case R_XTENSA_GNU_VTENTRY: /* This relocation describes which C++ vtable entries are actually used. Record for later use during GC. */ - BFD_ASSERT (h != NULL); - if (h != NULL + BFD_ASSERT (h); + if (h && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) return FALSE; continue; @@ -1302,7 +1302,7 @@ elf_xtensa_gc_mark_hook (asection *sec, if (xtensa_is_property_section (sec)) return NULL; - if (h != NULL) + if (h) switch (ELF32_R_TYPE (rel->r_info)) { case R_XTENSA_GNU_VTINHERIT: @@ -1675,11 +1675,11 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, if (elf_hash_table (info)->dynamic_sections_created) { - BFD_ASSERT (htab->srelgot != NULL - && htab->srelplt != NULL - && htab->sgot != NULL - && htab->spltlittbl != NULL - && htab->sgotloc != NULL); + BFD_ASSERT (htab->srelgot + && htab->srelplt + && htab->sgot + && htab->spltlittbl + && htab->sgotloc); /* Set the contents of the .interp section to the interpreter. */ if (info->executable) @@ -1721,13 +1721,13 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, created earlier because the initial count of PLT relocations was an overestimate. */ for (chunk = 0; - (splt = elf_xtensa_get_plt_section (info, chunk)) != NULL; + (splt = elf_xtensa_get_plt_section (info, chunk)); chunk++) { int chunk_entries; sgotplt = elf_xtensa_get_gotplt_section (info, chunk); - BFD_ASSERT (sgotplt != NULL); + BFD_ASSERT (sgotplt); if (chunk < plt_chunks - 1) chunk_entries = PLT_ENTRIES_PER_CHUNK; @@ -1754,11 +1754,11 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, literal tables. */ sgotloc = htab->sgotloc; sgotloc->size = spltlittbl->size; - for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next) + for (abfd = info->input_bfds; abfd; abfd = abfd->link.next) { if (abfd->flags & DYNAMIC) continue; - for (s = abfd->sections; s != NULL; s = s->next) + for (s = abfd->sections; s; s = s->next) { if (! discarded_section (s) && xtensa_is_littable_section (s) @@ -1771,7 +1771,7 @@ elf_xtensa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, /* Allocate memory for dynamic sections. */ relplt = FALSE; relgot = FALSE; - for (s = dynobj->sections; s != NULL; s = s->next) + for (s = dynobj->sections; s; s = s->next) { const char *name; @@ -2227,7 +2227,7 @@ vsprint_msg (const char *origmsg, const char *fmt, int arglen, ...) message = (char *) bfd_realloc_or_free (message, len); alloc_size = len; } - if (message != NULL) + if (message) { if (!is_append) memcpy (message, origmsg, orig_len); @@ -2368,7 +2368,7 @@ elf_xtensa_create_plt_entry (struct bfd_link_info *info, chunk = reloc_index / PLT_ENTRIES_PER_CHUNK; splt = elf_xtensa_get_plt_section (info, chunk); sgotplt = elf_xtensa_get_gotplt_section (info, chunk); - BFD_ASSERT (splt != NULL && sgotplt != NULL); + BFD_ASSERT (splt && sgotplt); plt_base = splt->output_section->vma + splt->output_offset; got_base = sgotplt->output_section->vma + sgotplt->output_offset; @@ -2706,7 +2706,7 @@ elf_xtensa_relocate_section (bfd *output_bfd, sym_type = h->type; } - if (sec != NULL && discarded_section (sec)) + if (sec && discarded_section (sec)) RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, rel, 1, relend, howto, 0, contents); @@ -2830,7 +2830,7 @@ elf_xtensa_relocate_section (bfd *output_bfd, return FALSE; } - if (h != NULL) + if (h) name = h->root.root.string; else { @@ -2883,7 +2883,7 @@ elf_xtensa_relocate_section (bfd *output_bfd, else srel = htab->srelgot; - BFD_ASSERT (srel != NULL); + BFD_ASSERT (srel); outrel.r_offset = _bfd_elf_section_offset (output_bfd, info, @@ -3135,7 +3135,7 @@ elf_xtensa_relocate_section (bfd *output_bfd, if (r != bfd_reloc_ok && !warned) { BFD_ASSERT (r == bfd_reloc_dangerous || r == bfd_reloc_other); - BFD_ASSERT (error_message != NULL); + BFD_ASSERT (error_message); if (rel->r_addend == 0) error_message = vsprint_msg (error_message, ": %s", @@ -3327,7 +3327,7 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd, dynobj = elf_hash_table (info)->dynobj; sdyn = bfd_get_linker_section (dynobj, ".dynamic"); - BFD_ASSERT (sdyn != NULL); + BFD_ASSERT (sdyn); /* Set the first entry in the global offset table to the address of the dynamic section. */ @@ -3354,7 +3354,7 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd, srelgot = htab->srelgot; spltlittbl = htab->spltlittbl; - BFD_ASSERT (srelgot != NULL && spltlittbl != NULL); + BFD_ASSERT (srelgot && spltlittbl); /* Find the first XTENSA_RTLD relocation. Presumably the rest of them follow immediately after.... */ @@ -3376,7 +3376,7 @@ elf_xtensa_finish_dynamic_sections (bfd *output_bfd, int chunk_entries = 0; sgotplt = elf_xtensa_get_gotplt_section (info, chunk); - BFD_ASSERT (sgotplt != NULL); + BFD_ASSERT (sgotplt); /* Emit special RTLD relocations for the first two entries in each chunk of the .got.plt section. */ @@ -3799,7 +3799,7 @@ elf_xtensa_discard_info (bfd *abfd, asection *sec; bfd_boolean changed = FALSE; - for (sec = abfd->sections; sec != NULL; sec = sec->next) + for (sec = abfd->sections; sec; sec = sec->next) { if (xtensa_is_property_section (sec)) { @@ -5699,7 +5699,7 @@ removed_by_actions (text_action_list *action_list, { splay_tree_node node = splay_tree_lookup (action_list->tree, (splay_tree_key)r); - BFD_ASSERT (node != NULL && r == (text_action *)node->value); + BFD_ASSERT (node && r == (text_action *)node->value); } while (r) @@ -6072,7 +6072,7 @@ print_removed_literals (FILE *fp, removed_literal_list *removed_list) r = removed_list->head; if (r) fprintf (fp, "Removed Literals\n"); - for (; r != NULL; r = r->next) + for (; r; r = r->next) { print_r_reloc (fp, &r->from); fprintf (fp, " => "); @@ -6268,7 +6268,7 @@ cache_fix_array (asection *sec) if (relax_info->fix_list == NULL) return; - for (r = relax_info->fix_list; r != NULL; r = r->next) + for (r = relax_info->fix_list; r; r = r->next) count++; relax_info->fix_array = @@ -6966,7 +6966,7 @@ elf_xtensa_relax_section (bfd *abfd, return TRUE; relax_info = get_xtensa_relax_info (sec); - BFD_ASSERT (relax_info != NULL); + BFD_ASSERT (relax_info); switch (relax_info->visited) { @@ -7021,15 +7021,15 @@ analyze_relocations (struct bfd_link_info *link_info) bfd_boolean is_relaxable = FALSE; /* Initialize the per-section relaxation info. */ - for (abfd = link_info->input_bfds; abfd != NULL; abfd = abfd->link.next) - for (sec = abfd->sections; sec != NULL; sec = sec->next) + for (abfd = link_info->input_bfds; abfd; abfd = abfd->link.next) + for (sec = abfd->sections; sec; sec = sec->next) { init_xtensa_relax_info (sec); } /* Mark relaxable sections (and count relocations against each one). */ - for (abfd = link_info->input_bfds; abfd != NULL; abfd = abfd->link.next) - for (sec = abfd->sections; sec != NULL; sec = sec->next) + for (abfd = link_info->input_bfds; abfd; abfd = abfd->link.next) + for (sec = abfd->sections; sec; sec = sec->next) { if (!find_relaxable_sections (abfd, sec, link_info, &is_relaxable)) return FALSE; @@ -7040,8 +7040,8 @@ analyze_relocations (struct bfd_link_info *link_info) return TRUE; /* Allocate space for source_relocs. */ - for (abfd = link_info->input_bfds; abfd != NULL; abfd = abfd->link.next) - for (sec = abfd->sections; sec != NULL; sec = sec->next) + for (abfd = link_info->input_bfds; abfd; abfd = abfd->link.next) + for (sec = abfd->sections; sec; sec = sec->next) { xtensa_relax_info *relax_info; @@ -7057,16 +7057,16 @@ analyze_relocations (struct bfd_link_info *link_info) } /* Collect info on relocations against each relaxable section. */ - for (abfd = link_info->input_bfds; abfd != NULL; abfd = abfd->link.next) - for (sec = abfd->sections; sec != NULL; sec = sec->next) + for (abfd = link_info->input_bfds; abfd; abfd = abfd->link.next) + for (sec = abfd->sections; sec; sec = sec->next) { if (!collect_source_relocs (abfd, sec, link_info)) return FALSE; } /* Compute the text actions. */ - for (abfd = link_info->input_bfds; abfd != NULL; abfd = abfd->link.next) - for (sec = abfd->sections; sec != NULL; sec = sec->next) + for (abfd = link_info->input_bfds; abfd; abfd = abfd->link.next) + for (sec = abfd->sections; sec; sec = sec->next) { if (!compute_text_actions (abfd, sec, link_info)) return FALSE; @@ -8359,7 +8359,7 @@ xlate_offset_with_removed_text (const xlate_map_t *map, sizeof (xlate_map_entry_t), &xlate_compare); e = (xlate_map_entry_t *) r; - BFD_ASSERT (e != NULL); + BFD_ASSERT (e); if (e == NULL) return offset; return e->new_address - e->orig_address + offset; @@ -9571,7 +9571,7 @@ relax_section (bfd *abfd, asection *sec, struct bfd_link_info *link_info) if (! elf_xtensa_ignore_discarded_relocs (sec) && elf_xtensa_action_discarded (sec) == PRETEND && sec->sec_info_type != SEC_INFO_TYPE_STABS - && target_sec != NULL + && target_sec && discarded_section (target_sec)) { /* It would be natural to call _bfd_elf_check_kept_section @@ -9583,7 +9583,7 @@ relax_section (bfd *abfd, asection *sec, struct bfd_link_info *link_info) so just compare the section names to find the right group member. */ asection *kept = target_sec->kept_section; - if (kept != NULL) + if (kept) { if ((kept->flags & SEC_GROUP) != 0) { @@ -9591,7 +9591,7 @@ relax_section (bfd *abfd, asection *sec, struct bfd_link_info *link_info) asection *s = first; kept = NULL; - while (s != NULL) + while (s) { if (strcmp (s->name, target_sec->name) == 0) { @@ -9604,7 +9604,7 @@ relax_section (bfd *abfd, asection *sec, struct bfd_link_info *link_info) } } } - if (kept != NULL + if (kept && ((target_sec->rawsize != 0 ? target_sec->rawsize : target_sec->size) == (kept->rawsize != 0 ? kept->rawsize : kept->size))) @@ -9936,7 +9936,7 @@ translate_section_fixes (asection *sec) if (!relax_info) return TRUE; - for (r = relax_info->fix_list; r != NULL; r = r->next) + for (r = relax_info->fix_list; r; r = r->next) if (!translate_reloc_bfd_fix (r)) return FALSE; @@ -9999,7 +9999,7 @@ translate_reloc_bfd_fix (reloc_bfd_fix *fix) /* The fact that there is still a relocation to this literal indicates that the literal is being coalesced, not simply removed. */ - BFD_ASSERT (removed->to.abfd != NULL); + BFD_ASSERT (removed->to.abfd); /* This was moved to some other address (possibly another section). */ new_sec = r_reloc_get_section (&removed->to); @@ -10069,7 +10069,7 @@ translate_reloc (const r_reloc *orig_rel, r_reloc *new_rel, asection *sec) /* The fact that there is still a relocation to this literal indicates that the literal is being coalesced, not simply removed. */ - BFD_ASSERT (removed->to.abfd != NULL); + BFD_ASSERT (removed->to.abfd); /* This was moved to some other address (possibly in another section). */ @@ -10179,7 +10179,7 @@ shrink_dynamic_reloc_sections (struct bfd_link_info *info, srel = htab->srelgot; /* Reduce size of the .rela.* section by one reloc. */ - BFD_ASSERT (srel != NULL); + BFD_ASSERT (srel); BFD_ASSERT (srel->size >= sizeof (Elf32_External_Rela)); srel->size -= sizeof (Elf32_External_Rela); @@ -10199,14 +10199,14 @@ shrink_dynamic_reloc_sections (struct bfd_link_info *info, chunk = reloc_index / PLT_ENTRIES_PER_CHUNK; splt = elf_xtensa_get_plt_section (info, chunk); sgotplt = elf_xtensa_get_gotplt_section (info, chunk); - BFD_ASSERT (splt != NULL && sgotplt != NULL); + BFD_ASSERT (splt && sgotplt); /* Check if an entire PLT chunk has just been eliminated. */ if (reloc_index % PLT_ENTRIES_PER_CHUNK == 0) { /* The two magic GOT entries for that chunk can go away. */ srelgot = htab->srelgot; - BFD_ASSERT (srelgot != NULL); + BFD_ASSERT (srelgot); srelgot->reloc_count -= 2; srelgot->size -= 2 * sizeof (Elf32_External_Rela); sgotplt->size -= 8; @@ -11149,8 +11149,8 @@ match_section_group (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *inf) const char *group_name = elf_group_name (sec); return (group_name == gname - || (group_name != NULL - && gname != NULL + || (group_name + && gname && strcmp (group_name, gname) == 0)); } diff --git a/libr/asm/p/asm_or1k.c b/libr/asm/p/asm_or1k.c index 8683adc7aa..8d2fd97e99 100644 --- a/libr/asm/p/asm_or1k.c +++ b/libr/asm/p/asm_or1k.c @@ -142,7 +142,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) { /* if name is null, but extra is present, it means 6 most significant bits * are not enough to decode instruction */ if (!insn_descr->name && insn_descr->extra) { - if ((extra_descr = find_extra_descriptor(insn_descr->extra, insn)) != NULL) { + if ((extra_descr = find_extra_descriptor(insn_descr->extra, insn))) { insn_to_str (a, &line, insn_descr, extra_descr, insn); } else { line = strdup ("invalid"); diff --git a/libr/asm/p/asm_xap.c b/libr/asm/p/asm_xap.c index 57bb650859..1635b8cf35 100644 --- a/libr/asm/p/asm_xap.c +++ b/libr/asm/p/asm_xap.c @@ -15,7 +15,7 @@ static int arch_xap_disasm(char *str, const unsigned char *buf, ut64 seek) { s->s_off = seek; s->s_out = NULL; d = next_inst(s); - if (d != NULL) { + if (d) { xap_decode (s, d); strcpy (str, d->d_asm); free (d); diff --git a/libr/bin/bfile.c b/libr/bin/bfile.c index 4a359c6fec..af407ebce3 100644 --- a/libr/bin/bfile.c +++ b/libr/bin/bfile.c @@ -423,7 +423,7 @@ static bool __isDataSection(RBinFile *a, RBinSection *s) { return true; } // Rust - return strstr (s->name, "_const") != NULL; + return strstr (s->name, "_const"); } static void get_strings_range(RBinFile *bf, RList *list, int min, int raw, ut64 from, ut64 to, RBinSection *section) { @@ -824,7 +824,7 @@ R_IPI bool r_bin_file_set_bytes(RBinFile *bf, const ut8 *bytes, ut64 sz, bool st } else { bf->buf = r_buf_new_with_bytes (bytes, sz); } - return bf->buf != NULL; + return bf->buf; } R_API RBinPlugin *r_bin_file_cur_plugin(RBinFile *bf) { diff --git a/libr/bin/dwarf.c b/libr/bin/dwarf.c index de5800e5e6..a7456e3f9d 100644 --- a/libr/bin/dwarf.c +++ b/libr/bin/dwarf.c @@ -344,7 +344,7 @@ static bool is_printable_lang(ut64 attr_code) { if (attr_code >= sizeof (dwarf_langs) / sizeof (dwarf_langs[0])) { return false; } - return dwarf_langs[attr_code] != NULL; + return dwarf_langs[attr_code]; } static inline bool is_printable_attr(ut64 attr_code) { diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index 4e0c079d18..c9c39ceb17 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -1,8 +1,5 @@ -/* radare - LGPL - Copyright 2008-2021 - nibble, pancake, alvaro_fe */ +/* radare - LGPL - Copyright 2008-2022 - nibble, pancake, alvaro_fe */ -#include -#include -#include #include #include #include "elf.h" @@ -2500,24 +2497,25 @@ int Elf_(r_bin_elf_get_bits)(ELFOBJ *bin) { } static inline int noodle(ELFOBJ *bin, const char *s) { - if (r_buf_size (bin->b) <= 64) { - return 0; + if (r_buf_size (bin->b) >= 64) { + ut8 tmp[64] = {0}; + if (r_buf_read_at (bin->b, r_buf_size (bin->b) - 64, tmp, 64) == 64) { + return (bool)r_mem_mem (tmp, 64, (const ut8 *)s, strlen (s)); + } } - ut8 tmp[64]; - r_buf_read_at (bin->b, r_buf_size (bin->b) - 64, tmp, 64); - return r_mem_mem (tmp, 64, (const ut8 *)s, strlen (s)) != NULL; + return false; } -static inline int needle(ELFOBJ *bin, const char *s) { +static inline bool needle(ELFOBJ *bin, const char *s) { if (bin->shstrtab) { ut32 len = bin->shstrtab_size; if (len > 4096) { len = 4096; // avoid slow loading .. can be buggy? } - return r_mem_mem ((const ut8*)bin->shstrtab, len, - (const ut8*)s, strlen (s)) != NULL; + return (bool)r_mem_mem ((const ut8*)bin->shstrtab, len, + (const ut8*)s, strlen (s)); } - return 0; + return false; } // TODO: must return const char * all those strings must be const char os[LINUX] or so diff --git a/libr/bin/format/pe/dotnet.c b/libr/bin/format/pe/dotnet.c index 1d0e6c96d8..9dd69d9773 100644 --- a/libr/bin/format/pe/dotnet.c +++ b/libr/bin/format/pe/dotnet.c @@ -451,7 +451,7 @@ void dotnet_parse_tilde_2( string_offset, DOTNET_STRING_INDEX(module_table->Name)); - if (name != NULL) + if (name) set_string(name, pe->object, "module_name"); table_offset += ( @@ -670,7 +670,7 @@ void dotnet_parse_tilde_2( row_size = (index_size + index_size2 + index_sizes.blob); - if (typeref_ptr != NULL && memberref_ptr != NULL) + if (typeref_ptr && memberref_ptr) { row_ptr = table_offset; @@ -801,7 +801,7 @@ void dotnet_parse_tilde_2( pe, string_offset, *(WORD*) typeref_row); } - if (name != NULL && strncmp(name, "GuidAttribute", 13) != 0) + if (name && strncmp(name, "GuidAttribute", 13) != 0) { row_ptr += row_size; continue; @@ -1002,7 +1002,7 @@ void dotnet_parse_tilde_2( string_offset, DOTNET_STRING_INDEX(moduleref_table->Name)); - if (name != NULL) + if (name) { set_string(name, pe->object, "modulerefs[%i]", counter); counter++; @@ -1085,7 +1085,7 @@ void dotnet_parse_tilde_2( row_ptr + 4 + 2 + 2 + 2 + 2 + 4 + index_sizes.blob)); - if (name != NULL) + if (name) set_string(name, pe->object, "assembly.name"); // Culture comes after Name. @@ -1112,7 +1112,7 @@ void dotnet_parse_tilde_2( // Sometimes it will be a zero length string. This is technically // against the specification but happens from time to time. - if (name != NULL && strlen(name) > 0) + if (name && strlen(name) > 0) set_string(name, pe->object, "assembly.culture"); table_offset += row_size * num_rows; @@ -1185,7 +1185,7 @@ void dotnet_parse_tilde_2( string_offset, *(WORD*) (row_ptr + 2 + 2 + 2 + 2 + 4 + index_sizes.blob)); - if (name != NULL) + if (name) set_string(name, pe->object, "assembly_refs[%i].name", i); row_ptr += row_size; @@ -1287,7 +1287,7 @@ void dotnet_parse_tilde_2( string_offset, DOTNET_STRING_INDEX(manifestresource_table->Name)); - if (name != NULL) + if (name) set_string(name, pe->object, "resources[%i].name", counter); row_ptr += row_size; @@ -1564,7 +1564,7 @@ void dotnet_parse_com(PE* pe, ut64 baddr) { // 4. We need to exclude the terminator and the padding, so search for the // first NULL byte. end = (char*) memmem((void*) metadata->Version, metadata->Length, "\0", 1); - if (end != NULL) + if (end) set_sized_string(metadata->Version, (end - metadata->Version), pe->object, diff --git a/libr/bin/format/pe/pe.c b/libr/bin/format/pe/pe.c index 2ea0d7c710..77d79efb8f 100644 --- a/libr/bin/format/pe/pe.c +++ b/libr/bin/format/pe/pe.c @@ -3246,7 +3246,7 @@ static int bin_pe_init_security(RBinPEObj *pe) { } free ((void *)claimed_authentihash); } - pe->is_signed = pe->cms != NULL; + pe->is_signed = pe->cms; return true; } diff --git a/libr/bin/format/pe/pe64_write.c b/libr/bin/format/pe/pe64_write.c index 064ebb4da1..febb746bb9 100644 --- a/libr/bin/format/pe/pe64_write.c +++ b/libr/bin/format/pe/pe64_write.c @@ -1,4 +1,4 @@ /* radare - LGPL - Copyright 2008-2017 nibble, pancake */ #define R_BIN_PE64 1 -#include "pe_write.c" \ No newline at end of file +#include "pe_write.c" diff --git a/libr/bin/mangling/cxx/cp-demangle.c b/libr/bin/mangling/cxx/cp-demangle.c index be38edd7a2..f2c65e6b95 100644 --- a/libr/bin/mangling/cxx/cp-demangle.c +++ b/libr/bin/mangling/cxx/cp-demangle.c @@ -1034,7 +1034,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type, } p = d_make_empty (di); - if (p != NULL) + if (p) { p->type = type; p->u.s_binary.left = left; @@ -1078,7 +1078,7 @@ d_make_builtin_type (struct d_info *di, if (type == NULL) return NULL; p = d_make_empty (di); - if (p != NULL) + if (p) { p->type = DEMANGLE_COMPONENT_BUILTIN_TYPE; p->u.s_builtin.type = type; @@ -1094,7 +1094,7 @@ d_make_operator (struct d_info *di, const struct demangle_operator_info *op) struct demangle_component *p; p = d_make_empty (di); - if (p != NULL) + if (p) { p->type = DEMANGLE_COMPONENT_OPERATOR; p->u.s_operator.op = op; @@ -1166,7 +1166,7 @@ d_make_template_param (struct d_info *di, int i) struct demangle_component *p; p = d_make_empty (di); - if (p != NULL) + if (p) { p->type = DEMANGLE_COMPONENT_TEMPLATE_PARAM; p->u.s_number.number = i; @@ -1182,7 +1182,7 @@ d_make_function_param (struct d_info *di, int i) struct demangle_component *p; p = d_make_empty (di); - if (p != NULL) + if (p) { p->type = DEMANGLE_COMPONENT_FUNCTION_PARAM; p->u.s_number.number = i; @@ -1198,7 +1198,7 @@ d_make_sub (struct d_info *di, const char *name, int len) struct demangle_component *p; p = d_make_empty (di); - if (p != NULL) + if (p) { p->type = DEMANGLE_COMPONENT_SUB_STD; p->u.s_string.string = name; @@ -1618,7 +1618,7 @@ d_unqualified_name (struct d_info *di) if (peek == 'o' && d_peek_next_char (di) == 'n') d_advance (di, 2); ret = d_operator_name (di); - if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR) + if (ret && ret->type == DEMANGLE_COMPONENT_OPERATOR) { di->expansion += sizeof "operator" + ret->u.s_operator.op->len - 2; if (!strcmp (ret->u.s_operator.op->code, "li")) @@ -1910,7 +1910,7 @@ d_make_character (struct d_info *di, int c) { struct demangle_component *p; p = d_make_empty (di); - if (p != NULL) + if (p) { p->type = DEMANGLE_COMPONENT_CHARACTER; p->u.s_character.character = c; @@ -2201,7 +2201,7 @@ d_call_offset (struct d_info *di, int c) static struct demangle_component * d_ctor_dtor_name (struct d_info *di) { - if (di->last_name != NULL) + if (di->last_name) { if (di->last_name->type == DEMANGLE_COMPONENT_NAME) di->expansion += di->last_name->u.s_name.len; @@ -2550,7 +2550,7 @@ cplus_demangle_type (struct d_info *di) a new substitution candidate. However, if the substitution was followed by template arguments, then the whole thing is a substitution candidate. */ - if (ret != NULL && ret->type == DEMANGLE_COMPONENT_SUB_STD) + if (ret && ret->type == DEMANGLE_COMPONENT_SUB_STD) can_subst = 0; } } @@ -3902,7 +3902,7 @@ d_substitution (struct d_info *di, int prefix) int len; struct demangle_component *dc; - if (p->set_last_name != NULL) + if (p->set_last_name) di->last_name = d_make_sub (di, p->set_last_name, p->set_last_name_len); if (verbose) @@ -4357,7 +4357,7 @@ d_index_template_argument (struct demangle_component *args, int i) return args; for (a = args; - a != NULL; + a; a = d_right (a)) { if (a->type != DEMANGLE_COMPONENT_TEMPLATE_ARGLIST) @@ -4447,7 +4447,7 @@ d_pack_length (const struct demangle_component *dc) { int count = 0; while (dc && dc->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST - && d_left (dc) != NULL) + && d_left (dc)) { ++count; dc = d_right (dc); @@ -4519,7 +4519,7 @@ d_save_scope (struct d_print_info *dpi, scope->container = container; link = &scope->templates; - for (src = dpi->templates; src != NULL; src = src->next) + for (src = dpi->templates; src; src = src->next) { struct d_print_template *dst; @@ -4695,7 +4695,7 @@ d_print_comp_inner (struct d_print_info *dpi, int options, dpi->modifiers = 0; i = 0; typed_name = d_left (dc); - while (typed_name != NULL) + while (typed_name) { if (i >= sizeof adpm / sizeof adpm[0]) { @@ -4993,7 +4993,7 @@ d_print_comp_inner (struct d_print_info *dpi, int options, same CV-qualifier gets pushed on the stack multiple times. We only need to print it once. */ - for (pdpm = dpi->modifiers; pdpm != NULL; pdpm = pdpm->next) + for (pdpm = dpi->modifiers; pdpm; pdpm = pdpm->next) { if (! pdpm->printed) { @@ -5040,7 +5040,7 @@ d_print_comp_inner (struct d_print_info *dpi, int options, /* This traversal is reentering SUB as a substition. If we are not beneath SUB or DC in the tree then we need to restore SUB's template stack temporarily. */ - for (dcse = dpi->component_stack; dcse != NULL; + for (dcse = dpi->component_stack; dcse; dcse = dcse->parent) { if (dcse->dc == sub @@ -5139,10 +5139,10 @@ d_print_comp_inner (struct d_print_info *dpi, int options, dc, dpi->modifiers); /* Print return type if present */ - if (d_left (dc) != NULL && (options & DMGL_RET_POSTFIX) != 0) + if (d_left (dc) && (options & DMGL_RET_POSTFIX) != 0) d_print_comp (dpi, options & ~(DMGL_RET_POSTFIX | DMGL_RET_DROP), d_left (dc)); - else if (d_left (dc) != NULL && (options & DMGL_RET_DROP) == 0) + else if (d_left (dc) && (options & DMGL_RET_DROP) == 0) { struct d_print_mod dpm; @@ -5201,7 +5201,7 @@ d_print_comp_inner (struct d_print_info *dpi, int options, i = 1; pdpm = hold_modifiers; - while (pdpm != NULL + while (pdpm && (pdpm->mod->type == DEMANGLE_COMPONENT_RESTRICT || pdpm->mod->type == DEMANGLE_COMPONENT_VOLATILE || pdpm->mod->type == DEMANGLE_COMPONENT_CONST)) @@ -5283,9 +5283,9 @@ d_print_comp_inner (struct d_print_info *dpi, int options, case DEMANGLE_COMPONENT_ARGLIST: case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: - if (d_left (dc) != NULL) + if (d_left (dc)) d_print_comp (dpi, options, d_left (dc)); - if (d_right (dc) != NULL) + if (d_right (dc)) { size_t len; unsigned long int flush_count; @@ -5508,7 +5508,7 @@ d_print_comp_inner (struct d_print_info *dpi, int options, else { d_append_string (dpi, "new "); - if (d_left (first) != NULL) + if (d_left (first)) { d_print_subexpr (dpi, options, first); d_append_char (dpi, ' '); @@ -5982,7 +5982,7 @@ d_print_function_type (struct d_print_info *dpi, int options, need_paren = 0; need_space = 0; - for (p = mods; p != NULL; p = p->next) + for (p = mods; p; p = p->next) { if (p->printed) break; @@ -6036,7 +6036,7 @@ d_print_function_type (struct d_print_info *dpi, int options, d_append_char (dpi, '('); - if (d_right (dc) != NULL) + if (d_right (dc)) d_print_comp (dpi, options, d_right (dc)); d_append_char (dpi, ')'); @@ -6056,13 +6056,13 @@ d_print_array_type (struct d_print_info *dpi, int options, int need_space; need_space = 1; - if (mods != NULL) + if (mods) { int need_paren; struct d_print_mod *p; need_paren = 0; - for (p = mods; p != NULL; p = p->next) + for (p = mods; p; p = p->next) { if (! p->printed) { @@ -6094,7 +6094,7 @@ d_print_array_type (struct d_print_info *dpi, int options, d_append_char (dpi, '['); - if (d_left (dc) != NULL) + if (d_left (dc)) d_print_comp (dpi, options, d_left (dc)); d_append_char (dpi, ']'); @@ -6132,7 +6132,7 @@ d_print_conversion (struct d_print_info *dpi, int options, /* For a conversion operator, we need the template parameters from the enclosing template in scope for processing the type. */ - if (dpi->current_template != NULL) + if (dpi->current_template) { dpt.next = dpi->templates; dpi->templates = &dpt; @@ -6142,7 +6142,7 @@ d_print_conversion (struct d_print_info *dpi, int options, if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE) { d_print_comp (dpi, options, d_left (dc)); - if (dpi->current_template != NULL) + if (dpi->current_template) dpi->templates = dpt.next; } else @@ -6152,7 +6152,7 @@ d_print_conversion (struct d_print_info *dpi, int options, /* For a templated cast operator, we need to remove the template parameters from scope after printing the operator name, so we need to handle the template printing here. */ - if (dpi->current_template != NULL) + if (dpi->current_template) dpi->templates = dpt.next; if (d_last_char (dpi) == '<') @@ -6282,7 +6282,7 @@ d_demangle_callback (const char *mangled, int options, d_dump (dc, 0); #endif - status = (dc != NULL) + status = (dc) ? cplus_demangle_print_callback (options, dc, callback, opaque) : 0; } @@ -6357,14 +6357,14 @@ __cxa_demangle (const char *mangled_name, char *output_buffer, if (mangled_name == NULL) { - if (status != NULL) + if (status) *status = -3; return NULL; } - if (output_buffer != NULL && length == NULL) + if (output_buffer && length == NULL) { - if (status != NULL) + if (status) *status = -3; return NULL; } @@ -6373,7 +6373,7 @@ __cxa_demangle (const char *mangled_name, char *output_buffer, if (demangled == NULL) { - if (status != NULL) + if (status) { if (alc == 1) *status = -1; @@ -6385,7 +6385,7 @@ __cxa_demangle (const char *mangled_name, char *output_buffer, if (output_buffer == NULL) { - if (length != NULL) + if (length) *length = alc; } else @@ -6403,7 +6403,7 @@ __cxa_demangle (const char *mangled_name, char *output_buffer, } } - if (status != NULL) + if (status) *status = 0; return demangled; @@ -6535,7 +6535,7 @@ is_ctor_or_dtor (const char *mangled, to demangle the entire string. */ ret = 0; - while (dc != NULL) + while (dc) { switch (dc->type) { @@ -6717,7 +6717,7 @@ main (int argc, char *argv[]) s = cplus_demangle_v3 (dyn_string_buf (mangled), options); #endif - if (s != NULL) + if (s) { fputs (s, stdout); free (s); @@ -6759,7 +6759,7 @@ main (int argc, char *argv[]) #endif /* If it worked, print the demangled name. */ - if (s != NULL) + if (s) { printf ("%s\n", s); free (s); diff --git a/libr/bin/mangling/microsoft_demangle.c b/libr/bin/mangling/microsoft_demangle.c index 434e608b3f..d3f6fc449d 100644 --- a/libr/bin/mangling/microsoft_demangle.c +++ b/libr/bin/mangling/microsoft_demangle.c @@ -610,7 +610,7 @@ static size_t get_namespace_and_name(const char *buf, STypeCodeStr *type_code_st goto get_namespace_and_name_err; } - while (curr_pos != NULL) { + while (curr_pos) { len = curr_pos - prev_pos; tmp = prev_pos; diff --git a/libr/bin/p/bin_coff.c b/libr/bin/p/bin_coff.c index 9bc08c7d58..9414b507c4 100644 --- a/libr/bin/p/bin_coff.c +++ b/libr/bin/p/bin_coff.c @@ -27,7 +27,7 @@ static bool r_coff_is_stripped(struct r_bin_coff_obj *obj) { static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadaddr, Sdb *sdb) { *bin_obj = r_bin_coff_new_buf (buf, bf->rbin->verbose); - return *bin_obj != NULL; + return *bin_obj; } static void destroy(RBinFile *bf) { diff --git a/libr/bin/p/bin_dex.c b/libr/bin/p/bin_dex.c index 354e00502c..f1d365124e 100644 --- a/libr/bin/p/bin_dex.c +++ b/libr/bin/p/bin_dex.c @@ -724,7 +724,7 @@ static Sdb *get_sdb(RBinFile *bf) { static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadaddr, Sdb *sdb) { RBinDexObj *o = r_bin_dex_new_buf (buf, bf->rbin->verbose); *bin_obj = o; - return o != NULL; + return o; } static ut64 baddr(RBinFile *bf) { diff --git a/libr/bin/p/bin_fs.c b/libr/bin/p/bin_fs.c index 87e0eed448..4b2042d176 100644 --- a/libr/bin/p/bin_fs.c +++ b/libr/bin/p/bin_fs.c @@ -42,7 +42,7 @@ static char *fsname(RBuffer *b) { static bool check_buffer(RBinFile *bf, RBuffer *b) { r_return_val_if_fail (b, false); char *p = fsname (b); - bool hasFs = p != NULL; + bool hasFs = p; free (p); return hasFs; } diff --git a/libr/bin/p/bin_ninds.c b/libr/bin/p/bin_ninds.c index 56cae1f2c3..9f342f6dec 100644 --- a/libr/bin/p/bin_ninds.c +++ b/libr/bin/p/bin_ninds.c @@ -28,7 +28,7 @@ static bool check_buffer(RBinFile *bf, RBuffer *b) { static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *b, ut64 loadaddr, Sdb *sdb) { r_buf_read_at (b, 0, (ut8*)&loaded_header, sizeof (loaded_header)); *bin_obj = &loaded_header; - return (*bin_obj != NULL); + return (*bin_obj); } static ut64 baddr(RBinFile *bf) { diff --git a/libr/bin/p/bin_ningb.c b/libr/bin/p/bin_ningb.c index fdcf38f50b..c0e9595fda 100644 --- a/libr/bin/p/bin_ningb.c +++ b/libr/bin/p/bin_ningb.c @@ -44,7 +44,7 @@ static RList* entries(RBinFile *bf) { RList *ret = r_list_new (); RBinAddr *ptr = NULL; - if (bf && bf->buf != NULL) { + if (bf && bf->buf) { if (!ret) { return NULL; } diff --git a/libr/bin/p/bin_nro.c b/libr/bin/p/bin_nro.c index 22d2ace3b0..a14b1a504d 100644 --- a/libr/bin/p/bin_nro.c +++ b/libr/bin/p/bin_nro.c @@ -33,7 +33,7 @@ static ut64 baddr(RBinFile *bf) { static bool check_buffer(RBinFile *bf, RBuffer *b) { ut8 magic[4]; if (r_buf_read_at (b, NRO_OFF (magic), magic, sizeof (magic)) == 4) { - return fileType (magic) != NULL; + return fileType (magic); } return false; } diff --git a/libr/bin/p/bin_nso.c b/libr/bin/p/bin_nso.c index 67994bce5c..7f69eb2b31 100644 --- a/libr/bin/p/bin_nso.c +++ b/libr/bin/p/bin_nso.c @@ -56,7 +56,7 @@ static bool check_buffer(RBinFile *bf, RBuffer *b) { if (r_buf_read_at (b, 0, magic, sizeof (magic)) != 4) { return false; } - return fileType (magic) != NULL; + return fileType (magic); } return false; } diff --git a/libr/bin/p/bin_omf.c b/libr/bin/p/bin_omf.c index 07b8ec483d..d2e5ae829f 100644 --- a/libr/bin/p/bin_omf.c +++ b/libr/bin/p/bin_omf.c @@ -11,7 +11,7 @@ static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *b, ut64 loadaddr, const ut8 *buf = r_buf_data (b, &size); r_return_val_if_fail (buf, false); *bin_obj = r_bin_internal_omf_load (buf, size); - return *bin_obj != NULL; + return *bin_obj; } static void destroy(RBinFile *bf) { diff --git a/libr/bin/p/bin_xtr_fatmach0.c b/libr/bin/p/bin_xtr_fatmach0.c index 2cbcc61f1c..c696552b9c 100644 --- a/libr/bin/p/bin_xtr_fatmach0.c +++ b/libr/bin/p/bin_xtr_fatmach0.c @@ -44,7 +44,7 @@ static void destroy(RBin *bin) { } static bool load(RBin *bin) { - return ((bin->cur->xtr_obj = r_bin_fatmach0_new (bin->file)) != NULL); + return ((bin->cur->xtr_obj = r_bin_fatmach0_new (bin->file))); } static int size(RBin *bin) { diff --git a/libr/bin/p/bin_xtr_sep64.c b/libr/bin/p/bin_xtr_sep64.c index bdef3b8f02..8f969dc5c8 100644 --- a/libr/bin/p/bin_xtr_sep64.c +++ b/libr/bin/p/bin_xtr_sep64.c @@ -134,7 +134,7 @@ static bool check_buffer(RBinFile *bf, RBuffer *b) { } static bool load(RBin *bin) { - return ((bin->cur->xtr_obj = sep64_xtr_ctx_new (bin->cur->buf)) != NULL); + return ((bin->cur->xtr_obj = sep64_xtr_ctx_new (bin->cur->buf))); } static void destroy(RBin *bin) { diff --git a/libr/bin/p/bin_zimg.c b/libr/bin/p/bin_zimg.c index ae634c8db4..fde86a21c2 100644 --- a/libr/bin/p/bin_zimg.c +++ b/libr/bin/p/bin_zimg.c @@ -14,7 +14,7 @@ static Sdb *get_sdb(RBinFile *bf) { static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *b, ut64 loadaddr, Sdb *sdb){ *bin_obj = r_bin_zimg_new_buf (b); - return *bin_obj != NULL; + return *bin_obj; } static ut64 baddr(RBinFile *bf) { diff --git a/libr/bin/pdb/pdb.c b/libr/bin/pdb/pdb.c index a233370427..2c94f698c3 100644 --- a/libr/bin/pdb/pdb.c +++ b/libr/bin/pdb/pdb.c @@ -241,7 +241,7 @@ static int init_pdb7_root_stream(RPdb *pdb, int *root_page_list, int pages_amoun // pdb_stream->pdb_stream = (R_PDB_STREAM *) malloc(sizeof(R_PDB_STREAM)); // init_r_pdb_stream(pdb_stream->pdb_stream, fp, pages, pages_amount, index, size, page_size); // pdb_stream->load = pLoad; -// if (pLoad != NULL) { +// if (pLoad) { // pLoad(pdb_stream, &(pdb_stream->pdb_stream->stream_file)); // } // } diff --git a/libr/bin/pdb/tpi.c b/libr/bin/pdb/tpi.c index 5438b251cb..04eac586df 100644 --- a/libr/bin/pdb/tpi.c +++ b/libr/bin/pdb/tpi.c @@ -2032,7 +2032,7 @@ static void get_nesttype_print_type(void *type, char **name) { tmp_name = base_type->type; } else { ti = &t->type_data; - if (ti->get_print_type != NULL) { + if (ti->get_print_type) { ti->get_print_type (ti, &tmp_name); } else { // TODO: need to investigate why this branch can be... diff --git a/libr/cons/cutf8.c b/libr/cons/cutf8.c index d34f358c37..46eacea8e0 100644 --- a/libr/cons/cutf8.c +++ b/libr/cons/cutf8.c @@ -234,7 +234,7 @@ R_API bool r_cons_is_utf8(void) { #endif #if R_UTF8_DETECT_LOCALE const char *ctype = setlocale (LC_CTYPE, NULL); - if ((ctype != NULL) && (ctype = strchr (ctype, '.')) && ctype++ && + if ((ctype) && (ctype = strchr (ctype, '.')) && ctype++ && (!r_str_casecmp (ctype, "UTF-8") || !r_str_casecmp (ctype, "UTF8"))) { return true; } diff --git a/libr/cons/dietline.c b/libr/cons/dietline.c index 5eca79cf5c..d33b38a951 100644 --- a/libr/cons/dietline.c +++ b/libr/cons/dietline.c @@ -525,7 +525,7 @@ R_API int r_line_hist_load(const char *file) { free (path); return false; } - while (fgets (buf, sizeof (buf), fd) != NULL) { + while (fgets (buf, sizeof (buf), fd)) { r_str_trim_tail (buf); r_line_hist_add (buf); } @@ -778,7 +778,7 @@ R_API void r_line_autocomplete(void) { if (argc == 1) { const char *end_word = r_sub_str_rchr (I.buffer.data, I.buffer.index, strlen (I.buffer.data), ' '); - const char *t = end_word != NULL? + const char *t = end_word? end_word: I.buffer.data + I.buffer.index; int largv0 = strlen (r_str_get (argv[0])); size_t len_t = strlen (t); diff --git a/libr/core/agraph.c b/libr/core/agraph.c index e5975633df..d086ee07bb 100644 --- a/libr/core/agraph.c +++ b/libr/core/agraph.c @@ -2178,7 +2178,7 @@ static char *get_bb_body(RCore *core, RAnalBlock *b, int opts, RAnalFunction *fc if (b->jump > b->addr) { RAnalBlock *jumpbb = r_anal_get_block_at (b->anal, b->jump); if (jumpbb && r_list_contains (jumpbb->fcns, fcn)) { - if (emu && core->anal->last_disasm_reg != NULL && !jumpbb->parent_reg_arena) { + if (emu && core->anal->last_disasm_reg && !jumpbb->parent_reg_arena) { jumpbb->parent_reg_arena = r_reg_arena_dup (core->anal->reg, core->anal->last_disasm_reg); } if (jumpbb->parent_stackptr == INT_MAX) { @@ -2191,7 +2191,7 @@ static char *get_bb_body(RCore *core, RAnalBlock *b, int opts, RAnalFunction *fc if (b->fail > b->addr) { RAnalBlock *failbb = r_anal_get_block_at (b->anal, b->fail); if (failbb && r_list_contains (failbb->fcns, fcn)) { - if (emu && core->anal->last_disasm_reg != NULL && !failbb->parent_reg_arena) { + if (emu && core->anal->last_disasm_reg && !failbb->parent_reg_arena) { failbb->parent_reg_arena = r_reg_arena_dup (core->anal->reg, core->anal->last_disasm_reg); } if (failbb->parent_stackptr == INT_MAX) { @@ -2485,7 +2485,7 @@ static bool get_cgnodes(RAGraph *g, RCore *core, RAnalFunction *fcn) { refs = r_anal_function_get_refs (fcn); r_list_foreach (refs, iter, ref) { title = get_title (ref->addr); - if (r_agraph_get_node (g, title) != NULL) { + if (r_agraph_get_node (g, title)) { continue; } free (title); @@ -4328,7 +4328,7 @@ R_API int r_core_visual_graph(RCore *core, RAGraph *g, RAnalFunction *_fcn, int grd->fs = is_interactive == 1; grd->core = core; grd->follow_offset = _fcn == NULL; - grd->fcn = fcn != NULL? &fcn: NULL; + grd->fcn = fcn? &fcn: NULL; ret = agraph_refresh (grd); if (!ret || is_interactive != 1) { r_cons_newline (); diff --git a/libr/core/anal_tp.c b/libr/core/anal_tp.c index bcfb44b6d5..fa826a7fdd 100644 --- a/libr/core/anal_tp.c +++ b/libr/core/anal_tp.c @@ -100,7 +100,7 @@ static void __var_retype(RAnal *anal, RAnalVar *var, const char *vname, const ch expand = "unsigned long long"; } const char *tmp = strstr (expand, "int"); - bool is_default = tmp != NULL; + bool is_default = tmp; if (!is_default && strncmp (var->type, "void", 4)) { // return since type is already propagated // except for "void *", since "void *" => "char *" is possible @@ -764,7 +764,7 @@ repeat: if (prev_dest && (type == R_ANAL_OP_TYPE_MOV || type == R_ANAL_OP_TYPE_STORE)) { char reg[REGNAME_SIZE] = {0}; get_src_regname (core, addr, reg, sizeof (reg)); - bool match = strstr (prev_dest, reg) != NULL; + bool match = strstr (prev_dest, reg); if (str_flag && match) { __var_retype (anal, var, NULL, "const char *", false, false); } diff --git a/libr/core/canal.c b/libr/core/canal.c index c86890e457..e949c3054b 100644 --- a/libr/core/canal.c +++ b/libr/core/canal.c @@ -4254,7 +4254,7 @@ R_API int r_core_anal_all(RCore *core) { r_cons_break_push (NULL, NULL); /* Symbols (Imports are already analyzed by rabin2 on init) */ - if ((list = r_bin_get_symbols (core->bin)) != NULL) { + if ((list = r_bin_get_symbols (core->bin))) { r_list_foreach (list, iter, symbol) { if (r_cons_is_breaked ()) { break; diff --git a/libr/core/casm.c b/libr/core/casm.c index 02470e39be..88f2e91ac8 100644 --- a/libr/core/casm.c +++ b/libr/core/casm.c @@ -208,7 +208,7 @@ R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut6 if (mode == 'a') { // check for case sensitive matches = !r_str_ncasecmp (opst, tokens[matchcount], strlen (tokens[matchcount])); } else if (!regexp) { - matches = strstr (opst, tokens[matchcount]) != NULL; + matches = !!strstr (opst, tokens[matchcount]); } else { rx = r_regex_new (tokens[matchcount], "es"); matches = r_regex_exec (rx, opst, 0, 0, 0) == 0; diff --git a/libr/core/cbin.c b/libr/core/cbin.c index 982a064aa3..3ca81ca219 100644 --- a/libr/core/cbin.c +++ b/libr/core/cbin.c @@ -834,7 +834,7 @@ static int bin_info(RCore *r, PJ *pj, int mode, ut64 laddr) { } return false; } - bool havecode = is_executable (obj) | (obj->entries != NULL); + bool havecode = is_executable (obj) | (!!obj->entries); const char *compiled = get_compile_time (bf->sdb); if (IS_MODE_SET (mode)) { @@ -1736,6 +1736,13 @@ static int bin_relocs(RCore *r, PJ *pj, int mode, int va) { } relocs = r_bin_get_relocs (r->bin); } + if (!relocs) { + if (pj) { + pj_a (pj); + pj_end (pj); + } + return false; + } if (bin_cache) { if (r_pvector_len (&r->io->cache) == 0) { r_config_set (r->config, "io.cache", "false"); @@ -1879,10 +1886,10 @@ static int bin_relocs(RCore *r, PJ *pj, int mode, int va) { db = NULL; R_TIME_PROFILE_END; - if (IS_MODE_JSON (mode) && relocs == NULL) { + if (IS_MODE_JSON (mode)) { return true; } - return relocs != NULL; + return true; } #define MYDB 1 @@ -2155,7 +2162,7 @@ typedef struct { } SymName; static void snInit(RCore *r, SymName *sn, RBinSymbol *sym, const char *lang) { - int bin_demangle = lang != NULL; + bool bin_demangle = !!lang; bool keep_lib = r_config_get_b (r->config, "bin.demangle.libs"); if (!r || !sym || !sym->name) { return; @@ -2433,14 +2440,12 @@ static int bin_symbols(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at, pj_kb (pj, "is_imported", symbol->is_imported); pj_end (pj); } else if (IS_MODE_SIMPLE (mode)) { - const char *name = sn.demname? sn.demname: r_symbol_name; - r_cons_printf ("0x%08"PFMT64x" %d %s%s%s\n", - addr, (int)symbol->size, - r_str_get (sn.libname), sn.libname ? " " : "", - name); + const char *n = sn.demname? sn.demname: r_symbol_name; + r_cons_printf ("0x%08"PFMT64x" %d %s%s%s\n", addr, (int)symbol->size, + r_str_get (sn.libname), sn.libname ? " " : "", n); } else if (IS_MODE_SIMPLEST (mode)) { - const char *name = sn.demname? sn.demname: r_symbol_name; - r_cons_printf ("%s\n", name); + const char *n = sn.demname? sn.demname: r_symbol_name; + r_cons_printf ("%s\n", n); } else if (IS_MODE_RAD (mode)) { /* Skip special symbols because we do not flag them and * they shouldn't be printed in the rad format either */ @@ -2449,8 +2454,8 @@ static int bin_symbols(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at, } RBinFile *binfile; RBinPlugin *plugin; - const char *name = sn.demname? sn.demname: r_symbol_name; - if (!name) { + const char *n = sn.demname? sn.demname: r_symbol_name; + if (!n) { goto next; } if (symbol->is_imported) { @@ -2465,8 +2470,8 @@ static int bin_symbols(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at, } lastfs = 's'; } - if (r->bin->prefix || *name) { // we don't want unnamed symbol flags - char *flagname = construct_symbol_flagname ("sym", sn.libname, name, MAXFLAG_LEN_DEFAULT); + if (r->bin->prefix || *n) { // we don't want unnamed symbol flags + char *flagname = construct_symbol_flagname ("sym", sn.libname, n, MAXFLAG_LEN_DEFAULT); if (!flagname) { goto next; } @@ -2501,7 +2506,7 @@ static int bin_symbols(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at, } else { const char *bind = r_str_get_fail (symbol->bind, "NONE"); const char *type = r_str_get_fail (symbol->type, "NONE"); - const char *name = r_str_getf (sn.demname? sn.demname: sn.name); + const char *n = r_str_getf (sn.demname? sn.demname: sn.name); // const char *fwd = r_str_getf (symbol->forwarder); r_table_add_rowf (table, "dXXssdss", symbol->ordinal, @@ -2511,7 +2516,7 @@ static int bin_symbols(RCore *r, PJ *pj, int mode, ut64 laddr, int va, ut64 at, type, symbol->size, r_str_get (symbol->libname), - name); + n); } next: snFini (&sn); @@ -2559,7 +2564,7 @@ static char *build_hash_string(PJ *pj, int mode, const char *chksum, ut8 *data, char *chkstr = NULL, *aux = NULL, *ret = NULL; RList *hashlist = r_str_split_duplist (chksum, ",", true); RListIter *iter; - char *hashname; + const char *hashname; r_list_foreach (hashlist, iter, hashname) { chkstr = r_hash_to_string (NULL, hashname, data, datalen); if (!chkstr) { diff --git a/libr/core/cmd.c b/libr/core/cmd.c index c4c357246e..a8bf78df1d 100644 --- a/libr/core/cmd.c +++ b/libr/core/cmd.c @@ -1222,7 +1222,7 @@ R_API bool r_core_run_script(RCore *core, const char *file) { sdb_query_lines (core->anal->sdb_types, out); free (out); } - ret = out != NULL; + ret = out; } else { p = r_lang_get_by_extension (core->lang, file); if (p) { @@ -3566,7 +3566,7 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd, char *colon, bool *tmpseek op0 = *q; *q = 0; } - haveQuote = q != NULL; + haveQuote = q; oseek = core->offset; r_core_seek (core, r_num_math (core->num, p + 2), true); if (q) { @@ -3998,7 +3998,7 @@ escape_backtick: ptr = NULL; } - cmd_tmpseek = core->tmpseek = ptr != NULL; + cmd_tmpseek = core->tmpseek = ptr; int rc = 0; if (ptr) { char *f, *ptr2 = strchr (ptr + 1, '!'); @@ -5215,7 +5215,7 @@ R_API int r_core_cmd_foreach(RCore *core, const char *cmd, char *each) { break; } r_cons_flush (); - } while (str != NULL); + } while (str); free (out); } } diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index f9035edc05..f2dce82289 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -3566,7 +3566,7 @@ static void __core_cmd_anal_fcn_allstats(RCore *core, const char *input) { RList *dbs = r_list_newf ((RListFree)sdb_free); Sdb *d = sdb_new0 (); ut64 oseek = core->offset; - bool isJson = strchr (input, 'j') != NULL; + bool isJson = strchr (input, 'j'); char *inp = r_str_newf ("*%s", input); r_list_foreach (core->anal->fcns, iter, fcn) { @@ -4449,14 +4449,14 @@ int cmd_anal_fcn(RCore *core, const char *input) { case 'C': // "afC" if (input[2] == 'c') { RAnalFunction *fcn; - if ((fcn = r_anal_get_fcn_in (core->anal, core->offset, 0)) != NULL) { + if ((fcn = r_anal_get_fcn_in (core->anal, core->offset, 0))) { r_cons_printf ("%i\n", r_anal_function_complexity (fcn)); } else { eprintf ("Error: Cannot find function at 0x08%" PFMT64x "\n", core->offset); } } else if (input[2] == 'l') { RAnalFunction *fcn; - if ((fcn = r_anal_get_fcn_in (core->anal, core->offset, 0)) != NULL) { + if ((fcn = r_anal_get_fcn_in (core->anal, core->offset, 0))) { r_cons_printf ("%d\n", r_anal_function_loops (fcn)); } else { eprintf ("Error: Cannot find function at 0x08%" PFMT64x "\n", core->offset); @@ -10579,7 +10579,7 @@ static bool archIsThumbable(RCore *core) { } static void _CbInRangeAav(RCore *core, ut64 from, ut64 to, int vsize, void *user) { - bool asterisk = user != NULL; + bool asterisk = user; int arch_align = r_anal_archinfo (core->anal, R_ANAL_ARCHINFO_ALIGN); bool vinfun = r_config_get_i (core->config, "anal.vinfun"); int searchAlign = r_config_get_i (core->config, "search.align"); diff --git a/libr/core/cmd_api.c b/libr/core/cmd_api.c index fbd4c0a6e6..d7329ccc72 100644 --- a/libr/core/cmd_api.c +++ b/libr/core/cmd_api.c @@ -934,7 +934,7 @@ R_API bool r_cmd_macro_add(RCmdMacro *mac, const char *oname) { } macro->args = strdup (args); ptr = strchr (macro->name, ' '); - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; macro->nargs = r_str_word_set0 (ptr+1); } diff --git a/libr/core/cmd_cmp.c b/libr/core/cmd_cmp.c index ca390404d5..a6d95d5777 100644 --- a/libr/core/cmd_cmp.c +++ b/libr/core/cmd_cmp.c @@ -976,7 +976,7 @@ static int cmd_cmp(void *data, const char *input) { } int col = core->cons->columns > 123; ut8 *b = malloc (core->blocksize); - if (b != NULL) { + if (b) { memset (b, 0xff, core->blocksize); r_io_read_at (core->io, addr, b, core->blocksize); r_print_hexdiff (core->print, core->offset, block, diff --git a/libr/core/cmd_debug.c b/libr/core/cmd_debug.c index 577dc55368..1e1c274acb 100644 --- a/libr/core/cmd_debug.c +++ b/libr/core/cmd_debug.c @@ -1766,7 +1766,7 @@ static int cmd_debug_map(RCore *core, const char *input) { r_list_foreach (list, iter, map) { if ((!libname || (addr != UT64_MAX && (addr >= map->addr && addr < map->addr_end)) || - (libname != NULL && (strstr (map->name, libname))))) { + (libname && (strstr (map->name, libname))))) { baddr = map->addr; char *res; const char *file = map->file? map->file: map->name; diff --git a/libr/core/cmd_flag.c b/libr/core/cmd_flag.c index e495250bc9..0295b893eb 100644 --- a/libr/core/cmd_flag.c +++ b/libr/core/cmd_flag.c @@ -1620,7 +1620,7 @@ rep: RListIter *iter; r_list_sort (temp, &cmpflag); r_list_foreach (temp, iter, flag) { - if (strstr (flag->name , arg) != NULL) { + if (strstr (flag->name , arg)) { if (flag->offset < core->offset) { loff = flag->offset; lmatch = flag->name; diff --git a/libr/core/cmd_help.c b/libr/core/cmd_help.c index 6c5a80e695..b4caba54de 100644 --- a/libr/core/cmd_help.c +++ b/libr/core/cmd_help.c @@ -1121,7 +1121,7 @@ static int cmd_help(void *data, const char *input) { r_str_trim (msg); char *p = strchr (msg, '&'); if (p) *p = 0; - r_sys_tts (msg, p != NULL); + r_sys_tts (msg, p); free (msg); break; } diff --git a/libr/core/cmd_info.c b/libr/core/cmd_info.c index fefa8ee3cb..60a0c37652 100644 --- a/libr/core/cmd_info.c +++ b/libr/core/cmd_info.c @@ -1271,7 +1271,7 @@ static int cmd_info(void *data, const char *input) { break; } if (input[2] && input[2] != '*' && input[2] != 'j' && !strstr (input, "qq")) { - bool radare2 = strstr (input, "**") != NULL; + bool radare2 = strstr (input, "**"); int idx = -1; const char * cls_name = NULL; if (radare2) { diff --git a/libr/core/cmd_seek.c b/libr/core/cmd_seek.c index 6d7119e2d3..6629514b3f 100644 --- a/libr/core/cmd_seek.c +++ b/libr/core/cmd_seek.c @@ -348,7 +348,7 @@ static int cmd_seek(void *data, const char *input) { return 0; } char *ptr; - if ((ptr = strstr (input, "+.")) != NULL) { + if ((ptr = strstr (input, "+."))) { char *dup = strdup (input); dup[ptr - input] = '\x00'; off = r_num_math (core->num, dup + 1); diff --git a/libr/core/cmd_write.c b/libr/core/cmd_write.c index 40b9302830..b07bf1f607 100644 --- a/libr/core/cmd_write.c +++ b/libr/core/cmd_write.c @@ -1217,7 +1217,7 @@ static int wr_handler_old(void *data, const char *input) { int len = (int)off; if (len > 0) { ut8 *buf = malloc (len); - if (buf != NULL) { + if (buf) { int i; r_num_irand (); for (i = 0; i < len; i++) diff --git a/libr/core/rvc.c b/libr/core/rvc.c index 6cf27d1f76..fe83401ec2 100644 --- a/libr/core/rvc.c +++ b/libr/core/rvc.c @@ -303,7 +303,7 @@ static bool update_blobs(const RList *ignore, RList *blobs, const RList *nh) { continue; } blob->fhash = r_str_new (nh->tail->data); - return blob->fhash != NULL; + return blob->fhash; } blob = R_NEW (RvcBlob); if (!blob) { diff --git a/libr/core/vmenus.c b/libr/core/vmenus.c index 1561cf716b..940d0421ae 100644 --- a/libr/core/vmenus.c +++ b/libr/core/vmenus.c @@ -947,7 +947,7 @@ R_API bool r_core_visual_hudclasses(RCore *core) { free (res); } r_list_free (list); - return res != NULL; + return res; } static bool hudstuff_append(RFlagItem *fi, void *user) { @@ -989,7 +989,7 @@ R_API bool r_core_visual_hudstuff(RCore *core) { free (res); } r_list_free (list); - return res != NULL; + return res; } static bool r_core_visual_config_hud(RCore *core) { diff --git a/libr/crypto/crypto.c b/libr/crypto/crypto.c index 2ddd66544d..ff62f5895e 100644 --- a/libr/crypto/crypto.c +++ b/libr/crypto/crypto.c @@ -128,7 +128,7 @@ R_API bool r_crypto_use(RCrypto *cry, const char *algo) { r_list_foreach (cry->plugins, iter, h) { if (h && h->use && h->use (algo)) { cry->h = h; - return cry->h != NULL; + return cry->h; } } return false; diff --git a/libr/debug/debug.c b/libr/debug/debug.c index 491506fd62..61a77b7ec8 100644 --- a/libr/debug/debug.c +++ b/libr/debug/debug.c @@ -1157,7 +1157,7 @@ R_API int r_debug_continue_kill(RDebug *dbg, int sig) { if (reg->cnum <= dbg->session->cnum) { continue; } - has_bp = r_bp_get_in (dbg->bp, reg->data, R_BP_PROT_EXEC) != NULL; + has_bp = r_bp_get_in (dbg->bp, reg->data, R_BP_PROT_EXEC); if (has_bp) { eprintf ("hit breakpoint at: 0x%" PFMT64x " cnum: %d\n", reg->data, reg->cnum); r_debug_goto_cnum (dbg, reg->cnum); @@ -1409,7 +1409,7 @@ static int r_debug_continue_until_internal(RDebug *dbg, ut64 addr, bool block) { return false; } // Check if there was another breakpoint set at addr - bool has_bp = r_bp_get_in (dbg->bp, addr, R_BP_PROT_EXEC) != NULL; + bool has_bp = r_bp_get_in (dbg->bp, addr, R_BP_PROT_EXEC); if (!has_bp) { r_bp_add_sw (dbg->bp, addr, dbg->bpsize, R_BP_PROT_EXEC); } @@ -1459,7 +1459,7 @@ R_API bool r_debug_continue_back(RDebug *dbg) { if (reg->cnum >= dbg->session->cnum) { continue; } - has_bp = r_bp_get_in (dbg->bp, reg->data, R_BP_PROT_EXEC) != NULL; + has_bp = r_bp_get_in (dbg->bp, reg->data, R_BP_PROT_EXEC); if (has_bp) { cnum = reg->cnum; eprintf ("hit breakpoint at: 0x%" PFMT64x " cnum: %d\n", reg->data, reg->cnum); diff --git a/libr/debug/dreg.c b/libr/debug/dreg.c index 208107e835..16980cafac 100644 --- a/libr/debug/dreg.c +++ b/libr/debug/dreg.c @@ -313,7 +313,7 @@ R_API bool r_debug_reg_set(RDebug *dbg, const char *name, ut64 num) { r_reg_set_value (dbg->reg, ri, num); r_debug_reg_sync (dbg, R_REG_TYPE_ALL, true); } - return (ri != NULL); + return (ri); } R_API ut64 r_debug_reg_get(RDebug *dbg, const char *name) { diff --git a/libr/debug/p/bfvm.c b/libr/debug/p/bfvm.c index 3f0ea2ac85..f49b640975 100644 --- a/libr/debug/p/bfvm.c +++ b/libr/debug/p/bfvm.c @@ -103,14 +103,14 @@ R_API ut8 bfvm_get(BfvmCPU *c) { R_API void bfvm_inc(BfvmCPU *c) { ut8 *mem = bfvm_get_ptr (c); - if (mem != NULL) { + if (mem) { mem[0]++; } } R_API void bfvm_dec(BfvmCPU *c) { ut8 *mem = bfvm_get_ptr (c); - if (mem != NULL) { + if (mem) { mem[0]--; } } diff --git a/libr/debug/p/native/bsd/bsd_debug.c b/libr/debug/p/native/bsd/bsd_debug.c index 89c0cfe943..ebf5493f66 100644 --- a/libr/debug/p/native/bsd/bsd_debug.c +++ b/libr/debug/p/native/bsd/bsd_debug.c @@ -49,7 +49,7 @@ static void addr_to_string(struct sockaddr_storage *ss, char *buffer, int buflen case AF_INET6: sin6 = (struct sockaddr_in6 *)ss; if (inet_ntop (AF_INET6, &sin6->sin6_addr, buffer2, - sizeof (buffer2)) != NULL) { + sizeof (buffer2))) { snprintf (buffer, buflen, "%s.%d", buffer2, ntohs (sin6->sin6_port)); } else { diff --git a/libr/debug/p/native/bt/generic_x86.c b/libr/debug/p/native/bt/generic_x86.c index 76b7348c18..11beafdaba 100644 --- a/libr/debug/p/native/bt/generic_x86.c +++ b/libr/debug/p/native/bt/generic_x86.c @@ -60,7 +60,7 @@ static RList *backtrace_x86_32_anal(RDebug *dbg, ut64 at) { eip = r_reg_get_value (reg, r_reg_get (reg, "eip", R_REG_TYPE_GPR)); fcn = r_anal_get_fcn_in (dbg->anal, eip, R_ANAL_FCN_TYPE_NULL); - if (fcn != NULL) { + if (fcn) { frame = R_NEW0 (RDebugFrame); frame->addr = eip; frame->size = 0; diff --git a/libr/debug/p/native/w32.c b/libr/debug/p/native/w32.c index 9697072911..84c65d41a0 100644 --- a/libr/debug/p/native/w32.c +++ b/libr/debug/p/native/w32.c @@ -25,9 +25,9 @@ static HANDLE w32_t2h(pid_t tid) { #endif inline static int w32_h2t(HANDLE h) { - if (w32_GetThreadId != NULL) // >= Windows Vista + if (w32_GetThreadId) // >= Windows Vista return w32_GetThreadId (h); - if (w32_GetProcessId != NULL) // >= Windows XP1 + if (w32_GetProcessId) // >= Windows XP1 return w32_GetProcessId (h); return (int)(size_t)h; // XXX broken } @@ -362,7 +362,7 @@ int w32_dbg_wait(RDebug *dbg, int pid) { case UNLOAD_DLL_DEBUG_EVENT: //eprintf ("(%d) Unloading library at %p\n", pid, de.u.UnloadDll.lpBaseOfDll); lstLibPtr = (PLIB_ITEM)r_debug_findlib (de.u.UnloadDll.lpBaseOfDll); - if (lstLibPtr != NULL) { + if (lstLibPtr) { lstLibPtr->hFile = (HANDLE)-1; } else { r_debug_lstLibAdd (pid, de.u.UnloadDll.lpBaseOfDll, (HANDLE)-1, "not cached"); diff --git a/libr/debug/p/native/windows/windows_debug.c b/libr/debug/p/native/windows/windows_debug.c index c509a13d5d..d3c7c744e4 100644 --- a/libr/debug/p/native/windows/windows_debug.c +++ b/libr/debug/p/native/windows/windows_debug.c @@ -188,7 +188,7 @@ static int __get_avx(HANDLE th, ut128 xmm[16], ut128 ymm[16]) { ymm[index].Low = 0; xmm[index].Low = 0; } - if (newxmm != NULL) { + if (newxmm) { for (index = 0; index < nregs; index++) { xmm[index].High = newxmm[index].High; xmm[index].Low = newxmm[index].Low; diff --git a/libr/debug/p/native/windows/windows_message.c b/libr/debug/p/native/windows/windows_message.c index 33acb23ea2..c4a601dfed 100644 --- a/libr/debug/p/native/windows/windows_message.c +++ b/libr/debug/p/native/windows/windows_message.c @@ -359,7 +359,7 @@ static RList *__get_windows(RDebug *dbg) { } r_list_push (windows, win); } - } while (hCurWnd != NULL); + } while (hCurWnd); return windows; } diff --git a/libr/egg/egg.c b/libr/egg/egg.c index 48f5a500a7..27fade5209 100644 --- a/libr/egg/egg.c +++ b/libr/egg/egg.c @@ -345,7 +345,7 @@ R_API bool r_egg_assemble_asm(REgg *egg, char **asm_list) { } } free (code); - bool ret = (asmcode != NULL); + bool ret = (asmcode); r_asm_code_free (asmcode); return ret; } diff --git a/libr/egg/rlcc/rlcc.c b/libr/egg/rlcc/rlcc.c index f918f16c5c..a77a98e78d 100644 --- a/libr/egg/rlcc/rlcc.c +++ b/libr/egg/rlcc/rlcc.c @@ -185,7 +185,7 @@ int main(int argc, char **argv) { Vartype, Typeident, Decls, Args, Body, Comment, Linecomment, Asm, Procedure, CProcedure, Sigdef, Sigbody, Includes, Smallc, NULL); - if (err != NULL) { + if (err) { mpc_err_print (err); mpc_err_delete (err); return 1; diff --git a/libr/io/io_fd.c b/libr/io/io_fd.c index 02739d2e2b..fb3745c5ee 100644 --- a/libr/io/io_fd.c +++ b/libr/io/io_fd.c @@ -110,7 +110,7 @@ R_API bool r_io_use_fd(RIO* io, int fd) { r_return_val_if_fail (io, false); if (!io->desc) { io->desc = r_io_desc_get (io, fd); - return io->desc != NULL; + return io->desc; } if (io->desc->fd != fd) { RIODesc* desc; diff --git a/libr/io/io_map.c b/libr/io/io_map.c index cf8e457f55..4d82ee43b5 100644 --- a/libr/io/io_map.c +++ b/libr/io/io_map.c @@ -114,7 +114,7 @@ R_API bool r_io_map_exists(RIO *io, RIOMap *map) { // check if a map with specified id exists R_API bool r_io_map_exists_for_id(RIO *io, ut32 id) { r_return_val_if_fail (io && io->maps, false); - return r_io_map_get (io, id) != NULL; + return r_io_map_get (io, id); } R_API RIOMap* r_io_map_get(RIO *io, ut32 id) { diff --git a/libr/io/p/io_ar.c b/libr/io/p/io_ar.c index ae58ebd7b2..9bc8b3f0ad 100644 --- a/libr/io/p/io_ar.c +++ b/libr/io/p/io_ar.c @@ -20,7 +20,7 @@ static const char *r_io_get_individual_schema(const char *file) { static bool r_io_ar_plugin_open(RIO *io, const char *file, bool many) { r_return_val_if_fail (io && file, false); if (many) { - return (r_io_get_individual_schema (file) != NULL); + return (r_io_get_individual_schema (file)); } return !strncmp ("ar://", file, 5) || !strncmp ("lib://", file, 6); } diff --git a/libr/io/p/io_bfdbg.c b/libr/io/p/io_bfdbg.c index e8418b2682..41148abb2e 100644 --- a/libr/io/p/io_bfdbg.c +++ b/libr/io/p/io_bfdbg.c @@ -178,7 +178,7 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) { } mal->size = (ut32)rlen; mal->buf = malloc (mal->size+1); - if (mal->buf != NULL) { + if (mal->buf) { memcpy (mal->buf, out, rlen); free (out); return r_io_desc_new (io, &r_io_plugin_bfdbg, diff --git a/libr/io/p/io_mmap.c b/libr/io/p/io_mmap.c index ffe01524f0..1d0f0ffd26 100644 --- a/libr/io/p/io_mmap.c +++ b/libr/io/p/io_mmap.c @@ -45,7 +45,7 @@ static bool r_io_mmap_refresh_buf(RIOMMapFileObj *mmo) { if (mmo->buf) { r_io_mmap_seek (io, mmo, cur, SEEK_SET); } - return mmo->buf != NULL; + return mmo->buf; } static void r_io_mmap_free(RIOMMapFileObj *mmo) { diff --git a/libr/io/p/io_rap.c b/libr/io/p/io_rap.c index 017549d2f3..c4057e3569 100644 --- a/libr/io/p/io_rap.c +++ b/libr/io/p/io_rap.c @@ -32,7 +32,7 @@ static int __rap_read(RIO *io, RIODesc *fd, ut8 *buf, int count) { static bool __rap_close(RIODesc *fd) { int ret = false; if (RIORAP_IS_VALID (fd)) { - if (RIORAP_FD (fd) != NULL) { + if (RIORAP_FD (fd)) { RIORap *r = fd->data; if (r && fd->fd != -1) { if (r->fd) { diff --git a/libr/io/p/io_zip.c b/libr/io/p/io_zip.c index ea0e969673..8830812723 100644 --- a/libr/io/p/io_zip.c +++ b/libr/io/p/io_zip.c @@ -262,7 +262,7 @@ RIOZipFileObj* r_io_zip_alloc_zipfileobj(const char *archivename, const char *fi for (i = 0; i < num_entries; i++) { zip_stat_init (&sb); zip_stat_index (zipArch, i, 0, &sb); - if (sb.name != NULL) { + if (sb.name) { if (strcmp (sb.name, filename) == 0) { zfo = r_io_zip_create_new_file ( archivename, filename, &sb, diff --git a/libr/lang/p/pipe.c b/libr/lang/p/pipe.c index 7573810871..849b1a676a 100644 --- a/libr/lang/p/pipe.c +++ b/libr/lang/p/pipe.c @@ -289,7 +289,7 @@ beach: free (r2pipe_var); free (r2pipe_paz); free (r2pipe_paz_); - return hproc != NULL; + return hproc; #endif #endif } diff --git a/libr/magic/apprentice.c b/libr/magic/apprentice.c index bd1b2c0e99..36f7d676c3 100644 --- a/libr/magic/apprentice.c +++ b/libr/magic/apprentice.c @@ -505,7 +505,7 @@ static void load_b(RMagic *ms, int action, const char *data, int *errs, struct r char line[BUFSIZ]; size_t lineno = 0; /* read and parse this file */ - for (ms->line = 1; (data = bgets (line, sizeof (line), data)) != NULL; ms->line++) { + for (ms->line = 1; (data = bgets (line, sizeof (line), data)); ms->line++) { size_t len = strlen (line); if (len == 0) { /* null line, garbage, etc */ continue; @@ -553,7 +553,7 @@ static void load_1(RMagic *ms, int action, const char *file, int *errs, struct r return; } /* read and parse this file */ - for (ms->line = 1; fgets (line, sizeof (line), f) != NULL; ms->line++) { + for (ms->line = 1; fgets (line, sizeof (line), f); ms->line++) { size_t len = strlen (line); if (len == 0) { /* null line, garbage, etc */ continue; @@ -1983,7 +1983,7 @@ static char *mkdbname(const char *fn, int strip) { int fnlen, extlen; if (strip) { const char *p; - if ((p = strrchr (fn, '/')) != NULL) { + if ((p = strrchr (fn, '/'))) { fn = ++p; } } diff --git a/libr/magic/fsmagic.c b/libr/magic/fsmagic.c index 60c96df276..40a9065c14 100644 --- a/libr/magic/fsmagic.c +++ b/libr/magic/fsmagic.c @@ -256,7 +256,7 @@ int file_fsmagic(struct r_magic_set *ms, const char *fn, struct stat *sb) { ms->flags &= R_MAGIC_SYMLINK; p = r_magic_file(ms, buf); ms->flags |= R_MAGIC_SYMLINK; - return p != NULL ? 1 : -1; + return p ? 1 : -1; } else { /* just print what it points to */ if (file_printf (ms, "symbolic link to `%s'", buf) == -1) return -1; diff --git a/libr/magic/magic.c b/libr/magic/magic.c index f2dd34da49..70d2b54dbb 100644 --- a/libr/magic/magic.c +++ b/libr/magic/magic.c @@ -255,13 +255,13 @@ R_API bool r_magic_load(RMagic* ms, const char *magicfile) { R_API bool r_magic_compile(RMagic *ms, const char *magicfile) { struct mlist *ml = file_apprentice (ms, magicfile, strlen (magicfile), FILE_COMPILE); free_mlist (ml); - return ml != NULL; + return ml; } R_API bool r_magic_check(RMagic *ms, const char *magicfile) { struct mlist *ml = file_apprentice (ms, magicfile, strlen (magicfile), FILE_CHECK); free_mlist (ml); - return ml != NULL; + return ml; } R_API const char* r_magic_descriptor(RMagic *ms, int fd) { diff --git a/libr/parse/c/tccgen.c b/libr/parse/c/tccgen.c index 075934786d..07a13b42d9 100644 --- a/libr/parse/c/tccgen.c +++ b/libr/parse/c/tccgen.c @@ -722,7 +722,7 @@ add_tstr: type_to_str (s1, buf, buf_size, &s->type, varstr); pstrcat (buf, buf_size, "("); sa = s->next; - while (sa != NULL) { + while (sa) { type_to_str (s1, buf1, sizeof (buf1), &sa->type, NULL); pstrcat (buf, buf_size, buf1); sa = sa->next; @@ -1168,7 +1168,7 @@ do_decl: } if (v == 0 && is_structured (&type1)) { ass = type1.ref; - while ((ass = ass->next) != NULL) { + while ((ass = ass->next)) { ss = sym_push (s1, ass->v, &ass->type, 0, offset + ass->c); if (!ss) { return; @@ -2092,7 +2092,7 @@ tok_identifier: s = s1->vtop->type.ref; /* find field */ s1->tok |= SYM_FIELD; - while ((s = s->next) != NULL) { + while ((s = s->next)) { if (s->v == s1->tok) { break; } @@ -2923,7 +2923,7 @@ static void func_decl_list(TCCState *s1, Sym *func_sym) { /* find parameter in function parameter list */ s = func_sym; found = 0; - while ((s = s->next) != NULL) { + while ((s = s->next)) { if ((s->v & ~SYM_FIELD) == v) { found = 1; break; @@ -3043,7 +3043,7 @@ static int decl0(TCCState *s1, int l, int is_for_loop_init) { /* reject abstract declarators in function definition */ sym = type.ref; if (sym) { - while ((sym = sym->next) != NULL) + while ((sym = sym->next)) if (!(sym->v & ~SYM_FIELD)) { expect (s1, "identifier6"); } diff --git a/libr/parse/c/tccpp.c b/libr/parse/c/tccpp.c index a1a588fc5f..2f8fb1d063 100644 --- a/libr/parse/c/tccpp.c +++ b/libr/parse/c/tccpp.c @@ -2995,7 +2995,7 @@ static void macro_subst(TCCState *s1, TokenString *tok_str, Sym **nested_list, goto no_subst; } s = define_find (s1, t); - if (s != NULL) { + if (s) { /* if nested substitution, do nothing */ if (sym_find2 (*nested_list, t)) { /* and mark it as TOK_NOSUBST, so it doesn't get subst'd again */ diff --git a/libr/parse/p/parse_6502_pseudo.c b/libr/parse/p/parse_6502_pseudo.c index c1ab8a325a..fd29b56f51 100644 --- a/libr/parse/p/parse_6502_pseudo.c +++ b/libr/parse/p/parse_6502_pseudo.c @@ -74,7 +74,7 @@ static int replace(int argc, const char *argv[], char *newstr, ADDR_TYPE type) { return false; } - for (i = 0; ops[i].op != NULL; i++) { + for (i = 0; ops[i].op; i++) { if (ops[i].narg) { if (argc - 1 != ops[i].narg) { continue; @@ -84,7 +84,7 @@ static int replace(int argc, const char *argv[], char *newstr, ADDR_TYPE type) { for (j = k = 0; ops[i].str[j] != '\0'; j++, k++) { if (IS_DIGIT(ops[i].str[j])) { const char *w = argv[ops[i].str[j] - '0']; - if (w != NULL) { + if (w) { strcpy(newstr + k, w); k += strlen(w) - 1; } diff --git a/libr/parse/p/parse_att2intel.c b/libr/parse/p/parse_att2intel.c index 5a3c7f6204..f58cddb4f8 100644 --- a/libr/parse/p/parse_att2intel.c +++ b/libr/parse/p/parse_att2intel.c @@ -35,13 +35,13 @@ static int replace(int argc, const char *argv[], char *newstr) { { NULL } }; - for (i = 0; ops[i].op != NULL; i++) { + for (i = 0; ops[i].op; i++) { if (!strcmp (ops[i].op, argv[0])) { - if (newstr != NULL) { + if (newstr) { for (j = k = 0; ops[i].str[j] != '\0'; j++, k++) { if (ops[i].str[j] >= '0' && ops[i].str[j] <= '9') { const char *w = argv[ops[i].str[j] - '0']; - if (w != NULL) { + if (w) { strcpy (newstr + k, w); k += strlen (w) - 1; } @@ -56,7 +56,7 @@ static int replace(int argc, const char *argv[], char *newstr) { } /* TODO: this is slow */ - if (newstr != NULL) { + if (newstr) { newstr[0] = '\0'; for (i=0; i= 'A' && ops[i].str[j] <= 'J') { const char *w = argv[ops[i].str[j] - '@']; - if (w != NULL) { + if (w) { strcpy (newstr + k, w); k += strlen(w) - 1; } @@ -121,7 +121,7 @@ static bool replace(int argc, const char *argv[], char *newstr) { } /* TODO: this is slow */ - if (newstr != NULL) { + if (newstr) { newstr[0] = '\0'; for (i = 0; i < argc; i++) { strcat (newstr, argv[i]); diff --git a/libr/parse/p/parse_dalvik_pseudo.c b/libr/parse/p/parse_dalvik_pseudo.c index 3fee4caf7e..9ce53eb7a8 100644 --- a/libr/parse/p/parse_dalvik_pseudo.c +++ b/libr/parse/p/parse_dalvik_pseudo.c @@ -193,13 +193,13 @@ static int replace(int argc, const char *argv[], char *newstr) { { NULL } }; - for (i=0; ops[i].op != NULL; i++) { + for (i=0; ops[i].op; i++) { if (!strcmp (ops[i].op, argv[0])) { - if (newstr != NULL) { + if (newstr) { for (j=k=0;ops[i].str[j]!='\0';j++,k++) { if (ops[i].str[j]>='1' && ops[i].str[j]<='9') { const char *w = argv[ ops[i].str[j]-'0' ]; - if (w != NULL) { + if (w) { strcpy (newstr+k, w); k += strlen(w)-1; } @@ -214,7 +214,7 @@ static int replace(int argc, const char *argv[], char *newstr) { } /* TODO: this is slow */ - if (newstr != NULL) { + if (newstr) { newstr[0] = '\0'; for (i=0; i= 'A' && ops[i].str[j] <= 'J') { const char *w = argv[ops[i].str[j] - '@']; - if (w != NULL) { + if (w) { strcpy (newstr + k, w); k += strlen(w) - 1; } @@ -145,7 +145,7 @@ static int replace(int argc, const char *argv[], char *newstr) { } /* TODO: this is slow */ - if (newstr != NULL) { + if (newstr) { newstr[0] = '\0'; for (i = 0; i < argc; i++) { strcat (newstr, argv[i]); diff --git a/libr/parse/p/parse_z80_pseudo.c b/libr/parse/p/parse_z80_pseudo.c index 8ca35541da..098f909400 100644 --- a/libr/parse/p/parse_z80_pseudo.c +++ b/libr/parse/p/parse_z80_pseudo.c @@ -42,13 +42,13 @@ static int replace(int argc, const char *argv[], char *newstr) { { NULL } }; - for (i=0; ops[i].op != NULL; i++) { + for (i=0; ops[i].op; i++) { if (!strcmp (ops[i].op, argv[0])) { - if (newstr != NULL) { + if (newstr) { for (j=k=0;ops[i].str[j]!='\0';j++,k++) { if (ops[i].str[j]>='1' && ops[i].str[j]<='9') { const char *w = argv[ ops[i].str[j]-'0' ]; - if (w != NULL) { + if (w) { strcpy (newstr+k, w); k += strlen(w)-1; } @@ -63,7 +63,7 @@ static int replace(int argc, const char *argv[], char *newstr) { } /* TODO: this is slow */ - if (newstr != NULL) { + if (newstr) { newstr[0] = '\0'; for (i=0; inext != NULL; p = p->next) { + for (p = n; p->next; p = p->next) { ; } p->next = (fnditem*) malloc (sizeof (fnditem)); @@ -48,7 +48,7 @@ static void add_fi(fnditem* n, unsigned char* blk, int patlen) { static int is_fi_present(fnditem* n, unsigned char* blk , int patlen) { fnditem* p; - for (p = n; p->next != NULL; p = p->next) { + for (p = n; p->next; p = p->next) { if (!memcmp (blk, p->str, patlen)) { return true; } diff --git a/libr/search/keyword.c b/libr/search/keyword.c index de85b81b21..c2c6830ac8 100644 --- a/libr/search/keyword.c +++ b/libr/search/keyword.c @@ -172,11 +172,11 @@ R_API RSearchKeyword* r_search_keyword_new_hex(const char *kwstr, const char *bm R_API RSearchKeyword* r_search_keyword_new_hexmask(const char *kwstr, const char *data) { RSearchKeyword *ks = NULL; ut8 *kw, *bm; - if (kwstr != NULL) { + if (kwstr) { int len = strlen (kwstr); kw = malloc (len + 4); bm = malloc (len + 4); - if (kw != NULL && bm != NULL) { + if (kw && bm) { len = r_hex_str2binmask (kwstr, (ut8*)kw, (ut8*)bm); if (len < 0) { len = -len - 1; diff --git a/libr/util/calc.c b/libr/util/calc.c index 319519a75f..5a7cafbaa3 100644 --- a/libr/util/calc.c +++ b/libr/util/calc.c @@ -121,7 +121,7 @@ static RNumCalcValue term(RNum *num, RNumCalc *nc, int get) { left = Nmod (left, d); } else if (nc->curr_tok == RNCDIV) { RNumCalcValue d = prim (num, nc, 1); - if (num != NULL && (!d.d || !d.n)) { + if (num && (!d.d || !d.n)) { num->dbz = 1; return d; } diff --git a/libr/util/format.c b/libr/util/format.c index 9038d9437e..341f8586ee 100644 --- a/libr/util/format.c +++ b/libr/util/format.c @@ -1,9 +1,11 @@ -/* radare - LGPL - Copyright 2007-2021 - pancake & Skia */ +/* radare - LGPL - Copyright 2007-2022 - pancake & Skia */ -#include "r_cons.h" -#include "r_util.h" -#include "r_util/r_print.h" -#include "r_reg.h" +#include +#include +#include +#include + +// W T F :D #define NOPTR 0 #define PTRSEEK 1 #define PTRBACK 2 @@ -2450,7 +2452,7 @@ R_API int r_print_format(RPrint *p, ut64 seek, const ut8* b, const int len, p->cb_printf ("*"); } p->cb_printf ("\",\"offset\":%"PFMT64d",\"value\":", - isptr? (seek + nexti - (p->bits / 8)) : seek + i); + (isptr)? (seek + nexti - (p->bits / 8)) : seek + i); } /* c struct */ @@ -2539,14 +2541,9 @@ R_API int r_print_format(RPrint *p, ut64 seek, const ut8* b, const int len, if (MUSTSET) { eprintf ("Set val not implemented yet for disassembler!\n"); } - if (isptr) { - if (p->bits == 64) { - i += r_print_format_disasm (p, addr64, size); - } else { - i += r_print_format_disasm (p, addr, size); - } - } else { - i += r_print_format_disasm (p, seeki, size); + { + ut64 at = isptr? ((p->bits == 64)? addr64: addr): seeki; + i += r_print_format_disasm (p, at, size); } break; case 'o': diff --git a/libr/util/idpool.c b/libr/util/idpool.c index 8572045c08..68487133eb 100644 --- a/libr/util/idpool.c +++ b/libr/util/idpool.c @@ -176,7 +176,7 @@ R_API bool r_id_storage_get_highest(RIDStorage *storage, ut32 *id) { if (storage->size > 0) { for (i = storage->size - 1; !storage->data[i] && i > 0; i--); *id = i; - return storage->data[i] != NULL; + return storage->data[i]; } // *id = i; return false; diff --git a/libr/util/lib.c b/libr/util/lib.c index c2fb584eae..5e85e712e3 100644 --- a/libr/util/lib.c +++ b/libr/util/lib.c @@ -221,7 +221,7 @@ R_API int r_lib_close(RLib *lib, const char *file) { } free (p->file); r_list_delete (lib->plugins, iter); - if (file != NULL) { + if (file) { return ret; } } diff --git a/libr/util/new_rbtree.c b/libr/util/new_rbtree.c index 2b720a15db..3a68079566 100644 --- a/libr/util/new_rbtree.c +++ b/libr/util/new_rbtree.c @@ -111,7 +111,7 @@ static RRBNode *_node_new(void *data, RRBNode *parent) { return node; } -#define IS_RED(n) ((n) != NULL && (n)->red == 1) +#define IS_RED(n) ((n) && (n)->red == 1) static RRBNode *_rot_once(RRBNode *root, int dir) { r_return_val_if_fail (root, NULL); diff --git a/libr/util/qrcode.c b/libr/util/qrcode.c index 4bede0e293..05c447b4ef 100644 --- a/libr/util/qrcode.c +++ b/libr/util/qrcode.c @@ -286,7 +286,8 @@ static int getTextProperties(const char *text, bool *isNumeric, bool *isAlphanum char c = *p; if (c < '0' || c > '9') { *isNumeric = false; - *isAlphanumeric &= strchr (ALPHANUMERIC_CHARSET, c) != NULL; + bool is_alpha = strchr (ALPHANUMERIC_CHARSET, c); + *isAlphanumeric &= is_alpha; } } diff --git a/libr/util/regex/engine.c b/libr/util/regex/engine.c index 0315429b0d..49254f7e80 100644 --- a/libr/util/regex/engine.c +++ b/libr/util/regex/engine.c @@ -135,7 +135,7 @@ static int matcher(struct re_guts *g, char *string, size_t nmatch, RRegexMatch p } /* prescreening; this does wonders for this rather slow code */ - if (g->must != NULL) { + if (g->must) { for (dp = start; dp < stop; dp++) { if (*dp == g->must[0] && stop - dp >= g->mlen && !memcmp (dp, g->must, (size_t)g->mlen)) { break; @@ -236,7 +236,7 @@ static int matcher(struct re_guts *g, char *string, size_t nmatch, RRegexMatch p break; } for (;;) { - if (dp != NULL || endp <= m->coldp) { + if (dp || endp <= m->coldp) { break; /* defeat */ } endp = slow (m, m->coldp, endp - 1, gf, gl); @@ -256,7 +256,7 @@ static int matcher(struct re_guts *g, char *string, size_t nmatch, RRegexMatch p #endif dp = backref (m, m->coldp, endp, gf, gl, (sopno)0, 0); } - if (dp != NULL || dp != endp) { /* found a shorter one */ + if (dp || dp != endp) { /* found a shorter one */ break; } @@ -367,7 +367,7 @@ dissect(struct match *m, char *start, char *stop, sopno startst, sopno stopst) ssub = ss + 1; esub = es - 1; /* did innards match? */ - if (slow(m, sp, rest, ssub, esub) != NULL) { + if (slow(m, sp, rest, ssub, esub)) { dp = dissect(m, sp, rest, ssub, esub); if (dp != rest) return NULL; } else if (sp != rest) return NULL; @@ -378,7 +378,7 @@ dissect(struct match *m, char *start, char *stop, sopno startst, sopno stopst) for (;;) { /* how long could this one be? */ rest = slow(m, sp, stp, ss, es); - if (rest != NULL) { /* it did match */ + if (rest) { /* it did match */ /* could the rest match the rest? */ tail = slow(m, rest, stop, es, stopst); if (tail == stop) @@ -634,7 +634,7 @@ backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst, } for (;;) { /* find first matching branch */ dp = backref(m, sp, stop, ssub, esub, lev, rec); - if (dp != NULL) + if (dp) return dp; /* that one missed, try next one */ if (OP (m->g->strip[esub]) == O_CH) @@ -659,7 +659,7 @@ backref(struct match *m, char *start, char *stop, sopno startst, sopno stopst, offsave = m->pmatch[i].rm_so; m->pmatch[i].rm_so = sp - m->offp; dp = backref(m, sp, stop, ss+1, stopst, lev, rec); - if (dp != NULL) + if (dp) return(dp); m->pmatch[i].rm_so = offsave; return(NULL); diff --git a/libr/util/regex/regcomp.c b/libr/util/regex/regcomp.c index 4f507d93a1..d38867be9f 100644 --- a/libr/util/regex/regcomp.c +++ b/libr/util/regex/regcomp.c @@ -802,7 +802,7 @@ static void p_bracket(struct parse *p) { } } } - if (cs->multis != NULL) { + if (cs->multis) { mccase (p, cs); } } @@ -819,7 +819,7 @@ static void p_bracket(struct parse *p) { if (p->g->cflags & R_REGEX_NEWLINE) { CHsub (cs, '\n'); } - if (cs->multis != NULL) { + if (cs->multis) { mcinvert (p, cs); } } @@ -914,7 +914,7 @@ static void p_b_cclass(struct parse *p, cset *cs) { NEXT (); } len = p->next - sp; - for (cp = cclasses; cp->name != NULL; cp++) { + for (cp = cclasses; cp->name; cp++) { if (strncmp (cp->name, sp, len) == 0 && cp->name[len] == '\0') { break; } @@ -984,7 +984,7 @@ p_b_coll_elem(struct parse *p, return(0); } len = p->next - sp; - for (cp = cnames; cp->name != NULL; cp++) { + for (cp = cnames; cp->name; cp++) { if (strncmp (cp->name, sp, len) == 0 && cp->name[len] == '\0') { return (cp->code); /* known name */ } diff --git a/libr/util/str.c b/libr/util/str.c index 04b414a720..d605c61c36 100644 --- a/libr/util/str.c +++ b/libr/util/str.c @@ -1865,8 +1865,8 @@ R_API char *r_str_format_msvc_argv(size_t argc, const char **argv) { r_strbuf_append (&sb, " "); } const char *arg = argv[i]; - bool must_escape = strchr (arg, '\"') != NULL; - bool must_quote = strpbrk (arg, " \t") != NULL || !*arg; + bool must_escape = strchr (arg, '\"'); + bool must_quote = strpbrk (arg, " \t") || !*arg; if (!must_escape && must_quote && *arg && arg[strlen (arg) - 1] == '\\') { // if the last char is a bs and we would quote it, we must also escape must_escape = true; diff --git a/libr/util/str_constpool.c b/libr/util/str_constpool.c index 15ab681b7f..12e8477b22 100644 --- a/libr/util/str_constpool.c +++ b/libr/util/str_constpool.c @@ -8,7 +8,7 @@ static void kv_fini(HtPPKv *kv) { R_API bool r_str_constpool_init(RStrConstPool *pool) { pool->ht = ht_pp_new (NULL, kv_fini, NULL); - return pool->ht != NULL; + return pool->ht; } R_API void r_str_constpool_fini(RStrConstPool *pool) { diff --git a/libr/util/table.c b/libr/util/table.c index 688ec4a441..7200eada2d 100644 --- a/libr/util/table.c +++ b/libr/util/table.c @@ -722,7 +722,7 @@ R_API void r_table_filter(RTable *t, int nth, int op, const char *un) { match = strstr (nn, un) == NULL; break; case '~': - match = strstr (nn, un) != NULL; + match = strstr (nn, un); break; case 's': match = strlen (nn) == atoi (un); diff --git a/libr/util/unum.c b/libr/util/unum.c index a6d6a31589..4ec5f0dd8b 100644 --- a/libr/util/unum.c +++ b/libr/util/unum.c @@ -513,7 +513,7 @@ R_API ut64 r_num_math(RNum *num, const char *str) { p = group + 1; if (r_str_delta (p, '(', ')') < 0) { char *p2 = strchr (p, '('); - if (p2 != NULL) { + if (p2) { *p2 = '\0'; ret = r_num_op (op, ret, r_num_math_internal (num, p)); ret = r_num_op (op, ret, r_num_math (num, p2 + 1)); diff --git a/shlr/gdb/src/gdbclient/xml.c b/shlr/gdb/src/gdbclient/xml.c index e58b90cab4..ff4154706d 100644 --- a/shlr/gdb/src/gdbclient/xml.c +++ b/shlr/gdb/src/gdbclient/xml.c @@ -753,28 +753,28 @@ static RList *_extract_regs(char *regstr, RList *flags, char *pc_alias) { // To parse features of other architectures refer to: // https://sourceware.org/gdb/onlinedocs/gdb/Standard-Target-Features.html#Standard-Target-Features // - x86 - if ((tmp1 = strstr (regstr, "core")) != NULL && tmp1 < feature_end) { + if ((tmp1 = strstr (regstr, "core")) && tmp1 < feature_end) { typegroup = "gpr"; - } else if ((tmp1 = strstr (regstr, "segments")) != NULL && tmp1 < feature_end) { + } else if ((tmp1 = strstr (regstr, "segments")) && tmp1 < feature_end) { typegroup = "seg"; - } else if ((tmp1 = strstr (regstr, "linux")) != NULL && tmp1 < feature_end) { + } else if ((tmp1 = strstr (regstr, "linux")) && tmp1 < feature_end) { typegroup = "gpr"; // Includes avx.512 - } else if ((tmp1 = strstr (regstr, "avx")) != NULL && tmp1 < feature_end) { + } else if ((tmp1 = strstr (regstr, "avx")) && tmp1 < feature_end) { typegroup = "ymm"; - } else if ((tmp1 = strstr (regstr, "mpx")) != NULL && tmp1 < feature_end) { + } else if ((tmp1 = strstr (regstr, "mpx")) && tmp1 < feature_end) { typegroup = "seg"; // - arm - } else if ((tmp1 = strstr (regstr, "m-profile")) != NULL && tmp1 < feature_end) { + } else if ((tmp1 = strstr (regstr, "m-profile")) && tmp1 < feature_end) { typegroup = "gpr"; - } else if ((tmp1 = strstr (regstr, "pfe")) != NULL && tmp1 < feature_end) { + } else if ((tmp1 = strstr (regstr, "pfe")) && tmp1 < feature_end) { typegroup = "fpu"; - } else if ((tmp1 = strstr (regstr, "vfp")) != NULL && tmp1 < feature_end) { + } else if ((tmp1 = strstr (regstr, "vfp")) && tmp1 < feature_end) { typegroup = "fpu"; - } else if ((tmp1 = strstr (regstr, "iwmmxt")) != NULL && tmp1 < feature_end) { + } else if ((tmp1 = strstr (regstr, "iwmmxt")) && tmp1 < feature_end) { typegroup = "xmm"; // -- Aarch64 - } else if ((tmp1 = strstr (regstr, "sve")) != NULL && tmp1 < feature_end) { + } else if ((tmp1 = strstr (regstr, "sve")) && tmp1 < feature_end) { typegroup = "ymm"; } else { typegroup = "gpr";