From c48d474fa834b4ff6bb4afd92962486f76e4b862 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Wed, 31 Oct 2018 08:46:22 +0000 Subject: [PATCH] Little code cleanups/var scope reductions --- libr/asm/arch/cr16/cr16_disas.c | 28 ---------------------------- libr/core/cbin.c | 4 ++-- 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/libr/asm/arch/cr16/cr16_disas.c b/libr/asm/arch/cr16/cr16_disas.c index edc7dc4778..c1e3f1ed59 100644 --- a/libr/asm/arch/cr16/cr16_disas.c +++ b/libr/asm/arch/cr16/cr16_disas.c @@ -90,11 +90,6 @@ static const char *ops_biti[] = { [0x2] = "tbit", }; -static inline ut8 cr16_get_opcode_biti(const ut8 instr) -{ - return (instr >> 6) & 0x3; -} - static inline ut8 cr16_get_opcode_low(const ut16 instr) { return (instr >> 9) & 0xF; @@ -139,14 +134,6 @@ static inline ut16 cr16_get_opcode_159_0(const ut16 opc) return (opc & 1) | ((opc >> 8) & 0xFE); } -static inline int cr16_check_biti_boundaries(const ut8 opcode) -{ - if (opcode >= sizeof(ops_biti)/sizeof(void*) || !ops_biti[opcode]) { - return -1; - } - return 0; -} - static inline int cr16_check_reg_boundaries(const ut8 reg) { if (reg >= sizeof(cr16_regs_names)/sizeof(void*) @@ -222,21 +209,6 @@ static inline int cr16_print_reg_med(struct cr16_cmd *cmd, ut16 med, ut8 reg) return 0; } -static inline int cr16_print_biti_opcode(struct cr16_cmd *cmd, ut16 instr) -{ - ut8 opcode = cr16_get_opcode_biti(instr); - - if (cr16_check_biti_boundaries(opcode)) { - return -1; - } - - snprintf(cmd->instr, CR16_INSTR_MAXLEN - 1, "%s%c", - ops_biti[opcode], - cr16_get_opcode_i(instr) ? 'w' : 'b'); - - return 0; -} - static inline int cr16_print_short_abs18(struct cr16_cmd *cmd, ut8 sh, ut32 abs) { snprintf(cmd->operands, CR16_INSTR_MAXLEN - 1, diff --git a/libr/core/cbin.c b/libr/core/cbin.c index 63c1c052e8..65b6f53e06 100644 --- a/libr/core/cbin.c +++ b/libr/core/cbin.c @@ -2529,8 +2529,6 @@ static int bin_fields(RCore *r, int mode, int va) { int i = 0; RBin *bin = r->bin; RBinFile *binfile = r_core_bin_cur (r); - ut64 size = binfile ? binfile->size : UT64_MAX; - ut64 baddr = r_bin_get_baddr (r->bin); if (!(fields = r_bin_get_fields (bin))) { return false; @@ -2548,6 +2546,8 @@ static int bin_fields(RCore *r, int mode, int va) { else if (IS_MODE_SET (mode)) { // XXX: Need more flags?? // this will be set even if the binary does not have an ehdr + ut64 size = binfile ? binfile->size : UT64_MAX; + ut64 baddr = r_bin_get_baddr (r->bin); int fd = r_core_file_cur_fd(r); r_io_section_add (r->io, 0, baddr, size, size, 7, "ehdr", 0, fd); }