From 363df75c06d41c88c9bc58a1bae8fa822a46b99f Mon Sep 17 00:00:00 2001 From: Richard Patel Date: Tue, 28 Jun 2022 02:49:42 +0200 Subject: [PATCH] Replace some instances of eprintf with R_LOG_ --- libr/anal/arch/8051/8051_ass.c | 2 +- libr/anal/arch/v850np/v850dis.c | 2 +- libr/anal/dwarf_process.c | 4 +-- libr/anal/esil.c | 8 ++--- libr/anal/esil_trace.c | 6 ++-- libr/anal/fcn.c | 18 +++++----- libr/anal/flirt.c | 4 +-- libr/anal/op.c | 2 +- libr/anal/p/anal_arm_cs.c | 2 +- libr/anal/p/anal_x86_cs.c | 2 +- libr/anal/p/capstone.inc | 2 +- libr/anal/rtti_itanium.c | 2 +- libr/anal/rtti_msvc.c | 12 +++---- libr/anal/sign.c | 34 +++++++++---------- libr/anal/var.c | 6 ++-- libr/asm/arch/pyc/opcode.c | 4 +-- libr/asm/arch/riscv/riscvasm.c | 6 ++-- .../arch/tms320/c55x_plus/c55plus_decode.c | 20 +++++------ libr/asm/asm.c | 30 ++++++++-------- libr/asm/p/asm_arm_cs.c | 2 +- libr/asm/p/asm_x86_nasm.c | 4 +-- libr/asm/p/asm_x86_nz.c | 24 ++++++------- libr/bin/bfile.c | 4 +-- libr/bin/bin.c | 4 +-- libr/bin/bobj.c | 2 +- libr/bin/dwarf.c | 2 +- libr/bin/format/bflt/bflt.c | 8 ++--- libr/bin/format/dex/dex.c | 2 +- libr/bin/format/dmp/dmp64.c | 20 +++++------ libr/bin/format/elf/elf.c | 4 +-- libr/bin/format/elf/elf_write.c | 4 +-- libr/bin/format/le/le.c | 2 +- libr/bin/format/mach0/dyldcache.c | 10 +++--- libr/bin/format/mach0/mach0.c | 4 +-- libr/bin/format/mz/mz.c | 16 ++++----- libr/bin/format/objc/mach0_classes.c | 4 +-- libr/bin/format/pe/pe.c | 26 +++++++------- libr/bin/format/pe/pemixed.c | 2 +- libr/bin/format/te/te.c | 4 +-- libr/bin/format/wasm/wasm.c | 4 +-- libr/bin/p/bin_cgc.c | 2 +- libr/bin/p/bin_dex.c | 22 ++++++------ libr/bin/p/bin_dyldcache.c | 4 +-- libr/bin/p/bin_elf.c | 2 +- libr/bin/p/bin_elf64.c | 2 +- libr/bin/p/bin_mach0.c | 6 ++-- libr/bin/p/bin_pe.c | 2 +- libr/bin/p/bin_symbols.c | 4 +-- libr/bin/p/bin_write_mach0.c | 4 +-- libr/bin/pdb/pdb.c | 20 +++++------ libr/bin/pdb/tpi.c | 2 +- libr/bp/bp.c | 4 +-- libr/cons/grep.c | 10 +++--- libr/cons/html.c | 2 +- libr/cons/hud.c | 2 +- libr/core/anal_objc.c | 4 +-- libr/core/anal_tp.c | 6 ++-- libr/core/blaze.c | 2 +- libr/core/canal.c | 34 +++++++++---------- libr/core/casm.c | 6 ++-- libr/core/cbin.c | 16 ++++----- libr/core/cconfig.c | 8 ++--- libr/core/cfile.c | 2 +- libr/core/cmd.c | 16 ++++----- libr/core/cmd_write.c | 2 +- libr/core/cplugin.c | 2 +- libr/core/esil2c.c | 2 +- libr/core/linux_heap_glibc.c | 10 +++--- libr/core/linux_heap_jemalloc.c | 16 ++++----- libr/core/p/core_java.c | 10 +++--- libr/core/project.c | 2 +- libr/core/rtr.c | 30 ++++++++-------- libr/core/rtr_http.c | 2 +- libr/core/rvc.c | 2 +- libr/core/vasm.c | 4 +-- libr/core/vmenus.c | 2 +- libr/core/yank.c | 6 ++-- libr/debug/debug.c | 6 ++-- libr/debug/dsession.c | 16 ++++----- libr/debug/p/debug_bf.c | 2 +- libr/debug/p/debug_bochs.c | 2 +- libr/debug/p/debug_gdb.c | 2 +- libr/debug/p/debug_native.c | 12 +++---- libr/debug/p/debug_rap.c | 2 +- libr/debug/p/native/linux/linux_coredump.c | 2 +- libr/debug/p/native/windows/windows_debug.c | 2 +- libr/debug/p/native/windows/windows_message.c | 2 +- libr/debug/p/native/xnu/trap_x86.c | 8 ++--- libr/debug/p/native/xnu/xnu_debug.c | 6 ++-- libr/debug/p/native/xnu/xnu_excthreads.c | 14 ++++---- libr/debug/plugin.c | 4 +-- libr/debug/snap.c | 6 ++-- libr/debug/trace.c | 12 +++---- libr/egg/egg.c | 6 ++-- libr/egg/egg_cfile.c | 6 ++-- libr/egg/egg_lang.c | 4 +-- libr/egg/emit_arm.c | 2 +- libr/egg/emit_esil.c | 2 +- libr/egg/emit_x86.c | 2 +- libr/io/io_cache.c | 2 +- libr/io/p/io_bochs.c | 2 +- libr/io/p/io_debug.c | 2 +- libr/io/p/io_procpid.c | 2 +- libr/io/p/io_ptrace.c | 2 +- libr/io/p/io_r2k_windows.c | 2 +- libr/io/p/io_self.c | 2 +- libr/io/p/io_winkd.c | 6 ++-- libr/io/p/io_xalz.c | 2 +- libr/io/p/io_zip.c | 4 +-- libr/parse/c/libtcc.c | 2 +- libr/search/keyword.c | 2 +- libr/socket/run.c | 6 ++-- libr/socket/socket.c | 4 +-- libr/socket/socket_rap_client.c | 6 ++-- libr/util/axml.c | 2 +- libr/util/file.c | 4 +-- libr/util/format.c | 4 +-- libr/util/punycode.c | 14 ++++---- libr/util/sandbox.c | 2 +- libr/util/str.c | 2 +- libr/util/sys.c | 2 +- libr/util/sys_sh.c | 4 +-- sys/lint.sh | 2 +- 123 files changed, 396 insertions(+), 396 deletions(-) diff --git a/libr/anal/arch/8051/8051_ass.c b/libr/anal/arch/8051/8051_ass.c index 4816fa8969..376ecb9a56 100644 --- a/libr/anal/arch/8051/8051_ass.c +++ b/libr/anal/arch/8051/8051_ass.c @@ -882,7 +882,7 @@ static bool mnem_jb(char const*const*arg, ut16 pc, ut8**out) { static bool mnem_jbc(char const*const*arg, ut16 pc, ut8**out) { ut8 cmp_addr; if (!address_bit (arg[0], &cmp_addr)) { - eprintf ("error during the assembly: address bit not found\n"); + R_LOG_ERROR ("error during the assembly: address bit not found"); return false; } diff --git a/libr/anal/arch/v850np/v850dis.c b/libr/anal/arch/v850np/v850dis.c index 794d257da3..467b12ba23 100644 --- a/libr/anal/arch/v850np/v850dis.c +++ b/libr/anal/arch/v850np/v850dis.c @@ -428,7 +428,7 @@ static bool v850np_disassemble(v850np_inst *inst, int cpumodel, ut64 memaddr, co bool invalid = false; value = get_operand_value (operand, insn, buffer + 2, buffer_size - 2, &invalid); if (invalid) { - // eprintf ("Warning: Cannot get operand value.\n"); + // R_LOG_WARN ("Cannot get operand value."); break; } diff --git a/libr/anal/dwarf_process.c b/libr/anal/dwarf_process.c index cf1d2e1e66..09157895bf 100644 --- a/libr/anal/dwarf_process.c +++ b/libr/anal/dwarf_process.c @@ -273,7 +273,7 @@ static st32 parse_type(Context *ctx, const ut64 offset, RStrBuf *strbuf, ut64 *s *visited = su; } if (visited && set_u_contains (*visited, offset)) { - eprintf ("Warning: anal.dwarf.parse_type: infinite recursion detected.\n"); + R_LOG_WARN ("anal.dwarf.parse_type: infinite recursion detected."); return -1; } set_u_add (*visited, offset); @@ -1039,7 +1039,7 @@ static const char *map_dwarf_reg_to_ppc64_reg(ut64 reg_num, VariableLocationKind /* returns string literal register name! TODO add more arches */ static const char *get_dwarf_reg_name(const char *arch, int reg_num, VariableLocationKind *kind, int bits) { - R_LOG_DEBUG ("get_dwarf_reg_name %s %d\n", arch, bits); + R_LOG_DEBUG ("get_dwarf_reg_name %s %d", arch, bits); if (arch && !strcmp (arch, "x86")) { if (bits == 64) { return map_dwarf_reg_to_x86_64_reg (reg_num, kind); diff --git a/libr/anal/esil.c b/libr/anal/esil.c index fc27c781f0..c4ddaca34d 100644 --- a/libr/anal/esil.c +++ b/libr/anal/esil.c @@ -441,15 +441,15 @@ static bool internal_esil_reg_write_no_null(RAnalEsil *esil, const char *regname const char *bp = r_reg_get_name (esil->anal->reg, R_REG_NAME_BP); if (!pc) { - eprintf ("Warning: RReg profile does not contain PC register\n"); + R_LOG_WARN ("RReg profile does not contain PC register"); return false; } if (!sp) { - eprintf ("Warning: RReg profile does not contain SP register\n"); + R_LOG_WARN ("RReg profile does not contain SP register"); return false; } if (!bp) { - eprintf ("Warning: RReg profile does not contain BP register\n"); + R_LOG_WARN ("RReg profile does not contain BP register"); return false; } if (reg && reg->name && ((strcmp (reg->name , pc) && strcmp (reg->name, sp) && strcmp(reg->name, bp)) || num)) { //I trust k-maps @@ -3745,7 +3745,7 @@ R_API int r_anal_esil_condition(RAnalEsil *esil, const char *str) { } free (popped); } else { - eprintf ("Warning: Cannot pop because The ESIL stack is empty\n"); + R_LOG_WARN ("Cannot pop because The ESIL stack is empty"); return -1; } return ret; diff --git a/libr/anal/esil_trace.c b/libr/anal/esil_trace.c index 5d3d82065e..c927ac5844 100644 --- a/libr/anal/esil_trace.c +++ b/libr/anal/esil_trace.c @@ -62,7 +62,7 @@ R_API RAnalEsilTrace *r_anal_esil_trace_new(RAnalEsil *esil) { } return trace; error: - eprintf ("error\n"); + R_LOG_ERROR ("error"); r_anal_esil_trace_free (trace); return NULL; } @@ -88,7 +88,7 @@ static void add_reg_change(RAnalEsilTrace *trace, int idx, RRegItem *ri, ut64 da if (!vreg) { vreg = r_vector_new (sizeof (RAnalEsilRegChange), NULL, NULL); if (!vreg) { - eprintf ("Error: creating a register vector.\n"); + R_LOG_ERROR ("creating a register vector."); return; } ht_up_insert (trace->registers, addr, vreg); @@ -103,7 +103,7 @@ static void add_mem_change(RAnalEsilTrace *trace, int idx, ut64 addr, ut8 data) if (!vmem) { vmem = r_vector_new (sizeof (RAnalEsilMemChange), NULL, NULL); if (!vmem) { - eprintf ("Error: creating a memory vector.\n"); + R_LOG_ERROR ("creating a memory vector."); return; } ht_up_insert (trace->memory, addr, vmem); diff --git a/libr/anal/fcn.c b/libr/anal/fcn.c index 54a25e6810..4fa82bdf5f 100644 --- a/libr/anal/fcn.c +++ b/libr/anal/fcn.c @@ -667,7 +667,7 @@ static int fcn_recurse(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 len, int } if ((maxlen - (addrbytes * idx)) > MAX_SCAN_SIZE) { if (anal->verbose) { - eprintf ("Warning: Skipping large memory region.\n"); + R_LOG_WARN ("Skipping large memory region."); } maxlen = 0; } @@ -699,19 +699,19 @@ repeat: ret = read_ahead (anal, at, buf, bytes_read); if (ret < 0) { - eprintf ("Failed to read\n"); + R_LOG_ERROR ("Failed to read"); break; } if (is_invalid_memory (anal, buf, bytes_read)) { if (anal->verbose) { - eprintf ("Warning: FFFF opcode at 0x%08"PFMT64x "\n", at); + R_LOG_WARN ("FFFF opcode at 0x%08"PFMT64x, at); } gotoBeach (R_ANAL_RET_ERROR) } r_anal_op_fini (op); if ((oplen = r_anal_op (anal, op, at, buf, bytes_read, R_ANAL_OP_MASK_ESIL | R_ANAL_OP_MASK_VAL | R_ANAL_OP_MASK_HINT)) < 1) { if (anal->verbose) { - eprintf ("Invalid instruction at 0x%"PFMT64x" with %d bits\n", at, anal->config->bits); + R_LOG_WARN ("Invalid instruction at 0x%"PFMT64x" with %d bits", at, anal->config->bits); } // gotoBeach (R_ANAL_RET_ERROR); // RET_END causes infinite loops somehow @@ -1690,12 +1690,12 @@ R_API RAnalFunction *r_anal_get_function_byname(RAnal *a, const char *name) { R_API bool r_anal_function_add_bb(RAnal *a, RAnalFunction *fcn, ut64 addr, ut64 size, ut64 jump, ut64 fail, R_BORROW RAnalDiff *diff) { D eprintf ("Add bb\n"); if (size == 0) { // empty basic blocks allowed? - eprintf ("Warning: empty basic block at 0x%08"PFMT64x" is not allowed. pending discussion.\n", addr); + R_LOG_WARN ("empty basic block at 0x%08"PFMT64x" is not allowed. pending discussion.", addr); r_warn_if_reached (); return false; } if (size > a->opt.bb_max_size) { - eprintf ("Warning: can't allocate such big bb of %"PFMT64d" bytes at 0x%08"PFMT64x"\n", (st64)size, addr); + R_LOG_WARN ("can't allocate such big bb of %"PFMT64d" bytes at 0x%08"PFMT64x, (st64)size, addr); r_warn_if_reached (); return false; } @@ -1720,7 +1720,7 @@ R_API bool r_anal_function_add_bb(RAnal *a, RAnalFunction *fcn, ut64 addr, ut64 } if (!block) { - D eprintf ("Warning: r_anal_function_add_bb failed in fcn 0x%08"PFMT64x" at 0x%08"PFMT64x"\n", fcn->addr, addr); + D R_LOG_WARN ("r_anal_function_add_bb failed in fcn 0x%08"PFMT64x" at 0x%08"PFMT64x, fcn->addr, addr); return false; } @@ -1775,7 +1775,7 @@ R_API int r_anal_function_complexity(RAnalFunction *fcn) { r_list_foreach (fcn->bbs, iter, bb) { N++; // nodes if ((!anal || anal->verbose) && bb->jump == UT64_MAX && bb->fail != UT64_MAX) { - eprintf ("Warning: invalid bb jump/fail pair at 0x%08"PFMT64x" (fcn 0x%08"PFMT64x"\n", bb->addr, fcn->addr); + R_LOG_WARN ("invalid bb jump/fail pair at 0x%08"PFMT64x" (fcn 0x%08"PFMT64x, bb->addr, fcn->addr); } if (bb->jump == UT64_MAX && bb->fail == UT64_MAX) { P++; // exit nodes @@ -1792,7 +1792,7 @@ R_API int r_anal_function_complexity(RAnalFunction *fcn) { int result = E - N + (2 * P); if (result < 1 && (!anal || anal->verbose)) { - eprintf ("Warning: CC = E(%d) - N(%d) + (2 * P(%d)) < 1 at 0x%08"PFMT64x"\n", E, N, P, fcn->addr); + R_LOG_WARN ("CC = E(%d) - N(%d) + (2 * P(%d)) < 1 at 0x%08"PFMT64x, E, N, P, fcn->addr); } // r_return_val_if_fail (result > 0, 0); return result; diff --git a/libr/anal/flirt.c b/libr/anal/flirt.c index ae8f954fdb..3a0a010f1a 100644 --- a/libr/anal/flirt.c +++ b/libr/anal/flirt.c @@ -917,7 +917,7 @@ static ut8 parse_leaf(const RAnal *anal, RBuffer *b, RFlirtNode *node) { } #if DEBUG if (crc_length == 0x00 && crc16 != 0x0000) { - eprintf ("Warning: non zero crc of zero length @ %04X\n", + R_LOG_WARN ("non zero crc of zero length @ %04X", r_buf_tell (b) + header_size); } eprintf ("crc_len: %02X crc16: %04X\n", crc_length, crc16); @@ -1467,7 +1467,7 @@ R_API void r_sign_flirt_scan(RAnal *anal, const char *flirt_file) { r_buf_free (flirt_buf); if (node) { if (!node_match_functions (anal, node)) { - eprintf ("Error while scanning the file %s\n", flirt_file); + R_LOG_ERROR ("Error while scanning the file %s", flirt_file); } node_free (node); return; diff --git a/libr/anal/op.c b/libr/anal/op.c index 77919fa91d..90daed9ea5 100644 --- a/libr/anal/op.c +++ b/libr/anal/op.c @@ -141,7 +141,7 @@ R_API int r_anal_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int le } if (!op->mnemonic && (mask & R_ANAL_OP_MASK_DISASM)) { if (anal->verbose) { - eprintf ("Warning: unhandled R_ANAL_OP_MASK_DISASM in r_anal_op\n"); + R_LOG_WARN ("unhandled R_ANAL_OP_MASK_DISASM in r_anal_op"); } } if (mask & R_ANAL_OP_MASK_HINT) { diff --git a/libr/anal/p/anal_arm_cs.c b/libr/anal/p/anal_arm_cs.c index a77dc9b988..d4e7f8160f 100644 --- a/libr/anal/p/anal_arm_cs.c +++ b/libr/anal/p/anal_arm_cs.c @@ -4465,7 +4465,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, RAn cs_open (CS_ARCH_ARM, mode, &handle); cs_option (handle, CS_OPT_DETAIL, CS_OPT_ON); if (ret != CS_ERR_OK) { - R_LOG_ERROR ("Capstone failed: cs_open(CS_ARCH_ARM%s, %x, ...): %s\n", + R_LOG_ERROR ("Capstone failed: cs_open(CS_ARCH_ARM%s, %x, ...): %s", (a->config->bits == 64) ? "64" : "", mode, cs_strerror (ret)); diff --git a/libr/anal/p/anal_x86_cs.c b/libr/anal/p/anal_x86_cs.c index 3e0a42a5c7..18a9d5facb 100644 --- a/libr/anal/p/anal_x86_cs.c +++ b/libr/anal/p/anal_x86_cs.c @@ -953,7 +953,7 @@ static void anop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, val = 0x8000000000000000; break; default: - eprintf ("Error: unknown operand size: %d\n", gop.insn->detail->x86.operands[0].size); + R_LOG_ERROR ("unknown operand size: %d", gop.insn->detail->x86.operands[0].size); val = 256; } ut32 bitsize; diff --git a/libr/anal/p/capstone.inc b/libr/anal/p/capstone.inc index 24154051a7..ab016fb66c 100644 --- a/libr/anal/p/capstone.inc +++ b/libr/anal/p/capstone.inc @@ -31,7 +31,7 @@ static csh init_capstone (RAnal *a) { if (cs_handle == 0) { int ret = cs_open (CSINC_ARCH, mode, &cs_handle); if (ret != CS_ERR_OK) { - R_LOG_ERROR ("Capstone failed: cs_open(%#x, %#x): %s\n", CSINC_ARCH, mode, cs_strerror (ret)); + R_LOG_ERROR ("Capstone failed: cs_open(%#x, %#x): %s", CSINC_ARCH, mode, cs_strerror (ret)); cs_handle = 0; } else { cs_option (cs_handle, CS_OPT_DETAIL, CS_OPT_ON); diff --git a/libr/anal/rtti_itanium.c b/libr/anal/rtti_itanium.c index e9f7de595b..3fef494b32 100644 --- a/libr/anal/rtti_itanium.c +++ b/libr/anal/rtti_itanium.c @@ -196,7 +196,7 @@ static bool rtti_itanium_vmi_class_type_info_init(RVTableContext *context, ut64 } at = at & 0xffffffff; if (at < 1 || at > 0xfffff) { - eprintf ("Error reading vmi_base_count\n"); + R_LOG_ERROR ("Error reading vmi_base_count"); return false; } vmi_cti->vmi_base_count = at; diff --git a/libr/anal/rtti_msvc.c b/libr/anal/rtti_msvc.c index 3152bd71ab..93530bb4d1 100644 --- a/libr/anal/rtti_msvc.c +++ b/libr/anal/rtti_msvc.c @@ -169,7 +169,7 @@ static RList *rtti_msvc_read_base_class_array(RVTableContext *context, ut32 num_ if (num_base_classes > BASE_CLASSES_MAX) { if (context->anal->verbose) { - eprintf ("Warning: Length of base class array at 0x%08"PFMT64x" exceeds %d.\n", addr, BASE_CLASSES_MAX); + R_LOG_WARN ("Length of base class array at 0x%08"PFMT64x" exceeds %d.", addr, BASE_CLASSES_MAX); } num_base_classes = BASE_CLASSES_MAX; } @@ -769,7 +769,7 @@ RecoveryCompleteObjectLocator *recovery_anal_complete_object_locator(RRTTIMSVCAn } if (!td->valid) { if (context->vt_context->anal->verbose) { - eprintf ("Warning: type descriptor of base is invalid.\n"); + R_LOG_WARN ("type descriptor of base is invalid."); } continue; } @@ -814,7 +814,7 @@ static char *unique_class_name(RAnal *anal, const char *original_name) { char *name = NULL; if (anal->verbose) { - eprintf ("Warning: class name %s already taken!\n", original_name); + R_LOG_WARN ("class name %s already taken!", original_name); } int i = 1; @@ -858,14 +858,14 @@ static void recovery_apply_bases(RRTTIMSVCAnalContext *context, const char *clas r_vector_foreach (base_descs, base_desc) { RecoveryTypeDescriptor *base_td = base_desc->td; if (!base_td->valid) { - eprintf ("Warning Base td is invalid!\n"); + R_LOG_WARN ("Warning Base td is invalid!"); continue; } const char *base_class_name; if (!base_td->col) { if (context->vt_context->anal->verbose) { - eprintf ("Warning: Base td %s has no col. Falling back to recovery from td only.\n", base_td->td.name); + R_LOG_WARN ("Base td %s has no col. Falling back to recovery from td only.", base_td->td.name); } base_class_name = recovery_apply_type_descriptor (context, base_td); } else { @@ -896,7 +896,7 @@ static const char *recovery_apply_complete_object_locator(RRTTIMSVCAnalContext * if (!col->td) { if (context->vt_context->anal->verbose) { - eprintf ("Warning: no td for col at 0x%"PFMT64x"\n", col->addr); + R_LOG_WARN ("no td for col at 0x%"PFMT64x, col->addr); } return NULL; } diff --git a/libr/anal/sign.c b/libr/anal/sign.c index f42619274e..6ac38e1da4 100644 --- a/libr/anal/sign.c +++ b/libr/anal/sign.c @@ -201,7 +201,7 @@ static bool types_sig_valid(const char *types) { #define DBL_VAL_FAIL(x,y) \ if (x) { \ - eprintf ("Warning: Skipping signature with multiple %c signatures (%s)\n", y, k); \ + R_LOG_WARN ("Skipping signature with multiple %c signatures (%s)", y, k); \ success = false; \ goto out; \ } @@ -219,12 +219,12 @@ R_API bool r_sign_deserialize(RAnal *a, RSignItem *it, const char *k, const char // Deserialize key: zign|space|name int n = r_str_split (k2, '|'); if (n != 3) { - eprintf ("Warning: Skipping signature with invalid key (%s)\n", k); + R_LOG_WARN ("Skipping signature with invalid key (%s)", k); success = false; goto out; } if (strcmp (r_str_word_get0 (k2, 0), "zign")) { - eprintf ("Warning: Skipping signature with invalid value (%s)\n", k); + R_LOG_WARN ("Skipping signature with invalid value (%s)", k); success = false; goto out; } @@ -251,7 +251,7 @@ R_API bool r_sign_deserialize(RAnal *a, RSignItem *it, const char *k, const char continue; } if (strlen (word) < 3 || word[1] != ':') { - eprintf ("Warning: Skipping signature with corrupted serialization (%s:%s)\n", k, word); + R_LOG_WARN ("Skipping signature with corrupted serialization (%s:%s)", k, word); success = false; goto out; } @@ -699,12 +699,12 @@ static bool addBBHash(RAnal *a, RAnalFunction *fcn, const char *name) { R_API bool r_sign_add_hash(RAnal *a, const char *name, int type, const char *val, int len) { r_return_val_if_fail (a && name && type && val && len > 0, false); if (type != R_SIGN_BBHASH) { - eprintf ("error: hash type unknown\n"); + R_LOG_ERROR ("error: hash type unknown"); return false; } int digestsize = r_hash_size (R_ZIGN_HASH) * 2; if (len != digestsize) { - eprintf ("error: invalid hash size: %d (%s digest size is %d)\n", len, ZIGN_HASH, digestsize); + R_LOG_ERROR ("error: invalid hash size: %d (%s digest size is %d)", len, ZIGN_HASH, digestsize); return false; } return addHash (a, name, type, val); @@ -982,7 +982,7 @@ R_API bool r_sign_addto_item(RAnal *a, RSignItem *it, RAnalFunction *fcn, RSignT } break; default: - eprintf ("Error: %s Can not handle type %c\n", __FUNCTION__, type); + R_LOG_ERROR ("%s Can not handle type %c", __FUNCTION__, type); } return false; @@ -2031,7 +2031,7 @@ static bool foreachCB(void *user, const char *k, const char *v) { keep_going = ctx->cb (it, ctx->user); } } else { - eprintf ("error: cannot deserialize zign\n"); + R_LOG_ERROR ("error: cannot deserialize zign"); } if (ctx->freeit) { r_sign_item_free (it); @@ -2873,7 +2873,7 @@ static bool loadCB(void *user, const char *k, const char *v) { } } } else { - eprintf ("error: cannot deserialize zign\n"); + R_LOG_ERROR ("error: cannot deserialize zign"); } r_sign_item_free (it); return true; @@ -2921,7 +2921,7 @@ R_API bool r_sign_load(RAnal *a, const char *file, bool merge) { } char *path = r_sign_path (a, file); if (!r_file_exists (path)) { - eprintf ("error: file %s does not exist\n", file); + R_LOG_ERROR ("error: file %s does not exist", file); free (path); return false; } @@ -2946,37 +2946,37 @@ R_API bool r_sign_load_gz(RAnal *a, const char *filename, bool merge) { char *path = r_sign_path (a, filename); if (!r_file_exists (path)) { - eprintf ("error: file %s does not exist\n", filename); + R_LOG_ERROR ("error: file %s does not exist", filename); retval = false; goto out; } if (!(buf = r_file_gzslurp (path, &size, 0))) { - eprintf ("error: cannot decompress file\n"); + R_LOG_ERROR ("error: cannot decompress file"); retval = false; goto out; } if (!(tmpfile = r_file_temp ("r2zign"))) { - eprintf ("error: cannot create temp file\n"); + R_LOG_ERROR ("error: cannot create temp file"); retval = false; goto out; } if (!r_file_dump (tmpfile, buf, size, 0)) { - eprintf ("error: cannot dump file\n"); + R_LOG_ERROR ("error: cannot dump file"); retval = false; goto out; } if (!r_sign_load (a, tmpfile, merge)) { - eprintf ("error: cannot load file\n"); + R_LOG_ERROR ("error: cannot load file"); retval = false; goto out; } if (!r_file_rm (tmpfile)) { - eprintf ("error: cannot delete temp file\n"); + R_LOG_ERROR ("error: cannot delete temp file"); retval = false; goto out; } @@ -2993,7 +2993,7 @@ R_API bool r_sign_save(RAnal *a, const char *file) { r_return_val_if_fail (a && file, false); if (sdb_isempty (a->sdb_zigns)) { - eprintf ("Warning: no zignatures to save\n"); + R_LOG_WARN ("no zignatures to save"); return false; } diff --git a/libr/anal/var.c b/libr/anal/var.c index d579d7945e..158302c862 100644 --- a/libr/anal/var.c +++ b/libr/anal/var.c @@ -941,7 +941,7 @@ static void extract_arg(RAnal *anal, RAnalFunction *fcn, RAnalOp *op, const char const char *rn = op->dst->reg ? op->dst->reg->name : NULL; if (rn && ((bp && !strcmp (bp, rn)) || (sp && !strcmp (sp, rn)))) { if (anal->verbose) { - eprintf ("Warning: Analysis didn't fill op->stackop for instruction that alters stack at 0x%" PFMT64x ".\n", op->addr); + R_LOG_WARN ("Analysis didn't fill op->stackop for instruction that alters stack at 0x%" PFMT64x ".", op->addr); } goto beach; } @@ -969,7 +969,7 @@ static void extract_arg(RAnal *anal, RAnalFunction *fcn, RAnalOp *op, const char } if (anal->verbose && (!op->src[0] || !op->dst)) { - eprintf ("Warning: Analysis didn't fill op->src/dst at 0x%" PFMT64x ".\n", op->addr); + R_LOG_WARN ("Analysis didn't fill op->src/dst at 0x%" PFMT64x ".", op->addr); } int rw = (op->direction == R_ANAL_OP_DIR_WRITE) ? R_ANAL_VAR_ACCESS_TYPE_WRITE : R_ANAL_VAR_ACCESS_TYPE_READ; @@ -1158,7 +1158,7 @@ R_API void r_anal_extract_rarg(RAnal *anal, RAnalOp *op, RAnalFunction *fcn, int const char *opdreg = op->dst ? get_regname (anal, op->dst) : NULL; const int size = (fcn->bits ? fcn->bits : anal->config->bits) / 8; if (!fcn->cc) { - R_LOG_DEBUG ("No calling convention for function '%s' to extract register arguments\n", fcn->name); + R_LOG_DEBUG ("No calling convention for function '%s' to extract register arguments", fcn->name); return; } char *fname = r_type_func_guess (anal->sdb_types, fcn->name); diff --git a/libr/asm/arch/pyc/opcode.c b/libr/asm/arch/pyc/opcode.c index b118095456..c334bc7a1e 100644 --- a/libr/asm/arch/pyc/opcode.c +++ b/libr/asm/arch/pyc/opcode.c @@ -245,7 +245,7 @@ void (store_opN)(struct op_parameter par) { def_op (.op_obj = par.op_obj, .op_name = par.op_name, .op_code = par.op_code, .pop = par.pop, .push = par.push); break; default: - eprintf ("Error in store_op in opcode.c, call function %u.\n", par.func); + R_LOG_ERROR ("Error in store_op in opcode.c, call function %u.", par.func); return; } par.op_obj[par.op_code].type |= HASSTORE; @@ -294,6 +294,6 @@ void (rm_op)(struct op_parameter par) { op_obj->op_name = r_str_newf ("<%u>", par.op_code); op_obj->type = op_obj->op_pop = op_obj->op_push = 0; } else { - eprintf ("Error in rm_op() while constructing opcodes for .pyc file: \n .op_code = %u, .op_name = %s", par.op_code, par.op_name); + R_LOG_ERROR ("Error in rm_op() while constructing opcodes for .pyc file: \n .op_code = %u, .op_name = %s", par.op_code, par.op_name); } } diff --git a/libr/asm/arch/riscv/riscvasm.c b/libr/asm/arch/riscv/riscvasm.c index a0739786b3..0bd6f07b24 100644 --- a/libr/asm/arch/riscv/riscvasm.c +++ b/libr/asm/arch/riscv/riscvasm.c @@ -122,7 +122,7 @@ static int riscv_rri(ut8 *b, int op, int rs, int rt, int imm) { static int getreg(const char *p) { int n; if (!p || !*p) { - eprintf ("Missing argument\n"); + R_LOG_ERROR ("Missing argument"); return -1; } /* check if it's a register */ @@ -147,7 +147,7 @@ static int getreg(const char *p) { if (n != 0 || p[0] == '0') { return n; } - eprintf ("Invalid reg name (%s) at pos %d\n", p, n); + R_LOG_ERROR ("Invalid reg name (%s) at pos %d", p, n); return -1; } @@ -216,7 +216,7 @@ R_IPI int riscv_assemble(const char *str, ut64 pc, ut8 *out) { free (s); return 4; default: - eprintf ("Unknown type\n"); + R_LOG_ERROR ("Unknown type"); break; } free (s); diff --git a/libr/asm/arch/tms320/c55x_plus/c55plus_decode.c b/libr/asm/arch/tms320/c55x_plus/c55plus_decode.c index 633976e904..538d0307b9 100644 --- a/libr/asm/arch/tms320/c55x_plus/c55plus_decode.c +++ b/libr/asm/arch/tms320/c55x_plus/c55plus_decode.c @@ -43,7 +43,7 @@ static ut32 get_q_bits(ut32 val, const char *ins, ut32 ins_len, int *err_code) { res = (val >> 10) & 1; } else { /* INVALID CONDITION */ - eprintf ("Invalid token %s\n", ins); + R_LOG_ERROR ("Invalid token %s", ins); *err_code = -1; } return res; @@ -74,7 +74,7 @@ static ut32 get_ins_bits(ut32 hash_code, ut32 ins_pos, const char *ins, if (!aux) { aux = strchr (op_str, ins[i]); if (!aux) { - eprintf ("Invalid token %s\n", ins); *err_code = -1; return 0; + R_LOG_ERROR ("Invalid token %s", ins); *err_code = -1; return 0; } } @@ -101,7 +101,7 @@ static bool check_arg(ut32 ins_bits, int *err_code) { } else if (ins_bits >= 32 && ins_bits <= 252) { res = false; } else { - eprintf ("Invalid arg: %u\n", ins_bits); + R_LOG_ERROR ("Invalid arg: %u", ins_bits); *err_code = -1; } @@ -122,7 +122,7 @@ static char *decode_regis(char *reg_arg, st32 hash_code, ut32 ins_bits, break; case 100: if (r_str_ncasecmp (reg_arg, "d(ALLx", 6)) { - eprintf ("invalid register! %s\n", reg_arg); + R_LOG_ERROR ("invalid register! %s", reg_arg); *err_code = -1; return NULL; } @@ -133,7 +133,7 @@ static char *decode_regis(char *reg_arg, st32 hash_code, ut32 ins_bits, break; case 41: if (r_str_ncasecmp (reg_arg, ")ALLx", 5)) { - eprintf ("invalid register! %s\n", reg_arg); + R_LOG_ERROR ("invalid register! %s", reg_arg); *err_code = -1; return NULL; } @@ -226,7 +226,7 @@ static char *decode_ins(st32 hash_code, ut32 ins_pos, ut32 ins_off, ut32 *ins_le // get pseudo instruction ins = ins_str[1 + 2 + hash_code * 4]; if (!ins /*|| ins_str[4 * hash_code] == 0*/) { - eprintf ("Invalid instruction /hash %x\n", hash_code); + R_LOG_ERROR ("Invalid instruction /hash %x", hash_code); *err_code = -1; return NULL; } @@ -247,14 +247,14 @@ static char *decode_ins(st32 hash_code, ut32 ins_pos, ut32 ins_off, ut32 *ins_le pos++; aux = strchr (pos, '`'); if (!aux || pos == aux) { - eprintf ("Invalid instruction %s\n", ins); + R_LOG_ERROR ("Invalid instruction %s", ins); free (res_decode); *err_code = -1; return NULL; } len = (ut32)(size_t)(aux-pos); if (len >= 80) { - eprintf ("Invalid length token %d\n", len); + R_LOG_ERROR ("Invalid length token %d", len); free (res_decode); *err_code = -1; return NULL; @@ -345,7 +345,7 @@ void set_magic_value(ut32 *magic_value, st32 hash_code, int *err_code) { *magic_value |= 0x400; break; default: - eprintf ("invalid hash code 0x%x for magic value 0x%x\n", hash_code, *magic_value); + R_LOG_ERROR ("invalid hash code 0x%x for magic value 0x%x", hash_code, *magic_value); *err_code = -1; } } @@ -830,7 +830,7 @@ static char* get_token_decoded(st32 hash_code, const char *ins_token, ut32 ins_t } else if (!r_str_ncasecmp (ins_token, "q_LINR", 6)) { res = ins_bits? ".lr": NULL; } else { - eprintf ("Invalid instruction %s\n!", ins_token); + R_LOG_ERROR ("Invalid instruction %s!", ins_token); *err_code = -1; return NULL; } diff --git a/libr/asm/asm.c b/libr/asm/asm.c index 44d35faddc..4628160ac1 100644 --- a/libr/asm/asm.c +++ b/libr/asm/asm.c @@ -59,7 +59,7 @@ static int r_asm_pseudo_string(RAsmOp *op, char *input, int zero) { static inline int r_asm_pseudo_arch(RAsm *a, const char *input) { if (!r_asm_use (a, input)) { - eprintf ("Error: Unknown plugin\n"); + R_LOG_ERROR ("Unknown plugin"); return -1; } return 0; @@ -67,7 +67,7 @@ static inline int r_asm_pseudo_arch(RAsm *a, const char *input) { static inline int r_asm_pseudo_bits(RAsm *a, const char *input) { if (!(r_asm_set_bits (a, r_num_math (NULL, input)))) { - eprintf ("Error: Unsupported value for .bits.\n"); + R_LOG_ERROR ("Unsupported value for .bits."); return -1; } return 0; @@ -84,7 +84,7 @@ static inline int r_asm_pseudo_intN(RAsm *a, RAsmOp *op, char *input, int n) { long int l; ut64 s64 = r_num_math (NULL, input); if (n != 8 && s64 >> (n * 8)) { - eprintf ("int16 Out is out of range\n"); + R_LOG_ERROR ("int16 Out is out of range"); return 0; } // XXX honor endian here @@ -144,8 +144,8 @@ static inline int r_asm_pseudo_fill(RAsmOp *op, const char *input) { if (strchr (input, ',')) { int res = sscanf (input, "%d,%d,%d", &repeat, &size, &value); // use r_num? if (res != 3) { - eprintf ("Invalid usage of .fill repeat,size,value\n"); - eprintf ("for example: .fill 1,0x100,0\n"); + R_LOG_ERROR ("Invalid usage of .fill repeat,size,value"); + R_LOG_ERROR ("for example: .fill 1,0x100,0"); return -1; } } else { @@ -179,7 +179,7 @@ static inline int r_asm_pseudo_incbin(RAsmOp *op, char *input) { size_t count = (size_t)r_num_math (NULL,r_str_word_get0 (input, 2)); char *content = r_file_slurp (input, &bytes_read); if (!content) { - eprintf ("Could not open '%s'.\n", input); + R_LOG_ERROR ("Could not open '%s'.", input); return -1; } if (skip > 0) { @@ -415,7 +415,7 @@ R_API bool r_asm_use(RAsm *a, const char *name) { if (a->analb.use (a->analb.anal, name)) { load_asm_descriptions (a, NULL); } else { - eprintf ("Cannot find arch plugin with this name. See rasm2 -L and rasm2 -LL\n"); + R_LOG_ERROR ("Cannot find arch plugin with this name. See rasm2 -L and rasm2 -LL"); } } #if 0 @@ -863,12 +863,12 @@ R_API RAsmCode *r_asm_massemble(RAsm *a, const char *assembly) { const size_t new_tokens_size = tokens_size * 2; if (sizeof (char*) * new_tokens_size <= sizeof (char*) * tokens_size) { // overflow - eprintf ("Too many tokens\n"); + R_LOG_ERROR ("Too many tokens"); goto fail; } char **new_tokens = realloc (tokens, sizeof (char*) * new_tokens_size); if (!new_tokens) { - eprintf ("Too many tokens\n"); + R_LOG_ERROR ("Too many tokens"); goto fail; } tokens_size = new_tokens_size; @@ -1057,7 +1057,7 @@ R_API RAsmCode *r_asm_massemble(RAsm *a, const char *assembly) { } else if ((!strncmp (ptr, ".byte ", 6)) || (!strncmp (ptr, ".int8 ", 6))) { ret = r_asm_pseudo_byte (&op, ptr + 6); } else if (!strncmp (ptr, ".glob", 5)) { // .global .globl - // eprintf (".global directive not yet implemented\n"); + // R_LOG_ERROR (".global directive not yet implemented"); ret = 0; continue; } else if (!strncmp (ptr, ".equ ", 5)) { @@ -1072,32 +1072,32 @@ R_API RAsmCode *r_asm_massemble(RAsm *a, const char *assembly) { *ptr2 = '\0'; r_asm_code_set_equ (acode, ptr + 5, ptr2 + 1); } else { - eprintf ("Invalid syntax for '.equ': Use '.equ '\n"); + R_LOG_ERROR ("Invalid syntax for '.equ': Use '.equ '"); } } else if (!strncmp (ptr, ".org ", 5)) { ret = r_asm_pseudo_org (a, ptr + 5); off = a->pc; } else if (r_str_startswith (ptr, ".offset ")) { - eprintf ("Invalid use of the .offset directory. This directive is only supported in r2 -c 'waf'.\n"); + R_LOG_ERROR ("Invalid use of the .offset directory. This directive is only supported in r2 -c 'waf'."); } else if (!strncmp (ptr, ".text", 5)) { acode->code_offset = a->pc; } else if (!strncmp (ptr, ".data", 5)) { acode->data_offset = a->pc; } else if (!strncmp (ptr, ".incbin", 7)) { if (ptr[7] != ' ') { - eprintf ("incbin missing filename\n"); + R_LOG_ERROR ("incbin missing filename"); continue; } ret = r_asm_pseudo_incbin (&op, ptr + 8); } else { - eprintf ("Unknown directive (%s)\n", ptr); + R_LOG_ERROR ("Unknown directive (%s)", ptr); goto fail; } if (!ret) { continue; } if (ret < 0) { - eprintf ("!!! Oops (%s)\n", ptr); + R_LOG_ERROR ("!!! Oops (%s)", ptr); goto fail; } } else { /* Instruction */ diff --git a/libr/asm/p/asm_arm_cs.c b/libr/asm/p/asm_arm_cs.c index da73b7cd65..cd50e7b4fa 100644 --- a/libr/asm/p/asm_arm_cs.c +++ b/libr/asm/p/asm_arm_cs.c @@ -243,7 +243,7 @@ static int assemble(RAsm *a, RAsmOp *op, const char *buf) { } else { opcode = armass_assemble (buf, a->pc, is_thumb); if (bits != 32 && bits != 16) { - eprintf ("Error: ARM assembler only supports 16 or 32 bits\n"); + R_LOG_ERROR ("ARM assembler only supports 16 or 32 bits"); return -1; } } diff --git a/libr/asm/p/asm_x86_nasm.c b/libr/asm/p/asm_x86_nasm.c index 23f31ba5cf..1120cc6215 100644 --- a/libr/asm/p/asm_x86_nasm.c +++ b/libr/asm/p/asm_x86_nasm.c @@ -6,7 +6,7 @@ static int assemble(RAsm *a, RAsmOp *op, const char *buf) { char *ipath, *opath; if (a->config->syntax != R_ASM_SYNTAX_INTEL) { - eprintf ("asm.x86.nasm does not support non-intel syntax\n"); + R_LOG_ERROR ("asm.x86.nasm does not support non-intel syntax"); return -1; } @@ -38,7 +38,7 @@ static int assemble(RAsm *a, RAsmOp *op, const char *buf) { op->size = read (ofd, buf, sizeof (buf)); r_asm_op_set_buf (op, buf, op->size); } else { - eprintf ("Error running 'nasm'\n"); + R_LOG_ERROR ("Error running 'nasm'"); } close (ofd); diff --git a/libr/asm/p/asm_x86_nz.c b/libr/asm/p/asm_x86_nz.c index 18f1176f0d..d22879fc3a 100644 --- a/libr/asm/p/asm_x86_nz.c +++ b/libr/asm/p/asm_x86_nz.c @@ -232,7 +232,7 @@ static int process_group_1(RAsm *a, ut8 *data, const Opcode *op) { } } else if (op->operands[0].type & OT_BYTE) { if (op->operands[1].immediate > 255) { - eprintf ("Error: Immediate exceeds bounds\n"); + R_LOG_ERROR ("Immediate exceeds bounds"); return -1; } data[l++] = 0x80; @@ -314,7 +314,7 @@ static int process_group_2(RAsm *a, ut8 *data, const Opcode *op) { st32 immediate = op->operands[1].immediate * op->operands[1].sign; if (immediate > 255 || immediate < -128) { - eprintf ("Error: Immediate exceeds bounds\n"); + R_LOG_ERROR ("Immediate exceeds bounds"); return -1; } @@ -406,7 +406,7 @@ static int process_1byte_op(RAsm *a, ut8 *data, const Opcode *op, int op1) { && op->operands[1].type & (OT_DWORD | OT_QWORD)) { data[l++] = op1 + 0x1; } else { - eprintf ("Error: mismatched operand sizes\n"); + R_LOG_ERROR ("mismatched operand sizes"); return -1; } reg = op->operands[1].reg; @@ -434,7 +434,7 @@ static int process_1byte_op(RAsm *a, ut8 *data, const Opcode *op, int op1) { && op->operands[1].type & (OT_DWORD | OT_QWORD)) { data[l++] = op1 + 0x3; } else { - eprintf ("Error: mismatched operand sizes\n"); + R_LOG_ERROR ("mismatched operand sizes"); return -1; } reg = op->operands[0].reg; @@ -999,7 +999,7 @@ static int opaam(RAsm *a, ut8 *data, const Opcode *op) { static int opdec(RAsm *a, ut8 *data, const Opcode *op) { if (op->operands[1].type) { - eprintf ("Error: Invalid operands\n"); + R_LOG_ERROR ("Invalid operands"); return -1; } is_valid_registers (op); @@ -1231,7 +1231,7 @@ static int opimul(RAsm *a, ut8 *data, const Opcode *op) { if ((op->operands[0].type & OT_GPREG) && !(op->operands[0].type & OT_MEMORY)) { if (op->operands[1].type & OT_CONSTANT) { if (op->operands[1].immediate == -1) { - eprintf ("Error: Immediate exceeds max\n"); + R_LOG_ERROR ("Immediate exceeds max"); return -1; } immediate = op->operands[1].immediate * op->operands[1].sign; @@ -1414,7 +1414,7 @@ static int opclflush(RAsm *a, ut8 *data, const Opcode *op) { static int opinc(RAsm *a, ut8 *data, const Opcode *op) { if (op->operands[1].type) { - eprintf ("Error: Invalid operands\n"); + R_LOG_ERROR ("Invalid operands"); return -1; } is_valid_registers (op); @@ -2446,7 +2446,7 @@ static int oppush(RAsm *a, ut8 *data, const Opcode *op) { } ut8 base = 0x50; if (op->operands[0].reg == X86R_RIP) { - eprintf ("Invalid register\n"); + R_LOG_ERROR ("Invalid register"); return -1; } data[l++] = base + op->operands[0].reg; @@ -2663,7 +2663,7 @@ static int optest(RAsm *a, ut8 *data, const Opcode *op) { is_valid_registers (op); int l = 0; if (!op->operands[0].type || !op->operands[1].type) { - eprintf ("Error: Invalid operands\n"); + R_LOG_ERROR ("Invalid operands"); return -1; } if (a->config->bits == 64) { @@ -4790,13 +4790,13 @@ static Register parseReg(RAsm *a, const char *str, size_t *pos, ut32 *type) { // read number // const int maxreg = (a->config->bits == 64) ? 15 : 7; if (getToken (token, pos, &nextpos) != TT_NUMBER) { - eprintf ("Expected register number '%s'\n", str + *pos); + R_LOG_ERROR ("Expected register number '%s'", str + *pos); return X86R_UNDEFINED; } reg = getnum (a, token + *pos); // st and mm go up to 7, xmm up to 15 if ((reg > 15) || ((*type & (OT_FPUREG | OT_MMXREG) & ~OT_REGALL) && reg > 7)) { - eprintf ("Too large register index!\n"); + R_LOG_ERROR ("Too large register index!"); return X86R_UNDEFINED; } *pos = nextpos; @@ -4895,7 +4895,7 @@ static int parseOperand(RAsm *a, const char *str, Operand *op, bool isrepop) { bool first_reg = true; while (str[pos] != ']') { if (pos > nextpos) { - // eprintf ("Error parsing instruction\n"); + // R_LOG_ERROR ("Error parsing instruction"); break; } pos = nextpos; diff --git a/libr/bin/bfile.c b/libr/bin/bfile.c index cf0e0ea5a7..f26ad0ed43 100644 --- a/libr/bin/bfile.c +++ b/libr/bin/bfile.c @@ -482,7 +482,7 @@ static void get_strings_range(RBinFile *bf, RList *list, int min, int raw, ut64 } else if (!strcmp (enc, "utf32le")) { type = R_STRING_TYPE_WIDE32; } else { // TODO utf16be, utf32be - eprintf ("ERROR: encoding %s not supported\n", enc); + R_LOG_ERROR ("ERROR: encoding %s not supported", enc); return; } string_scan_range (list, bf, min, from, to, type, raw, section); @@ -937,7 +937,7 @@ R_API RList *r_bin_file_compute_hashes(RBin *bin, ut64 limit) { // By SLURP_LIMIT normally cannot compute ... if (buf_len > limit) { if (bin->verbose) { - eprintf ("Warning: r_bin_file_hash: file exceeds bin.hashlimit\n"); + R_LOG_WARN ("r_bin_file_hash: file exceeds bin.hashlimit"); } return NULL; } diff --git a/libr/bin/bin.c b/libr/bin/bin.c index d3af443137..2bfaffd289 100644 --- a/libr/bin/bin.c +++ b/libr/bin/bin.c @@ -646,7 +646,7 @@ R_API void r_bin_set_baddr(RBin *bin, ut64 baddr) { } } } else { - eprintf ("Warning: This should be an assert probably.\n"); + R_LOG_WARN ("This should be an assert probably."); } // XXX - update all the infos? // maybe in RBinFile.rebase() ? @@ -1109,7 +1109,7 @@ R_API void r_bin_list_archs(RBin *bin, PJ *pj, int mode) { "0x%08" PFMT64x ":%" PFMT64u ":%s:%d", boffset, obj_size, "unk", 0); } else { - eprintf ("Error: Invalid RBinFile.\n"); + R_LOG_ERROR ("Invalid RBinFile."); } //sdb_array_push (binfile_sdb, ARCHS_KEY, archline, 0); } diff --git a/libr/bin/bobj.c b/libr/bin/bobj.c index 1465940b2e..ebe6d998b6 100644 --- a/libr/bin/bobj.c +++ b/libr/bin/bobj.c @@ -148,7 +148,7 @@ R_IPI RBinObject *r_bin_object_new(RBinFile *bf, RBinPlugin *plugin, ut64 basead if (plugin && plugin->load_buffer) { if (!plugin->load_buffer (bf, &bo->bin_obj, bf->buf, loadaddr, sdb)) { if (bf->rbin->verbose) { - eprintf ("Error in r_bin_object_new: load_buffer failed for %s plugin\n", plugin->name); + R_LOG_ERROR ("Error in r_bin_object_new: load_buffer failed for %s plugin", plugin->name); } sdb_free (bo->kv); free (bo); diff --git a/libr/bin/dwarf.c b/libr/bin/dwarf.c index 534f224481..a969405ed1 100644 --- a/libr/bin/dwarf.c +++ b/libr/bin/dwarf.c @@ -2088,7 +2088,7 @@ static RBinDwarfDebugInfo *parse_info_raw(Sdb *sdb, RBinDwarfDebugAbbrev *da, } if (da->decls->count >= da->capacity) { - eprintf ("Warning: malformed dwarf have not enough buckets for decls.\n"); + R_LOG_WARN ("malformed dwarf have not enough buckets for decls."); } r_warn_if_fail (da->count <= da->capacity); diff --git a/libr/bin/format/bflt/bflt.c b/libr/bin/format/bflt/bflt.c index e4161fdc24..d1c333ff6b 100644 --- a/libr/bin/format/bflt/bflt.c +++ b/libr/bin/format/bflt/bflt.c @@ -22,17 +22,17 @@ static int bflt_init_hdr(struct r_bin_bflt_obj *bin) { len = r_buf_read_at (bin->b, 0, bhdr, BFLT_HDR_SIZE); if (len < 1) { - eprintf ("Warning: read bFLT hdr failed\n"); + R_LOG_WARN ("read bFLT hdr failed"); goto fail; } if (strncmp ((const char *)bhdr, "bFLT", 4)) { - eprintf ("Warning: wrong magic number in bFLT file\n"); + R_LOG_WARN ("wrong magic number in bFLT file"); goto fail; } p_hdr = R_NEW0 (struct bflt_hdr); if (!p_hdr) { - eprintf ("Warning: couldn't allocate memory\n"); + R_LOG_WARN ("couldn't allocate memory"); goto fail; } @@ -49,7 +49,7 @@ static int bflt_init_hdr(struct r_bin_bflt_obj *bin) { p_hdr->build_date = READ (bhdr, i); if (p_hdr->rev != FLAT_VERSION) { - eprintf ("Warning: only v4 is supported!\n"); + R_LOG_WARN ("only v4 is supported!"); R_FREE (p_hdr); goto fail; } diff --git a/libr/bin/format/dex/dex.c b/libr/bin/format/dex/dex.c index 5743ee5cad..934ac14fda 100644 --- a/libr/bin/format/dex/dex.c +++ b/libr/bin/format/dex/dex.c @@ -46,7 +46,7 @@ static char *getstr(RBinDexObj *bin, int idx) { r_buf_read_at (bin->b, bin->strings[idx] + uleblen, ptr, len + 1); ptr[len] = 0; if (len != r_utf8_strlen (ptr)) { - // eprintf ("Warning: Invalid string for index %d\n", idx); + // R_LOG_WARN ("Invalid string for index %d", idx); return NULL; } } diff --git a/libr/bin/format/dmp/dmp64.c b/libr/bin/format/dmp/dmp64.c index dfe1ac516c..649dc9860b 100644 --- a/libr/bin/format/dmp/dmp64.c +++ b/libr/bin/format/dmp/dmp64.c @@ -9,12 +9,12 @@ static int r_bin_dmp64_init_memory_runs(struct r_bin_dmp64_obj_t *obj) { int i, j; dmp64_p_memory_desc *mem_desc = &obj->header->PhysicalMemoryBlockBuffer; if (!memcmp (mem_desc, DMP_UNUSED_MAGIC, 4)) { - eprintf ("Warning: Invalid PhysicalMemoryDescriptor\n"); + R_LOG_WARN ("Invalid PhysicalMemoryDescriptor"); return false; } ut64 num_runs = mem_desc->NumberOfRuns; if (num_runs * sizeof (dmp_p_memory_run) >= r_offsetof (dmp64_header, ContextRecord)) { - eprintf ("Warning: Invalid PhysicalMemoryDescriptor\n"); + R_LOG_WARN ("Invalid PhysicalMemoryDescriptor"); return false; } obj->pages = r_list_newf (free); @@ -24,7 +24,7 @@ static int r_bin_dmp64_init_memory_runs(struct r_bin_dmp64_obj_t *obj) { dmp_p_memory_run *runs = calloc (num_runs, sizeof (dmp_p_memory_run)); ut64 num_runs_offset = r_offsetof (dmp64_header, PhysicalMemoryBlockBuffer) + r_offsetof (dmp64_p_memory_desc, NumberOfRuns); if (r_buf_read_at (obj->b, num_runs_offset, (ut8*)runs, num_runs * sizeof (dmp_p_memory_run)) < 0) { - eprintf ("Warning: read memory runs\n"); + R_LOG_WARN ("read memory runs"); free (runs); return false; }; @@ -46,7 +46,7 @@ static int r_bin_dmp64_init_memory_runs(struct r_bin_dmp64_obj_t *obj) { } } if (mem_desc->NumberOfPages != num_page) { - eprintf ("Warning: Number of Pages not matches\n"); + R_LOG_WARN ("Number of Pages not matches"); } free (runs); @@ -59,7 +59,7 @@ static int r_bin_dmp64_init_header(struct r_bin_dmp64_obj_t *obj) { return false; } if (r_buf_read_at (obj->b, 0, (ut8*)obj->header, sizeof (dmp64_header)) < 0) { - eprintf ("Warning: read header\n"); + R_LOG_WARN ("read header"); return false; } obj->dtb = obj->header->DirectoryTableBase; @@ -96,7 +96,7 @@ static int r_bin_dmp64_init_bmp_pages(struct r_bin_dmp64_obj_t *obj) { num_bitset++; } if (obj->bmp_header->TotalPresentPages != num_bitset) { - eprintf ("Warning: TotalPresentPages not matched\n"); + R_LOG_WARN ("TotalPresentPages not matched"); return false; } @@ -110,17 +110,17 @@ static int r_bin_dmp64_init_bmp_header(struct r_bin_dmp64_obj_t *obj) { return false; } if (r_buf_read_at (obj->b, sizeof (dmp64_header), (ut8*)obj->bmp_header, offsetof (dmp_bmp_header, Bitmap)) < 0) { - eprintf ("Warning: read bmp_header\n"); + R_LOG_WARN ("read bmp_header"); return false; } if (!!memcmp (obj->bmp_header, DMP_BMP_MAGIC, 8)) { - eprintf ("Warning: Invalid Bitmap Magic\n"); + R_LOG_WARN ("Invalid Bitmap Magic"); return false; } ut64 bitmapsize = obj->bmp_header->Pages / 8; obj->bitmap = calloc (1, bitmapsize); if (r_buf_read_at (obj->b, sizeof (dmp64_header) + offsetof (dmp_bmp_header, Bitmap), obj->bitmap, bitmapsize) < 0) { - eprintf ("Warning: read bitmap\n"); + R_LOG_WARN ("read bitmap"); return false; } @@ -129,7 +129,7 @@ static int r_bin_dmp64_init_bmp_header(struct r_bin_dmp64_obj_t *obj) { static int r_bin_dmp64_init(struct r_bin_dmp64_obj_t *obj) { if (!r_bin_dmp64_init_header (obj)) { - eprintf ("Warning: Invalid Kernel Dump x64 Format\n"); + R_LOG_WARN ("Invalid Kernel Dump x64 Format"); return false; } switch (obj->header->DumpType) { diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index 9712b7bc3e..c5ba5b4292 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -1316,7 +1316,7 @@ static bool init_dynstr(ELFOBJ *bin) { section_name = &bin->shstrtab[bin->shdr[i].sh_name]; if (bin->shdr[i].sh_type == SHT_STRTAB && !strcmp (section_name, ".dynstr")) { if (!(bin->dynstr = (char*) calloc (bin->shdr[i].sh_size + 1, sizeof (char)))) { - R_LOG_ERROR ("Cannot allocate memory for dynamic strings\n"); + R_LOG_ERROR ("Cannot allocate memory for dynamic strings"); return false; } if (bin->shdr[i].sh_offset > bin->size) { @@ -3763,7 +3763,7 @@ static RBinElfSymbol* Elf_(_r_bin_elf_get_symbols_imports)(ELFOBJ *bin, int type } ret[ret_ctr].size = tsize; if (sym[k].st_name + 1 > strtab_section->sh_size) { - R_LOG_DEBUG ("index out of strtab range (%"PFMT64d" / %"PFMT64d")\n", + R_LOG_DEBUG ("index out of strtab range (%"PFMT64d" / %"PFMT64d")", (ut64)sym[k].st_name, (ut64)strtab_section->sh_size); continue; } diff --git a/libr/bin/format/elf/elf_write.c b/libr/bin/format/elf/elf_write.c index 3d0157e1dc..f7dd6d2a79 100644 --- a/libr/bin/format/elf/elf_write.c +++ b/libr/bin/format/elf/elf_write.c @@ -205,7 +205,7 @@ bool Elf_(r_bin_elf_del_rpath)(RBinFile *bf) { return false; } if (r_buf_read_at (bin->b, bin->phdr[i].p_offset, (ut8*)dyn, bin->phdr[i].p_filesz) == -1) { - eprintf ("Error: read (dyn)\n"); + R_LOG_ERROR ("read (dyn)"); free (dyn); return false; } @@ -220,7 +220,7 @@ bool Elf_(r_bin_elf_del_rpath)(RBinFile *bf) { if (dyn[j].d_tag == DT_RPATH || dyn[j].d_tag == DT_RUNPATH) { if (r_buf_write_at (bin->b, stroff + dyn[j].d_un.d_val, (ut8*)"", 1) == -1) { - eprintf ("Error: write (rpath)\n"); + R_LOG_ERROR ("write (rpath)"); free (dyn); return false; } diff --git a/libr/bin/format/le/le.c b/libr/bin/format/le/le.c index 87fe65c27e..61a830787f 100644 --- a/libr/bin/format/le/le.c +++ b/libr/bin/format/le/le.c @@ -457,7 +457,7 @@ RList *r_bin_le_get_relocs(r_bin_le_obj_t *bin) { int ret = r_buf_read_at (bin->buf, offset, (ut8 *)&header, sizeof (header)); // XXX this is endiandy unsafe if (ret < (int)sizeof (header)) { - eprintf ("Warning: oobread in LE header parsing relocs\n"); + R_LOG_WARN ("oobread in LE header parsing relocs"); break; } offset += sizeof (header); diff --git a/libr/bin/format/mach0/dyldcache.c b/libr/bin/format/mach0/dyldcache.c index 383d697bfa..4768629ce7 100644 --- a/libr/bin/format/mach0/dyldcache.c +++ b/libr/bin/format/mach0/dyldcache.c @@ -67,12 +67,12 @@ struct r_bin_dyldcache_lib_t *r_bin_dyldcache_extract(struct r_bin_dyldcache_obj return NULL; } if (bin->hdr.startaddr > bin->size) { - eprintf ("corrupted dyldcache\n"); + R_LOG_ERROR ("corrupted dyldcache"); goto ret_err; } if (bin->hdr.startaddr > bin->size || bin->hdr.baseaddroff > bin->size) { - eprintf ("corrupted dyldcache\n"); + R_LOG_ERROR ("corrupted dyldcache"); goto ret_err; } int sz = bin->nlibs * sizeof (struct dyld_cache_image_info); @@ -84,13 +84,13 @@ struct r_bin_dyldcache_lib_t *r_bin_dyldcache_extract(struct r_bin_dyldcache_obj dyld_vmbase = r_buf_read64le (bin->b, bin->hdr.baseaddroff); liboff = image_infos[idx].address - dyld_vmbase; if (liboff > bin->size) { - eprintf ("Corrupted file\n"); + R_LOG_ERROR ("Corrupted file"); goto ret_err; } ret->offset = liboff; int pfo = image_infos[idx].pathFileOffset; if (pfo < 0 || pfo > bin->size) { - eprintf ("corrupted file: pathFileOffset > bin->size (%d)\n", pfo); + R_LOG_ERROR ("corrupted file: pathFileOffset > bin->size (%d)", pfo); goto ret_err; } libname = r_buf_read_string (bin->b, pfo, 64); @@ -146,7 +146,7 @@ struct r_bin_dyldcache_lib_t *r_bin_dyldcache_extract(struct r_bin_dyldcache_obj } int t = seg.filesize; if (seg.fileoff + seg.filesize > bin->size || seg.fileoff > bin->size) { - eprintf ("malformed dyldcache\n"); + R_LOG_ERROR ("malformed dyldcache"); goto dbuf_err; } r_buf_append_buf_slice (dbuf, bin->b, seg.fileoff, t); diff --git a/libr/bin/format/mach0/mach0.c b/libr/bin/format/mach0/mach0.c index 6a4af1cec2..857336b0a7 100644 --- a/libr/bin/format/mach0/mach0.c +++ b/libr/bin/format/mach0/mach0.c @@ -467,7 +467,7 @@ static bool parse_symtab(struct MACH0_(obj_t) *mo, ut64 off) { } int len = r_buf_read_at (mo->b, off, symt, sizeof (struct symtab_command)); if (len != sizeof (struct symtab_command)) { - Eprintf ("Error: read (symtab)\n"); + R_LOG_ERROR ("read (symtab)"); return false; } st.cmd = r_read_ble32 (symt, be); @@ -2098,7 +2098,7 @@ static bool init(struct MACH0_(obj_t) *mo) { return false; } if (!init_items (mo)) { - Eprintf ("Warning: Cannot initialize items\n"); + R_LOG_WARN ("Cannot initialize items"); } mo->baddr = MACH0_(get_baddr)(mo); return true; diff --git a/libr/bin/format/mz/mz.c b/libr/bin/format/mz/mz.c index 9fb8f080ed..370b6c6cf8 100644 --- a/libr/bin/format/mz/mz.c +++ b/libr/bin/format/mz/mz.c @@ -24,7 +24,7 @@ RBinAddr *r_bin_mz_get_entrypoint (const struct r_bin_mz_obj_t *bin) { la = r_bin_mz_va_to_la (mz->cs, mz->ip); la &= 0xfffff; if (la >= bin->load_module_size) { - eprintf ("Error: entry point outside load module\n"); + R_LOG_ERROR ("entry point outside load module"); return NULL; } entrypoint = R_NEW0 (RBinAddr); @@ -146,7 +146,7 @@ RList *r_bin_mz_get_segments(const struct r_bin_mz_obj_t *bin) { return seg_list; err_out: - eprintf ("Error: alloc (RBinSection)\n"); + R_LOG_ERROR ("alloc (RBinSection)"); r_list_free (seg_list); return NULL; @@ -159,7 +159,7 @@ struct r_bin_mz_reloc_t *r_bin_mz_get_relocs (const struct r_bin_mz_obj_t *bin) struct r_bin_mz_reloc_t *relocs = calloc (num_relocs + 1, sizeof (*relocs)); if (!relocs) { - eprintf ("Error: calloc (struct r_bin_mz_reloc_t)\n"); + R_LOG_ERROR ("calloc (struct r_bin_mz_reloc_t)"); return NULL; } for (i = 0, j = 0; i < num_relocs; i++) { @@ -200,7 +200,7 @@ static int r_bin_mz_init_hdr(struct r_bin_mz_obj_t *bin) { bin->dos_header = mz; // TODO: read field by field to avoid endian and alignment issues if (r_buf_read_at (bin->b, 0, (ut8 *)mz, sizeof (*mz)) == -1) { - eprintf ("Error: read (MZ_image_dos_header)\n"); + R_LOG_ERROR ("read (MZ_image_dos_header)"); return false; } // dos_header is not endian safe here in this point @@ -255,7 +255,7 @@ static int r_bin_mz_init_hdr(struct r_bin_mz_obj_t *bin) { if (r_buf_read_at (bin->b, sizeof (MZ_image_dos_header), (ut8 *)bin->dos_extended_header, bin->dos_extended_header_size) == -1) { - eprintf ("Error: read (dos extended header)\n"); + R_LOG_ERROR ("read (dos extended header)"); return false; } } @@ -267,7 +267,7 @@ static int r_bin_mz_init_hdr(struct r_bin_mz_obj_t *bin) { } if (r_buf_read_at (bin->b, bin->dos_header->reloc_table_offset, (ut8 *)bin->relocation_entries, relocations_size) == -1) { - eprintf ("Error: read (dos relocation entries)\n"); + R_LOG_ERROR ("read (dos relocation entries)"); R_FREE (bin->relocation_entries); return false; } @@ -281,7 +281,7 @@ static bool r_bin_mz_init(struct r_bin_mz_obj_t *bin) { bin->relocation_entries = NULL; bin->kv = sdb_new0 (); if (!r_bin_mz_init_hdr (bin)) { - eprintf ("Warning: File is not MZ\n"); + R_LOG_WARN ("File is not MZ"); return false; } return true; @@ -336,7 +336,7 @@ RBinAddr *r_bin_mz_get_main_vaddr (struct r_bin_mz_obj_t *bin) { } ZERO_FILL (b); if (r_buf_read_at (bin->b, entry->paddr, b, sizeof (b)) < 0) { - eprintf ("Warning: Cannot read entry at 0x%16" PFMT64x "\n", (ut64)entry->paddr); + R_LOG_WARN ("Cannot read entry at 0x%16" PFMT64x, (ut64)entry->paddr); free (entry); return NULL; } diff --git a/libr/bin/format/objc/mach0_classes.c b/libr/bin/format/objc/mach0_classes.c index 617d0e7075..2774394f7b 100644 --- a/libr/bin/format/objc/mach0_classes.c +++ b/libr/bin/format/objc/mach0_classes.c @@ -291,7 +291,7 @@ static void get_ivar_list_t(mach0_ut p, RBinFile *bf, RBinClass *klass) { if (offset_at != 0 && left >= sizeof (mach0_ut)) { len = r_buf_read_at (bf->buf, offset_at, offs, sizeof (mach0_ut)); if (len != sizeof (mach0_ut)) { - eprintf ("Error reading\n"); + R_LOG_ERROR ("Error reading"); goto error; } ivar_offset = r_read_ble (offs, bigendian, 8 * sizeof (mach0_ut)); @@ -315,7 +315,7 @@ static void get_ivar_list_t(mach0_ut p, RBinFile *bf, RBinClass *klass) { name = malloc (name_len + 1); len = r_buf_read_at (bf->buf, r, (ut8 *)name, name_len); if (len < 1) { - eprintf ("Error reading\n"); + R_LOG_ERROR ("Error reading"); R_FREE (name); goto error; } diff --git a/libr/bin/format/pe/pe.c b/libr/bin/format/pe/pe.c index 65230b840c..8483e86650 100644 --- a/libr/bin/format/pe/pe.c +++ b/libr/bin/format/pe/pe.c @@ -1234,7 +1234,7 @@ static bool bin_pe_init_metadata_hdr(RBinPEObj* pe) { goto fail; } - R_LOG_DEBUG ("Metadata Signature: 0x%"PFMT64x" 0x%"PFMT64x" %d\n", + R_LOG_DEBUG ("Metadata Signature: 0x%"PFMT64x" 0x%"PFMT64x" %d", (ut64)metadata_directory, (ut64)metadata->Signature, (int)metadata->VersionStringLength); // read the version string @@ -1252,7 +1252,7 @@ static bool bin_pe_init_metadata_hdr(RBinPEObj* pe) { free (metadata); return 0; } - R_LOG_DEBUG (".NET Version: %s\n", metadata->VersionString); + R_LOG_DEBUG (".NET Version: %s", metadata->VersionString); } // read the header after the string @@ -1261,7 +1261,7 @@ static bool bin_pe_init_metadata_hdr(RBinPEObj* pe) { if (rr < 1) { goto fail; } - R_LOG_DEBUG ("Number of Metadata Streams: %d\n", metadata->NumberOfStreams); + R_LOG_DEBUG ("Number of Metadata Streams: %d", metadata->NumberOfStreams); pe->metadata_header = metadata; // read metadata streams @@ -1305,7 +1305,7 @@ static bool bin_pe_init_metadata_hdr(RBinPEObj* pe) { free (streams); goto fail; } - R_LOG_DEBUG ("Stream name: %s %d\n", stream_name, c); + R_LOG_DEBUG ("Stream name: %s %d", stream_name, c); stream->Name = stream_name; streams[count] = stream; stream_addr += 8 + c; @@ -2973,7 +2973,7 @@ static void _parse_resource_directory(RBinPEObj *pe, Pe_image_resource_directory break; } if (read_image_resource_directory_entry (pe->b, off, &entry) < 0) { - eprintf ("Warning: read resource entry\n"); + R_LOG_WARN ("read resource entry"); break; } if (entry.u1.Name >> 31) { @@ -3004,7 +3004,7 @@ static void _parse_resource_directory(RBinPEObj *pe, Pe_image_resource_directory off = rsrc_base + OffsetToDirectory; int len = read_image_resource_directory (pe->b, off, &identEntry); if (len < 1 || len != sizeof (Pe_image_resource_directory)) { - eprintf ("Warning: parsing resource directory\n"); + R_LOG_WARN ("parsing resource directory"); } _parse_resource_directory (pe, &identEntry, OffsetToDirectory, type, entry.u1.Name & 0xffff, dirs, resourceEntryName); R_FREE (resourceEntryName); @@ -3022,7 +3022,7 @@ static void _parse_resource_directory(RBinPEObj *pe, Pe_image_resource_directory break; } if (read_image_resource_data_entry (pe->b, off, data) != sizeof (*data)) { - eprintf ("Warning: read (resource data entry)\n"); + R_LOG_WARN ("read (resource data entry)"); free (data); break; } @@ -3138,7 +3138,7 @@ R_API void PE_(bin_pe_parse_resource)(RBinPEObj *pe) { curRes = rs_directory->NumberOfNamedEntries; totalRes = curRes + rs_directory->NumberOfIdEntries; if (totalRes > R_PE_MAX_RESOURCES) { - eprintf ("Error parsing resource directory\n"); + R_LOG_ERROR ("Error parsing resource directory"); ht_uu_free (dirs); return; } @@ -3150,7 +3150,7 @@ R_API void PE_(bin_pe_parse_resource)(RBinPEObj *pe) { break; } if (read_image_resource_directory_entry (pe->b, off, &typeEntry) < 0) { - eprintf ("Warning: read resource directory entry\n"); + R_LOG_WARN ("read resource directory entry"); break; } if (typeEntry.u2.OffsetToData >> 31) { @@ -3159,7 +3159,7 @@ R_API void PE_(bin_pe_parse_resource)(RBinPEObj *pe) { off = rsrc_base + OffsetToDirectory; int len = read_image_resource_directory (pe->b, off, &identEntry); if (len != sizeof (identEntry)) { - eprintf ("Warning: parsing resource directory\n"); + R_LOG_WARN ("parsing resource directory"); } (void)_parse_resource_directory (pe, &identEntry, OffsetToDirectory, typeEntry.u1.Name & 0xffff, 0, dirs, NULL); } @@ -3276,11 +3276,11 @@ static int bin_pe_init(RBinPEObj* pe) { pe->cms = NULL; pe->spcinfo = NULL; if (!bin_pe_init_hdr (pe)) { - eprintf ("Warning: File is not PE\n"); + R_LOG_WARN ("File is not PE"); return false; } if (!bin_pe_init_sections (pe)) { - eprintf ("Warning: Cannot initialize sections\n"); + R_LOG_WARN ("Cannot initialize sections"); return false; } pe->sections = PE_(r_bin_pe_get_sections) (pe); @@ -4148,7 +4148,7 @@ void PE_(r_bin_pe_check_sections)(RBinPEObj* pe, struct r_bin_pe_section_t* * se if (addr_beg <= entry->vaddr || entry->vaddr < addr_end) { if (!(sections[j].perm & PE_IMAGE_SCN_MEM_EXECUTE)) { if (pe->verbose) { - eprintf ("Warning: Found entrypoint in non-executable section.\n"); + R_LOG_WARN ("Found entrypoint in non-executable section."); } sections[j].perm |= PE_IMAGE_SCN_MEM_EXECUTE; } diff --git a/libr/bin/format/pe/pemixed.c b/libr/bin/format/pe/pemixed.c index 0de7e2ccd6..ade5de8d28 100644 --- a/libr/bin/format/pe/pemixed.c +++ b/libr/bin/format/pe/pemixed.c @@ -37,7 +37,7 @@ struct PE_(r_bin_pe_obj_t)* r_bin_pemixed_init_dos(RBinPEObj* pe) { } if ((r_buf_read_at (pe->b, 0, tmp_buf, pe_hdr_off)) == -1) { - eprintf ("Error reading to buffer\n"); + R_LOG_ERROR ("Error reading to buffer"); return NULL; } diff --git a/libr/bin/format/te/te.c b/libr/bin/format/te/te.c index 31770729f4..2f36226256 100644 --- a/libr/bin/format/te/te.c +++ b/libr/bin/format/te/te.c @@ -72,7 +72,7 @@ ut64 r_bin_te_get_main_paddr(struct r_bin_te_obj_t *bin) { return 0LL; } if (r_buf_read_at (bin->b, entry->paddr, buf, sizeof (buf)) == -1) { - eprintf ("Error: read (entry)\n"); + R_LOG_ERROR ("read (entry)"); } else { if (buf[367] == 0xe8) { int delta = (buf[368] | buf[369]<<8 | buf[370]<<16 | buf[371]<<24); @@ -115,7 +115,7 @@ static int r_bin_te_init_sections(struct r_bin_te_obj_t* bin) { } if (r_buf_read_at (bin->b, sizeof(TE_image_file_header), (ut8*)bin->section_header, sections_size) == -1) { - eprintf ("Error: read (sections headers)\n"); + R_LOG_ERROR ("read (sections headers)"); return false; } return true; diff --git a/libr/bin/format/wasm/wasm.c b/libr/bin/format/wasm/wasm.c index 36d5a877d7..feac03d2f7 100644 --- a/libr/bin/format/wasm/wasm.c +++ b/libr/bin/format/wasm/wasm.c @@ -463,7 +463,7 @@ static RBinWasmTypeEntry *parse_type_entry(RBinWasmObj *bin, ut64 bound, ut32 in goto beach; } if (type->form != R_BIN_WASM_VALUETYPE_FUNC) { - R_LOG_WARN ("Halting types section parsing at invalid type 0x%02x at offset: 0x%" PFMTSZx "\n", type->form, type->file_offset); + R_LOG_WARN ("Halting types section parsing at invalid type 0x%02x at offset: 0x%" PFMTSZx, type->form, type->file_offset); goto beach; } @@ -762,7 +762,7 @@ static RBinWasmCustomNameEntry *parse_custom_name_entry(RBinWasmObj *bin, ut64 b } break; default: - R_LOG_WARN ("[wasm] Halting custom name section parsing at unknown type 0x%x offset 0x%" PFMTSZx "\n", cust->type, start); + R_LOG_WARN ("[wasm] Halting custom name section parsing at unknown type 0x%x offset 0x%" PFMTSZx, cust->type, start); cust->type = R_BIN_WASM_NAMETYPE_None; goto beach; } diff --git a/libr/bin/p/bin_cgc.c b/libr/bin/p/bin_cgc.c index c7f1ee07ed..1de72e2940 100644 --- a/libr/bin/p/bin_cgc.c +++ b/libr/bin/p/bin_cgc.c @@ -87,7 +87,7 @@ static RBuffer* create(RBin* bin, const ut8 *code, int codelen, const ut8 *data, if (data && datalen>0) { //ut32 data_section = buf->length; - eprintf ("Warning: DATA section not support for ELF yet\n"); + R_LOG_WARN ("DATA section not support for ELF yet"); B (data, datalen); } return buf; diff --git a/libr/bin/p/bin_dex.c b/libr/bin/p/bin_dex.c index e8b697e82a..9687f55547 100644 --- a/libr/bin/p/bin_dex.c +++ b/libr/bin/p/bin_dex.c @@ -262,12 +262,12 @@ static char *dex_get_proto(RBinDexObj *bin, int proto_id) { // size of the list, in 16 bit entries ut32 list_size = r_read_le32 (params_buf); if (list_size >= ST32_MAX) { - eprintf ("Warning: function prototype contains too many parameters (> 2 million).\n"); + R_LOG_WARN ("function prototype contains too many parameters (> 2 million)."); list_size = ST32_MAX; } size_t typeidx_bufsize = (list_size * sizeof (ut16)); if (params_off + typeidx_bufsize > bin->size) { - eprintf ("Warning: truncated typeidx buffer from %d to %d\n", + R_LOG_WARN ("truncated typeidx buffer from %d to %d", (int)(params_off + typeidx_bufsize), (int)(bin->size - params_off)); typeidx_bufsize = bin->size - params_off; // early return as this may result on so many trashy symbols that take too much time to load @@ -1152,19 +1152,19 @@ static void parse_dex_class_method(RBinFile *bf, RBinDexClass *c, RBinClass *cls encoded_method_addr = r_buf_tell (bf->buf); MI = peek_uleb (bf->buf, &err, &skip); if (err) { - eprintf ("Error\n"); + R_LOG_ERROR ("Error"); break; } MI += omi; omi = MI; MA = peek_uleb (bf->buf, &err, &skip); if (err) { - eprintf ("Error\n"); + R_LOG_ERROR ("Error"); break; } MC = peek_uleb (bf->buf, &err, &skip); if (err) { - eprintf ("Error\n"); + R_LOG_ERROR ("Error"); break; } // TODO: MOVE CHECKS OUTSIDE! @@ -1925,27 +1925,27 @@ static void add_segment(RList *ret, const char *name, Section s, int perm) { static bool validate_section(const char *name, Section *pre, Section *cur, Section *nex, Section *all) { r_return_val_if_fail (cur && all, false); if (pre && cur->addr < (pre->addr + pre->size)) { - eprintf ("Warning: %s Section starts before the previous.\n", name); + R_LOG_WARN ("%s Section starts before the previous.", name); } if (cur->addr >= all->size) { - eprintf ("Warning: %s section starts beyond the end of the file.\n", name); + R_LOG_WARN ("%s section starts beyond the end of the file.", name); return false; } if (cur->addr == UT64_MAX) { - eprintf ("Warning: %s invalid region size.\n", name); + R_LOG_WARN ("%s invalid region size.", name); return false; } if ((cur->addr + cur->size) > all->size) { - eprintf ("Warning: %s truncated section because of file size.\n", name); + R_LOG_WARN ("%s truncated section because of file size.", name); cur->size = all->size - cur->addr; } if (nex) { if (cur->addr >= nex->addr) { - eprintf ("Warning: invalid %s section address.\n", name); + R_LOG_WARN ("invalid %s section address.", name); return false; } if ((cur->addr + cur->size) > nex->addr) { - eprintf ("Warning: truncated %s with next section size.\n", name); + R_LOG_WARN ("truncated %s with next section size.", name); cur->size = nex->addr - cur->addr; } } diff --git a/libr/bin/p/bin_dyldcache.c b/libr/bin/p/bin_dyldcache.c index f783c60adb..c85d06c7e1 100644 --- a/libr/bin/p/bin_dyldcache.c +++ b/libr/bin/p/bin_dyldcache.c @@ -1075,7 +1075,7 @@ static void carve_deps_at_address(RDyldCache *cache, cache_img_t *img, HtPU *pat const char *key = (const char *) cursor + 24; size_t dep_index = (size_t)ht_pu_find (path_to_idx, key, &found); if (!found || dep_index >= cache->hdr->imagesCount) { - eprintf ("Warning: alien dep '%s'\n", key); + R_LOG_WARN ("alien dep '%s'", key); continue; } deps[dep_index]++; @@ -1564,7 +1564,7 @@ static int dyldcache_io_read(RIO *io, RIODesc *fd, ut8 *buf, int count) { result = R_MIN (count, internal_result); memcpy (buf, internal_buf + page_offset, result); } else { - eprintf ("ERROR rebasing\n"); + R_LOG_ERROR ("ERROR rebasing"); result = cache->original_io_read (io, fd, buf, count); } diff --git a/libr/bin/p/bin_elf.c b/libr/bin/p/bin_elf.c index d37ba4aba2..99ae1b7d03 100644 --- a/libr/bin/p/bin_elf.c +++ b/libr/bin/p/bin_elf.c @@ -118,7 +118,7 @@ static RBuffer* create(RBin* bin, const ut8 *code, int codelen, const ut8 *data, if (data && datalen > 0) { //ut32 data_section = buf->length; - eprintf ("Warning: DATA section not support for ELF yet\n"); + R_LOG_WARN ("DATA section not support for ELF yet"); B (data, datalen); } return buf; diff --git a/libr/bin/p/bin_elf64.c b/libr/bin/p/bin_elf64.c index eb3552e89e..4d6e4fb4e7 100644 --- a/libr/bin/p/bin_elf64.c +++ b/libr/bin/p/bin_elf64.c @@ -117,7 +117,7 @@ static RBuffer* create(RBin* bin, const ut8 *code, int codelen, const ut8 *data, B (code, codelen); if (data && datalen>0) { - eprintf ("Warning: DATA section not support for ELF yet\n"); + R_LOG_WARN ("DATA section not support for ELF yet"); B (data, datalen); } return buf; diff --git a/libr/bin/p/bin_mach0.c b/libr/bin/p/bin_mach0.c index 09364812d9..707193b2dd 100644 --- a/libr/bin/p/bin_mach0.c +++ b/libr/bin/p/bin_mach0.c @@ -547,7 +547,7 @@ static bool _patch_reloc(struct MACH0_(obj_t) *bin, RIOBind *iob, struct reloc_t ins_len = 5; break; default: - eprintf ("Warning: unsupported reloc type for X86_64 (%d), please file a bug.\n", reloc->type); + R_LOG_WARN ("unsupported reloc type for X86_64 (%d), please file a bug.", reloc->type); return false; } break; @@ -560,7 +560,7 @@ static bool _patch_reloc(struct MACH0_(obj_t) *bin, RIOBind *iob, struct reloc_t case CPU_TYPE_ARM: break; default: - eprintf ("Warning: unsupported architecture for patching relocs, please file a bug. %s\n", MACH0_(get_cputype_from_hdr)(&bin->hdr)); + R_LOG_WARN ("unsupported architecture for patching relocs, please file a bug. %s", MACH0_(get_cputype_from_hdr)(&bin->hdr)); return false; } @@ -619,7 +619,7 @@ static RList* patch_relocs(RBin *b) { } if (!io->cached) { - eprintf ("Warning: run r2 with -e bin.cache=true to fix relocations in disassembly\n"); + R_LOG_WARN ("run r2 with -e bin.cache=true to fix relocations in disassembly"); goto beach; } diff --git a/libr/bin/p/bin_pe.c b/libr/bin/p/bin_pe.c index b979215852..bfc176756e 100644 --- a/libr/bin/p/bin_pe.c +++ b/libr/bin/p/bin_pe.c @@ -97,7 +97,7 @@ static RBuffer* create(RBin* bin, const ut8 *code, int codelen, const ut8 *data, if (data && datalen > 0) { //ut32 data_section = buf->length; - eprintf ("Warning: DATA section not support for PE yet\n"); + R_LOG_WARN ("DATA section not support for PE yet"); B (data, datalen); } return buf; diff --git a/libr/bin/p/bin_symbols.c b/libr/bin/p/bin_symbols.c index 5177be7886..3f6db2230e 100644 --- a/libr/bin/p/bin_symbols.c +++ b/libr/bin/p/bin_symbols.c @@ -198,7 +198,7 @@ static RCoreSymCacheElement *parseDragons(RBinFile *bf, RBuffer *buf, int off, i } int available = r_buf_read_at (buf, off, b, size); if (available != size) { - eprintf ("Warning: r_buf_read_at failed\n"); + R_LOG_WARN ("r_buf_read_at failed"); return NULL; } #if 0 @@ -235,7 +235,7 @@ static RCoreSymCacheElement *parseDragons(RBinFile *bf, RBuffer *buf, int off, i // hack for C22F7494 available = r_buf_read_at (buf, off - 8, b, size); if (available != size) { - eprintf ("Warning: r_buf_read_at failed\n"); + R_LOG_WARN ("r_buf_read_at failed"); return NULL; } if (!memcmp ("\x1a\x2b\xb2\xa1", b, 4)) { // 0x130 ? diff --git a/libr/bin/p/bin_write_mach0.c b/libr/bin/p/bin_write_mach0.c index 8a9d83d1e0..8f69d29e61 100644 --- a/libr/bin/p/bin_write_mach0.c +++ b/libr/bin/p/bin_write_mach0.c @@ -28,7 +28,7 @@ static MachoPointers findLastCommand(RBinFile *bf) { //r_buf_seek (bin->b, off, R_BUF_SET); int len = loadc[1]; // r_buf_read_le32 (loadc[1]); // bin->b); // if (len < 1) { - eprintf ("Error: read (lc) at 0x%08"PFMT64x"\n", off); + R_LOG_ERROR ("read (lc) at 0x%08"PFMT64x, off); break; } int size = r_read_ble32 (&loadc[1], bin->big_endian); @@ -59,7 +59,7 @@ static bool MACH0_(write_addlib)(RBinFile *bf, const char *lib) { size_t lib_len = strlen (lib); if (lib_len > 22) { - eprintf ("Warning: Adjusting cmdsize too long libname\n"); + R_LOG_WARN ("Adjusting cmdsize too long libname"); size_of_lib += lib_len + 1 - 22; size_of_lib += 8 - (size_of_lib % 8); } diff --git a/libr/bin/pdb/pdb.c b/libr/bin/pdb/pdb.c index 23be9a67a2..8b52dd65ff 100644 --- a/libr/bin/pdb/pdb.c +++ b/libr/bin/pdb/pdb.c @@ -91,7 +91,7 @@ static int read_int_var(char *var_name, int *var, RPdb *pdb) { } int bytes_read = r_buf_read (pdb->buf, (ut8 *) var, 4); if (bytes_read != 4) { - eprintf ("Error while reading from file '%s'\n", var_name); + R_LOG_ERROR ("Error while reading from file '%s'", var_name); return 0; } return bytes_read; @@ -188,7 +188,7 @@ static int init_pdb7_root_stream(RPdb *pdb, int *root_page_list, int pages_amoun if ((pos + num_pages) > tmp_data_max_size) { R_FREE (data); R_FREE (sizes); - eprintf ("Warning: looks like there is no correct values of stream size in PDB file.\n"); + R_LOG_WARN ("looks like there is no correct values of stream size in PDB file."); return 0; } @@ -212,7 +212,7 @@ static int init_pdb7_root_stream(RPdb *pdb, int *root_page_list, int pages_amoun // fclose(tmp_file); page->stream_size = sizes[i]; if (sizes[i] == 0) { - //eprintf ("Warning: stream_size (%d) is 0\n", i); + //R_LOG_WARN ("stream_size (%d) is 0", i); } page->stream_pages = tmp; page->num_pages = num_pages; @@ -220,7 +220,7 @@ static int init_pdb7_root_stream(RPdb *pdb, int *root_page_list, int pages_amoun page->stream_size = 0; page->stream_pages = 0; page->num_pages = 0; - //eprintf ("Warning: stream_size (%d) is 0\n", i); + //R_LOG_WARN ("stream_size (%d) is 0", i); free (tmp); } @@ -349,7 +349,7 @@ static int pdb_read_root(RPdb *pdb) { while (r_list_iter_next (it)) { page = (SPage *) r_list_iter_get (it); if (page->stream_pages == 0) { - //eprintf ("Warning: no stream pages. Skipping.\n"); + //R_LOG_WARN ("no stream pages. Skipping."); r_list_append (pList, NULL); i++; continue; @@ -438,7 +438,7 @@ static bool pdb7_parse(RPdb *pdb) { bytes_read = r_buf_read (pdb->buf, (unsigned char *) signature, PDB7_SIGNATURE_LEN); if (bytes_read != PDB7_SIGNATURE_LEN) { - //eprintf ("Error while reading PDB7_SIGNATURE.\n"); + //R_LOG_ERROR ("Error while reading PDB7_SIGNATURE."); goto error; } if (!read_int_var ("page_size", &page_size, pdb)) { @@ -465,14 +465,14 @@ static bool pdb7_parse(RPdb *pdb) { num_root_index_pages = count_pages ((num_root_pages * 4), page_size); root_index_pages = (int *) calloc (sizeof (int), R_MAX (num_root_index_pages, 1)); if (!root_index_pages) { - eprintf ("Error memory allocation.\n"); + R_LOG_ERROR ("Error memory allocation."); goto error; } bytes_read = r_buf_read (pdb->buf, (unsigned char *) root_index_pages, 4 * num_root_index_pages); // fread(root_index_pages, 4, num_root_index_pages, pdb->fp); if (bytes_read != 4 * num_root_index_pages) { - eprintf ("Error while reading root_index_pages.\n"); + R_LOG_ERROR ("Error while reading root_index_pages."); goto error; } if (page_size < 1 || num_root_index_pages < 1) { @@ -481,7 +481,7 @@ static bool pdb7_parse(RPdb *pdb) { } root_page_data = (int *) calloc (page_size, num_root_index_pages); if (!root_page_data) { - eprintf ("Error: memory allocation of root_page_data.\n"); + R_LOG_ERROR ("memory allocation of root_page_data."); goto error; } p_tmp = root_page_data; @@ -496,7 +496,7 @@ static bool pdb7_parse(RPdb *pdb) { } root_page_list = (int *) calloc (sizeof(int), num_root_pages); if (!root_page_list) { - eprintf ("Error: memory allocation of root page.\n"); + R_LOG_ERROR ("memory allocation of root page."); goto error; } diff --git a/libr/bin/pdb/tpi.c b/libr/bin/pdb/tpi.c index c85a89b6ba..36e64bf9ea 100644 --- a/libr/bin/pdb/tpi.c +++ b/libr/bin/pdb/tpi.c @@ -2041,7 +2041,7 @@ static void get_nesttype_print_type(void *type, char **name) { // this is possible because there is no support for // parsing METHODLIST... // need to investigate for this theme - //eprintf ("warning: strange for nesttype\n"); + //R_LOG_WARN ("strange for nesttype"); } } diff --git a/libr/bp/bp.c b/libr/bp/bp.c index 8ccc8223e6..104b228a87 100644 --- a/libr/bp/bp.c +++ b/libr/bp/bp.c @@ -174,8 +174,8 @@ static RBreakpointItem *r_bp_add(RBreakpoint *bp, const ut8 *obytes, ut64 addr, eprintf ("base addr should not be larger than the breakpoint address.\n"); } if (bp->bpinmaps && !r_bp_is_valid (bp, b)) { - eprintf ("Warning: Breakpoint won't be placed since it's not in a valid map.\n" - "You can bypass this check by setting dbg.bpinmaps to false.\n"); + R_LOG_WARN ("Breakpoint won't be placed since it's not in a valid map.\n" + "You can bypass this check by setting dbg.bpinmaps to false."); } b->delta = addr - bp->baddr; b->size = size; diff --git a/libr/cons/grep.c b/libr/cons/grep.c index ebc7aea775..cec8fa95ce 100644 --- a/libr/cons/grep.c +++ b/libr/cons/grep.c @@ -88,7 +88,7 @@ static void parse_grep_expression(const char *str) { len = 0; } if (len > R_CONS_GREP_BUFSIZE - 1) { - R_LOG_ERROR ("r_cons_grep: too long!\n"); + R_LOG_ERROR ("r_cons_grep: too long!"); return; } if (len > 0 && str[len] == '?') { @@ -110,7 +110,7 @@ static void parse_grep_expression(const char *str) { ptr = ptrs[ptrs_length]; ptrs_length++; if (ptrs_length >= R_CONS_GREP_COUNT) { - R_LOG_ERROR ("to many nested greps\n"); + R_LOG_ERROR ("too many nested greps"); return; } } @@ -354,12 +354,12 @@ static void parse_grep_expression(const char *str) { continue; } if (wlen >= R_CONS_GREP_WORD_SIZE - 1) { - R_LOG_ERROR ("grep string too long\n"); + R_LOG_ERROR ("grep string too long"); continue; } grep->nstrings++; if (grep->nstrings > R_CONS_GREP_WORDS - 1) { - R_LOG_ERROR ("too many grep strings\n"); + R_LOG_ERROR ("too many grep strings"); break; } r_str_ncpy (grep->strings[grep->nstrings - 1], @@ -894,7 +894,7 @@ R_API int r_cons_grep_line(char *buf, int len) { } outlen = outlen > 0? outlen - 1: 0; if (outlen > len) { // should never happen - R_LOG_ERROR ("r_cons_grep_line: wtf, how you reach this?\n"); + R_LOG_ERROR ("r_cons_grep_line: wtf, how you reach this?"); free (in); free (out); return -1; diff --git a/libr/cons/html.c b/libr/cons/html.c index cd6223eddf..f8f0a8d090 100644 --- a/libr/cons/html.c +++ b/libr/cons/html.c @@ -116,7 +116,7 @@ R_API char *r_cons_html_filter(const char *ptr, int *newlen) { if (esc == 1) { // \x1b[2J if (ptr[0] != '[') { - R_LOG_ERROR ("Oops invalid escape char\n"); + R_LOG_ERROR ("Oops invalid escape char"); esc = 0; str = ptr + 1; continue; diff --git a/libr/cons/hud.c b/libr/cons/hud.c index 0517f40c9e..49b672955b 100644 --- a/libr/cons/hud.c +++ b/libr/cons/hud.c @@ -454,7 +454,7 @@ R_API char *r_cons_hud_path(const char *path, int dir) { } r_list_free (files); } else { - R_LOG_ERROR ("No files found\n"); + R_LOG_ERROR ("No files found"); } if (!ret) { free (tmp); diff --git a/libr/core/anal_objc.c b/libr/core/anal_objc.c index ef03cb86a5..c8478d12f8 100644 --- a/libr/core/anal_objc.c +++ b/libr/core/anal_objc.c @@ -196,7 +196,7 @@ static RCoreObjc *core_objc_new(RCore *core) { } o->word_size = (core->rasm->config->bits == 64)? 8: 4; if (o->word_size != 8) { - eprintf ("Warning: aao experimental on 32bit binaries\n"); + R_LOG_WARN ("aao experimental on 32bit binaries"); } RBinSection *s; @@ -280,7 +280,7 @@ static bool objc_find_refs(RCore *core) { } if (classMethodsVA > to) { - eprintf ("Warning: Fuzzed binary or bug in here, checking next %"PFMT64x" !< %"PFMT64x"\n", classMethodsVA, to); + R_LOG_WARN ("Fuzzed binary or bug in here, checking next %"PFMT64x" !< %"PFMT64x, classMethodsVA, to); break; } for (va = classMethodsVA; va < to; va += objc2ClassMethSize) { diff --git a/libr/core/anal_tp.c b/libr/core/anal_tp.c index a106289fef..364aba4449 100644 --- a/libr/core/anal_tp.c +++ b/libr/core/anal_tp.c @@ -308,7 +308,7 @@ static void type_match(RCore *core, char *fcn_name, ut64 addr, ut64 baddr, const in_stack = true; } if (verbose && !strncmp (fcn_name, "sym.imp.", 8)) { - eprintf ("Warning: Missing function definition for '%s'\n", fcn_name + 8); + R_LOG_WARN ("Missing function definition for '%s'", fcn_name + 8); } if (!max) { if (!in_stack) { @@ -583,7 +583,7 @@ repeat: for (j = 0; j < bblist_size; j++) { bb = r_anal_get_block_at (core->anal, bblist[j]); if (!bb) { - eprintf ("Warning: basic block at 0x%08"PFMT64x" was removed during analysis.\n", bblist[j]); + R_LOG_WARN ("basic block at 0x%08"PFMT64x" was removed during analysis.", bblist[j]); retries--; free (bblist); goto repeat; @@ -636,7 +636,7 @@ repeat: if (i < bblist_size) { bb = r_anal_get_block_at (core->anal, bb_addr); if (!bb) { - eprintf ("Warning: basic block at 0x%08"PFMT64x" was removed during analysis.\n", bblist[i]); + R_LOG_WARN ("basic block at 0x%08"PFMT64x" was removed during analysis.", bblist[i]); retries--; free (bblist); goto repeat; diff --git a/libr/core/blaze.c b/libr/core/blaze.c index 8993e55360..87ec6d2aa4 100644 --- a/libr/core/blaze.c +++ b/libr/core/blaze.c @@ -38,7 +38,7 @@ static bool __is_data_block_cb(RAnalBlock *block, void *user) { static int __isdata(RCore *core, ut64 addr) { if (!r_io_is_valid_offset (core->io, addr, false)) { - // eprintf ("Warning: Invalid memory address at 0x%08"PFMT64x"\n", addr); + // R_LOG_WARN ("Invalid memory address at 0x%08"PFMT64x, addr); return 4; } diff --git a/libr/core/canal.c b/libr/core/canal.c index 5050ff51a5..44f10e307d 100644 --- a/libr/core/canal.c +++ b/libr/core/canal.c @@ -997,7 +997,7 @@ R_API RAnalOp* r_core_anal_op(RCore *core, ut64 addr, int mask) { if (!op->mnemonic && mask & R_ANAL_OP_MASK_DISASM) { RAsmOp asmop; if (core->anal->verbose) { - eprintf ("Warning: Implement RAnalOp.MASK_DISASM for current anal.arch. Using the sluggish RAsmOp fallback for now.\n"); + R_LOG_WARN ("Implement RAnalOp.MASK_DISASM for current anal.arch. Using the sluggish RAsmOp fallback for now."); } r_asm_set_pc (core->rasm, addr); r_asm_op_init (&asmop); @@ -1967,7 +1967,7 @@ R_API bool r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int dep if (core->io->va) { if (!r_io_is_valid_offset (core->io, at, !core->anal->opt.noncode)) { if (core->anal->verbose) { - eprintf ("Warning: Address not mapped or not executable at 0x%08"PFMT64x"\n", at); + R_LOG_WARN ("Address not mapped or not executable at 0x%08"PFMT64x, at); } return false; } @@ -3990,7 +3990,7 @@ R_API int r_core_anal_search(RCore *core, ut64 from, ut64 to, ut64 ref, int mode } } } else { - eprintf ("error: block size too small\n"); + R_LOG_ERROR ("error: block size too small"); } r_cons_break_pop (); free (buf); @@ -4085,17 +4085,17 @@ R_API int r_core_anal_search_xrefs(RCore *core, ut64 from, ut64 to, PJ *pj, int } if (core->blocksize <= OPSZ) { - eprintf ("Error: block size too small\n"); + R_LOG_ERROR ("block size too small"); return -1; } ut8 *buf = malloc (bsz); if (!buf) { - eprintf ("Error: cannot allocate a block\n"); + R_LOG_ERROR ("cannot allocate a block"); return -1; } ut8 *block = malloc (bsz); if (!block) { - eprintf ("Error: cannot allocate a temp block\n"); + R_LOG_ERROR ("cannot allocate a temp block"); free (buf); return -1; } @@ -4112,7 +4112,7 @@ R_API int r_core_anal_search_xrefs(RCore *core, ut64 from, ut64 to, PJ *pj, int } if (bsz < maxopsz) { // wtf - eprintf ("Error: Something is really wrong deep inside\n"); + R_LOG_ERROR ("Something is really wrong deep inside"); free (block); return -1; } @@ -4128,13 +4128,13 @@ R_API int r_core_anal_search_xrefs(RCore *core, ut64 from, ut64 to, PJ *pj, int (void)r_io_read_at (core->io, at, buf, bsz); memset (block, -1, bsz); if (!memcmp (buf, block, bsz)) { - // eprintf ("Error: skipping uninitialized block \n"); + // R_LOG_ERROR ("skipping uninitialized block "); at += ret; continue; } memset (block, 0, bsz); if (!memcmp (buf, block, bsz)) { - // eprintf ("Error: skipping uninitialized block \n"); + // R_LOG_ERROR ("skipping uninitialized block"); at += ret; continue; } @@ -5239,7 +5239,7 @@ R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) { return; } if (iend > MAX_SCAN_SIZE) { - eprintf ("Warning: Not going to analyze 0x%08"PFMT64x" bytes.\n", (ut64)iend); + R_LOG_WARN ("Not going to analyze 0x%08"PFMT64x" bytes.", (ut64)iend); return; } buf = malloc ((size_t)iend + 2); @@ -5261,7 +5261,7 @@ R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) { } const char *kspname = r_reg_get_name (core->anal->reg, R_REG_NAME_SP); if (R_STR_ISEMPTY (kspname)) { - eprintf ("Error: No =SP defined in the reg profile.\n"); + R_LOG_ERROR ("No =SP defined in the reg profile."); return; } char *spname = strdup (kspname); @@ -5420,7 +5420,7 @@ R_API void r_core_anal_esil(RCore *core, const char *str, const char *target) { } const char *sn = r_reg_get_name (core->anal->reg, R_REG_NAME_SN); if (!sn) { - eprintf ("Warning: No SN reg alias for current architecture.\n"); + R_LOG_WARN ("No SN reg alias for current architecture."); } if (sn && op.type == R_ANAL_OP_TYPE_SWI) { r_strf_buffer (64); @@ -5679,7 +5679,7 @@ R_IPI int r_core_search_value_in_range(RCore *core, bool relative, RInterval sea ut32 v32; ut16 v16; if (from >= to) { - eprintf ("Error: from must be lower than to\n"); + R_LOG_ERROR ("from must be lower than to"); return -1; } bool maybeThumb = false; @@ -5690,11 +5690,11 @@ R_IPI int r_core_search_value_in_range(RCore *core, bool relative, RInterval sea } if (vmin >= vmax) { - eprintf ("Error: vmin must be lower than vmax\n"); + R_LOG_ERROR ("vmin must be lower than vmax"); return -1; } if (to == UT64_MAX) { - eprintf ("Error: Invalid destination boundary\n"); + R_LOG_ERROR ("Invalid destination boundary"); return -1; } r_cons_break_push (NULL, NULL); @@ -5994,12 +5994,12 @@ R_API void r_core_anal_inflags(RCore *core, const char *glob) { continue; } if (a0 > a1) { - eprintf ("Warning: unsorted flag list 0x%"PFMT64x" 0x%"PFMT64x"\n", a0, a1); + R_LOG_WARN ("unsorted flag list 0x%"PFMT64x" 0x%"PFMT64x, a0, a1); continue; } st64 sz = a1 - a0; if (sz < 1 || sz > core->anal->opt.bb_max_size) { - eprintf ("Warning: invalid flag range from 0x%08"PFMT64x" to 0x%08"PFMT64x"\n", a0, a1); + R_LOG_WARN ("invalid flag range from 0x%08"PFMT64x" to 0x%08"PFMT64x, a0, a1); continue; } if (simple) { diff --git a/libr/core/casm.c b/libr/core/casm.c index 88f2e91ac8..c09280d7b9 100644 --- a/libr/core/casm.c +++ b/libr/core/casm.c @@ -90,12 +90,12 @@ R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut6 ut64 usrimm = r_num_math (core->num, inp); ut64 usrimm2 = inp_arg? r_num_math (core->num, inp_arg): usrimm; if (usrimm > usrimm2) { - eprintf ("Error: /ci : Invalid range\n"); + R_LOG_ERROR ("/ci : Invalid range"); return NULL; } if (core->blocksize < 8) { - eprintf ("error: block size too small\n"); + R_LOG_ERROR ("error: block size too small"); return NULL; } if (!(buf = (ut8 *)calloc (core->blocksize, 1))) { @@ -249,7 +249,7 @@ R_API RList *r_core_asm_strsearch(RCore *core, const char *input, ut64 from, ut6 if (maxhits) { count++; if (count >= maxhits) { - //eprintf ("Error: search.maxhits reached\n"); + //R_LOG_ERROR ("search.maxhits reached"); goto beach; } } diff --git a/libr/core/cbin.c b/libr/core/cbin.c index dffecc58ca..a1343177d9 100644 --- a/libr/core/cbin.c +++ b/libr/core/cbin.c @@ -260,7 +260,7 @@ R_API void r_core_bin_export_info(RCore *core, int mode) { fmtsize, v, 0, NULL, NULL); free (buf); if (res < 0) { - eprintf ("Warning: Cannot register invalid format (%s)\n", v); + R_LOG_WARN ("Cannot register invalid format (%s)", v); } } } @@ -781,11 +781,11 @@ R_API void r_core_anal_cc_init(RCore *core) { char *s = r_reg_profile_to_cc (core->anal->reg); if (s) { if (!r_anal_cc_set (core->anal, s)) { - eprintf ("Warning: Invalid CC from reg profile.\n"); + R_LOG_WARN ("Invalid CC from reg profile."); } free (s); } else { - eprintf ("Warning: Cannot derive CC from reg profile.\n"); + R_LOG_WARN ("Cannot derive CC from reg profile."); } } #else @@ -808,11 +808,11 @@ R_API void r_core_anal_cc_init(RCore *core) { char *s = r_reg_profile_to_cc (core->anal->reg); if (s) { if (!r_anal_cc_set (core->anal, s)) { - eprintf ("Warning: Invalid CC from reg profile.\n"); + R_LOG_WARN ("Invalid CC from reg profile."); } free (s); } else { - eprintf ("Warning: Cannot derive CC from reg profile.\n"); + R_LOG_WARN ("Cannot derive CC from reg profile."); } } R_FREE (cc->path); @@ -825,7 +825,7 @@ R_API void r_core_anal_cc_init(RCore *core) { cc->path = strdup (dbpath); } if (anal_arch && sdb_isempty (core->anal->sdb_cc)) { - eprintf ("Warning: Missing calling conventions for '%s' %d. Deriving it from the regprofile.\n", anal_arch, bits); + R_LOG_WARN ("Missing calling conventions for '%s' %d. Deriving it from the regprofile.", anal_arch, bits); } free (anal_arch); free (dbpath); @@ -1266,7 +1266,7 @@ R_API bool r_core_pdb_info(RCore *core, const char *file, PJ *pj, int mode) { if (core->bin->cur && core->bin->cur->o && core->bin->cur->o->baddr) { baddr = core->bin->cur->o->baddr; } else if (baddr == UT64_MAX) { - eprintf ("Warning: Cannot find base address, flags will probably be misplaced\n"); + R_LOG_WARN ("Cannot find base address, flags will probably be misplaced"); baddr = 0LL; } @@ -3893,7 +3893,7 @@ static void bin_pe_versioninfo(RCore *r, PJ *pj, int mode) { ut8 *val_utf8 = calloc (lenval * 2, 1); if (r_str_utf16_to_utf8 (key_utf8, lenkey * 2, key_utf16, lenkey, true) < 0 || r_str_utf16_to_utf8 (val_utf8, lenval * 2, val_utf16, lenval, true) < 0) { - eprintf ("Warning: Cannot decode utf16 to utf8\n"); + R_LOG_WARN ("Cannot decode utf16 to utf8"); } else if (IS_MODE_JSON (mode)) { pj_ks (pj, (char*)key_utf8, (char*)val_utf8); } else { diff --git a/libr/core/cconfig.c b/libr/core/cconfig.c index 8c88422072..7783d027dd 100644 --- a/libr/core/cconfig.c +++ b/libr/core/cconfig.c @@ -1355,7 +1355,7 @@ static bool cb_cfgcharset(void *user, void *data) { if (rc) { r_sys_setenv ("RABIN2_CHARSET", cf); } else { - eprintf ("Warning: Cannot load charset file '%s'.\n", cf); + R_LOG_WARN ("Cannot load charset file '%s'.", cf); } } return rc; @@ -1746,7 +1746,7 @@ static bool cb_dbg_execs(void *user, void *data) { } #else if (node->i_value) { - eprintf ("Warning: dbg.execs is not supported in this platform.\n"); + R_LOG_WARN ("dbg.execs is not supported in this platform."); } #endif return true; @@ -2287,7 +2287,7 @@ static bool cb_io_pava(void *user, void *data) { RConfigNode *node = (RConfigNode *) data; core->print->pava = node->i_value; if (node->i_value && core->io->va) { - eprintf ("Warning: You may probably want to disable io.va too.\n"); + R_LOG_WARN ("You may probably want to disable io.va too."); } return true; } @@ -3182,7 +3182,7 @@ static bool cb_linesabs(void *user, void *data) { ut64 to = r_num_math (core->num, (to_str && *to_str) ? to_str : "$s"); core->print->lines_cache_sz = r_core_lines_initcache (core, from, to); if (core->print->lines_cache_sz == -1) { - eprintf ("ERROR: \"lines.from\" and \"lines.to\" must be set\n"); + R_LOG_ERROR ("ERROR: \"lines.from\" and \"lines.to\" must be set"); } else { eprintf ("Found %d lines\n", core->print->lines_cache_sz-1); } diff --git a/libr/core/cfile.c b/libr/core/cfile.c index a4cd087b60..f763ee5d8c 100644 --- a/libr/core/cfile.c +++ b/libr/core/cfile.c @@ -160,7 +160,7 @@ R_API bool r_core_file_reopen(RCore *core, const char *args, int perm, int loadb ret = r_core_bin_load (core, obinfilepath, baddr); r_core_bin_update_arch_bits (core); if (!ret) { - eprintf ("Error: Failed to reload rbin for: %s\n", path); + R_LOG_ERROR ("Failed to reload rbin for: %s", path); } origoff = r_num_math (core->num, "entry0"); } diff --git a/libr/core/cmd.c b/libr/core/cmd.c index bf48f1c374..293137929f 100644 --- a/libr/core/cmd.c +++ b/libr/core/cmd.c @@ -1208,7 +1208,7 @@ R_API bool r_core_run_script(RCore *core, const char *file) { r_list_foreach (core->scriptstack, iter, name) { if (!strcmp (file, name)) { - eprintf ("Warning: ignored nested source: %s\n", file); + R_LOG_WARN ("ignored nested source: %s", file); return false; } } @@ -1344,14 +1344,14 @@ R_API bool r_core_run_script(RCore *core, const char *file) { if (r_lang_use (core->lang, "qjs")) { r_lang_run_file (core->lang, file); } else { - eprintf ("Error: r2pm -ci rlang-qjs\n"); + R_LOG_ERROR ("r2pm -ci rlang-qjs"); } ret = 1; } else if (!strcmp (ext, "wren")) { if (r_lang_use (core->lang, "wren")) { r_lang_run_file (core->lang, file); } else { - eprintf ("Error: r2pm -ci rlang-wren\n"); + R_LOG_ERROR ("r2pm -ci rlang-wren"); } ret = 1; } else if (!strcmp (ext, "pl")) { @@ -1674,7 +1674,7 @@ static void load_table_asciiart(RCore *core, RTable *t, RList *lines) { RListIter *iter2; ncols = 0; if (r_list_length (t->cols) > 0) { - eprintf ("Warning: Not re-adding headers. Use ,- to reset the table.\n"); + R_LOG_WARN ("Not re-adding headers. Use ,- to reset the table."); continue; } r_list_foreach (args, iter2, arg) { @@ -2960,7 +2960,7 @@ static int cmd_system(void *data, const char *input) { r_cons_write (out, olen); free (out); free (cmd); - } //else eprintf ("Error setting up system environment\n"); + } //else R_LOG_ERROR ("Error setting up system environment"); } else { eprintf ("History saved to "R2_HOME_HISTORY"\n"); r_line_hist_save (R2_HOME_HISTORY); @@ -2991,7 +2991,7 @@ static int cmd_system(void *data, const char *input) { if (cmd) { r_core_cmd0 (core, cmd); } - //else eprintf ("Error setting up system environment\n"); + //else R_LOG_ERROR ("Error setting up system environment"); } else { char *cmd = r_core_sysenv_begin (core, input); if (cmd) { @@ -3004,7 +3004,7 @@ static int cmd_system(void *data, const char *input) { r_core_sysenv_end (core, input); free (cmd); } else { - eprintf ("Error setting up system environment\n"); + R_LOG_ERROR ("Error setting up system environment"); } } break; @@ -4291,7 +4291,7 @@ repeat_arroba: r_core_block_read (core); } } else { - eprintf ("Error: Invalid hexpairs for @x:\n"); + R_LOG_ERROR ("Invalid hexpairs for @x:"); } free (buf); } else { diff --git a/libr/core/cmd_write.c b/libr/core/cmd_write.c index 52573b7f0d..5925bfe32b 100644 --- a/libr/core/cmd_write.c +++ b/libr/core/cmd_write.c @@ -219,7 +219,7 @@ R_API int cmd_write_hexpair(RCore* core, const char* pairs) { } r_core_block_read (core); } else { - R_LOG_ERROR ("Error: invalid hexpair string"); + R_LOG_ERROR ("invalid hexpair string"); r_core_return_value (core, R_CMD_RC_FAILURE); } free (buf); diff --git a/libr/core/cplugin.c b/libr/core/cplugin.c index 62f191c615..c0f94202a6 100644 --- a/libr/core/cplugin.c +++ b/libr/core/cplugin.c @@ -42,7 +42,7 @@ R_API bool r_core_plugin_init(RCmd *cmd) { cmd->plist = r_list_newf (NULL); // memleak or dblfree for (i = 0; cmd_static_plugins[i]; i++) { if (!r_core_plugin_add (cmd, cmd_static_plugins[i])) { - eprintf ("Error loading cmd plugin\n"); + R_LOG_ERROR ("Error loading cmd plugin"); return false; } } diff --git a/libr/core/esil2c.c b/libr/core/esil2c.c index 96934f51fa..913e2aad23 100644 --- a/libr/core/esil2c.c +++ b/libr/core/esil2c.c @@ -10,7 +10,7 @@ static char *esil2c(RCore *core, RAnalEsil *esil, const char *expr) { RStrBuf *sb = r_strbuf_new (""); user->sb = sb; if (!r_anal_esil_parse (esil, expr)) { - eprintf ("ERROR\n"); + R_LOG_ERROR ("ERROR"); } user->sb = NULL; return r_strbuf_drain (sb); diff --git a/libr/core/linux_heap_glibc.c b/libr/core/linux_heap_glibc.c index aec750ea8d..af11c6c4d9 100644 --- a/libr/core/linux_heap_glibc.c +++ b/libr/core/linux_heap_glibc.c @@ -446,9 +446,9 @@ static bool GH(r_resolve_main_arena)(RCore *core, GHT *m_arena) { if (libc_addr_sta == GHT_MAX || libc_addr_end == GHT_MAX) { if (r_config_get_b (core->config, "cfg.debug")) { - eprintf ("Warning: Can't find glibc mapped in memory (see dm)\n"); + R_LOG_WARN ("Can't find glibc mapped in memory (see dm)"); } else { - eprintf ("Warning: Can't find arena mapped in memory (see om)\n"); + R_LOG_WARN ("Can't find arena mapped in memory (see om)"); } return false; } @@ -487,7 +487,7 @@ static bool GH(r_resolve_main_arena)(RCore *core, GHT *m_arena) { } addr_srch += sizeof (GHT); } - eprintf ("Warning: Can't find main_arena in mapped memory\n"); + R_LOG_WARN ("Can't find main_arena in mapped memory"); free (ta); return false; } @@ -762,7 +762,7 @@ static void GH(print_heap_bin)(RCore *core, GHT m_arena, MallocState *main_arena case 'g': // dmhbg [bin_num] num_bin = r_num_get (NULL, input + j) - 1; if (num_bin > NBINS - 2) { - eprintf ("Error: 0 < bin <= %d\n", NBINS - 1); + R_LOG_ERROR ("0 < bin <= %d", NBINS - 1); break; } PRINTF_YA (" Bin %03"PFMT64u":\n", (ut64)num_bin + 1); @@ -889,7 +889,7 @@ void GH(print_heap_fastbin)(RCore *core, GHT m_arena, MallocState *main_arena, G case ' ': // dmhf [bin_num] num_bin = r_num_get (NULL, input) - 1; if (num_bin >= NFASTBINS) { - eprintf ("Error: 0 < bin <= %d\n", NFASTBINS); + R_LOG_ERROR ("0 < bin <= %d", NFASTBINS); break; } if (GH(print_single_linked_list_bin)(core, main_arena, m_arena, offset, num_bin, demangle)) { diff --git a/libr/core/linux_heap_jemalloc.c b/libr/core/linux_heap_jemalloc.c index 6f2ee9302c..097d729d02 100644 --- a/libr/core/linux_heap_jemalloc.c +++ b/libr/core/linux_heap_jemalloc.c @@ -109,14 +109,14 @@ static bool GH(r_resolve_jemalloc)(RCore *core, char *symname, ut64 *symbol) { } } if (!path) { - eprintf ("Warning: cannot find jemalloc mapped in memory (see `dm`)\n"); + R_LOG_WARN ("cannot find jemalloc mapped in memory (see `dm`)"); return false; } #if __linux__ bool is_debug_file = GH(je_matched)(path, "/usr/local/lib"); if (!is_debug_file) { - eprintf ("Warning: Cannot find libjemalloc.so.2 in /usr/local/lib\n"); + R_LOG_WARN ("Cannot find libjemalloc.so.2 in /usr/local/lib"); return false; } if (r_file_exists (path)) { @@ -202,7 +202,7 @@ static void GH(jemalloc_get_chunks)(RCore *core, const char *input) { extent_node_t *head = R_NEW0 (extent_node_t); if (!node || !head) { - eprintf ("Error calling calloc\n"); + R_LOG_ERROR ("Error calling calloc"); free (ar); free (node); free (head); @@ -367,7 +367,7 @@ static void GH(jemalloc_get_bins)(RCore *core, const char *input) { break; } if (!GH(r_resolve_jemalloc)(core, "je_arena_bin_info", &bin_info)) { - eprintf ("Error resolving je_arena_bin_info\n"); + R_LOG_ERROR ("Error resolving je_arena_bin_info"); R_FREE (b); break; } @@ -437,7 +437,7 @@ static void GH(jemalloc_get_runs)(RCore *core, const char *input) { arena_chunk_t *c = R_NEW0 (arena_chunk_t); if (!c) { - eprintf ("Error calling calloc\n"); + R_LOG_ERROR ("Error calling calloc"); return; } @@ -445,11 +445,11 @@ static void GH(jemalloc_get_runs)(RCore *core, const char *input) { chunk = r_num_math (core->num, input); if (!GH(r_resolve_jemalloc)(core, "je_chunk_npages", &npages)) { - eprintf ("Error resolving je_chunk_npages\n"); + R_LOG_ERROR ("Error resolving je_chunk_npages"); return; } if (!GH(r_resolve_jemalloc)(core, "je_chunksize_mask", &chunksize_mask)) { - eprintf ("Error resolving je_chunksize_mask\n"); + R_LOG_ERROR ("Error resolving je_chunksize_mask"); return; } if (!GH(r_resolve_jemalloc)(core, "je_map_bias", &map_bias)) { @@ -480,7 +480,7 @@ static void GH(jemalloc_get_runs)(RCore *core, const char *input) { arena_run_t *r = R_NEW0 (arena_run_t); if (!r) { - eprintf ("Error calling calloc\n"); + R_LOG_ERROR ("Error calling calloc"); return; } for (pageind = map_bias; pageind < npages; pageind++) { diff --git a/libr/core/p/core_java.c b/libr/core/p/core_java.c index e9bff63b7e..d2d1c1e508 100644 --- a/libr/core/p/core_java.c +++ b/libr/core/p/core_java.c @@ -874,7 +874,7 @@ static int r_cmd_java_handle_replace_classname_value(RCore *core, const char *cm core, obj, idx, addr, (const ut8 *)result, res_len); if (res == false) { - eprintf ("ERROR: r_cmd_java: Failed to write bytes or reload the binary.\n"); + R_LOG_ERROR ("ERROR: r_cmd_java: Failed to write bytes or reload the binary."); } } free (result); @@ -1739,7 +1739,7 @@ static int r_cmd_java_print_method_num_name(RBinJavaObj *obj) { static int r_cmd_java_print_field_summary(RBinJavaObj *obj, ut16 idx) { int res = r_bin_java_print_field_idx_summary (obj, idx); if (res == false) { - eprintf ("Error: Field or Method @ index (%d) not found in the RBinJavaObj.\n", idx); + R_LOG_ERROR ("Field or Method @ index (%d) not found in the RBinJavaObj.", idx); res = true; } return res; @@ -1757,7 +1757,7 @@ static int r_cmd_java_print_field_name(RBinJavaObj *obj, ut16 idx) { if (res) { r_cons_println (res); } else { - eprintf ("Error: Field or Method @ index (%d) not found in the RBinJavaObj.\n", idx); + R_LOG_ERROR ("Field or Method @ index (%d) not found in the RBinJavaObj.", idx); } free (res); return true; @@ -1766,7 +1766,7 @@ static int r_cmd_java_print_field_name(RBinJavaObj *obj, ut16 idx) { static int r_cmd_java_print_method_summary(RBinJavaObj *obj, ut16 idx) { int res = r_bin_java_print_method_idx_summary (obj, idx); if (res == false) { - eprintf ("Error: Field or Method @ index (%d) not found in the RBinJavaObj.\n", idx); + R_LOG_ERROR ("Field or Method @ index (%d) not found in the RBinJavaObj.", idx); res = true; } return res; @@ -1784,7 +1784,7 @@ static int r_cmd_java_print_method_name(RBinJavaObj *obj, ut16 idx) { if (res) { r_cons_println (res); } else { - eprintf ("Error: Field or Method @ index (%d) not found in the RBinJavaObj.\n", idx); + R_LOG_ERROR ("Field or Method @ index (%d) not found in the RBinJavaObj.", idx); } free (res); return true; diff --git a/libr/core/project.c b/libr/core/project.c index 097a7bd82b..fdcb859fdd 100644 --- a/libr/core/project.c +++ b/libr/core/project.c @@ -669,7 +669,7 @@ R_API bool r_core_project_save(RCore *core, const char *prj_name) { char *prj_bin_file = r_str_newf ("%s" R_SYS_DIR "%s", prj_bin_dir, bin_filename); r_sys_mkdirp (prj_bin_dir); if (!r_file_copy (bin_file, prj_bin_file)) { - eprintf ("Warning: Cannot copy '%s' into '%s'\n", bin_file, prj_bin_file); + R_LOG_WARN ("Cannot copy '%s' into '%s'", bin_file, prj_bin_file); } free (prj_bin_file); free (prj_bin_dir); diff --git a/libr/core/rtr.c b/libr/core/rtr.c index 0634f6b465..357cedfc35 100644 --- a/libr/core/rtr.c +++ b/libr/core/rtr.c @@ -659,7 +659,7 @@ R_API void r_core_rtr_pushout(RCore *core, const char *input) { } } if (!(cmd = strchr (input, ' '))) { - eprintf ("Error\n"); + R_LOG_ERROR ("Error"); return; } } else { @@ -667,18 +667,18 @@ R_API void r_core_rtr_pushout(RCore *core, const char *input) { } if (!rtr_host[rtr_n].fd || !rtr_host[rtr_n].fd->fd) { - eprintf ("Error: Unknown host\n"); + R_LOG_ERROR ("Unknown host"); return; } if (!(str = r_core_cmd_str (core, cmd))) { - eprintf ("Error: radare_cmd_str returned NULL\n"); + R_LOG_ERROR ("radare_cmd_str returned NULL"); return; } switch (rtr_host[rtr_n].proto) { case RTR_PROTOCOL_RAP: - eprintf ("Error: Cannot use '=<' to a rap connection.\n"); + R_LOG_ERROR ("Cannot use '=<' to a rap connection."); break; case RTR_PROTOCOL_UNIX: r_socket_write (rtr_host[rtr_n].fd, str, strlen (str)); @@ -774,7 +774,7 @@ R_API void r_core_rtr_add(RCore *core, const char *_input) { // it's fine to listen without serving a file } else { file = "cmd/"; - eprintf ("Error: Missing '/'\n"); + R_LOG_ERROR ("Missing '/'"); //c:wreturn; } } @@ -786,7 +786,7 @@ R_API void r_core_rtr_add(RCore *core, const char *_input) { fd = r_socket_new (false); if (!fd) { - eprintf ("Error: Cannot create new socket\n"); + R_LOG_ERROR ("Cannot create new socket"); return; } switch (proto) { @@ -807,7 +807,7 @@ R_API void r_core_rtr_add(RCore *core, const char *_input) { break; case RTR_PROTOCOL_RAP: if (!r_socket_connect_tcp (fd, host, port, timeout)) { //TODO: Use rap.ssl - eprintf ("Error: Cannot connect to '%s' (%s)\n", host, port); + R_LOG_ERROR ("Cannot connect to '%s' (%s)", host, port); r_socket_free (fd); return; } else { @@ -818,7 +818,7 @@ R_API void r_core_rtr_add(RCore *core, const char *_input) { case RTR_PROTOCOL_UNIX: if (!r_socket_connect_unix (fd, host)) { r_core_return_value (core, R_CMD_RC_FAILURE); - eprintf ("Error: Cannot connect to 'unix://%s'\n", host); + R_LOG_ERROR ("Cannot connect to 'unix://%s'", host); r_socket_free (fd); return; } @@ -828,7 +828,7 @@ R_API void r_core_rtr_add(RCore *core, const char *_input) { case RTR_PROTOCOL_TCP: if (!r_socket_connect_tcp (fd, host, port, timeout)) { //TODO: Use rap.ssl r_core_return_value (core, R_CMD_RC_FAILURE); - eprintf ("Error: Cannot connect to '%s' (%s)\n", host, port); + R_LOG_ERROR ("Cannot connect to '%s' (%s)", host, port); r_socket_free (fd); return; } @@ -838,7 +838,7 @@ R_API void r_core_rtr_add(RCore *core, const char *_input) { case RTR_PROTOCOL_UDP: if (!r_socket_connect_udp (fd, host, port, timeout)) { //TODO: Use rap.ssl r_core_return_value (core, R_CMD_RC_FAILURE); - eprintf ("Error: Cannot connect to '%s' (%s)\n", host, port); + R_LOG_ERROR ("Cannot connect to '%s' (%s)", host, port); r_socket_free (fd); return; } @@ -1025,7 +1025,7 @@ R_API void r_core_rtr_cmd(RCore *core, const char *input) { } if (!rtr_host[rtr_n].fd) { - eprintf ("Error: Unknown host\n"); + R_LOG_ERROR ("Unknown host"); r_core_return_value (core, R_CMD_RC_FAILURE); return; } @@ -1039,7 +1039,7 @@ R_API void r_core_rtr_cmd(RCore *core, const char *input) { r_socket_close (s); r_strf_var (portstr, 32, "%d", rh->port); if (!r_socket_connect (s, rh->host, portstr, R_SOCKET_PROTO_TCP, 0)) { - eprintf ("Error: Cannot connect to '%s' (%d)\n", rh->host, rh->port); + R_LOG_ERROR ("Cannot connect to '%s' (%d)", rh->host, rh->port); r_socket_free (s); return; } @@ -1048,7 +1048,7 @@ R_API void r_core_rtr_cmd(RCore *core, const char *input) { int maxlen = 4096; // r_read_le32 (blen); char *cmd_output = calloc (1, maxlen + 1); if (!cmd_output) { - eprintf ("Error: Allocating cmd output\n"); + R_LOG_ERROR ("Allocating cmd output"); return; } (void)r_socket_read_block (s, (ut8*)cmd_output, maxlen); @@ -1094,7 +1094,7 @@ R_API void r_core_rtr_cmd(RCore *core, const char *input) { free (cmd_output); return; } - eprintf ("Error: Unknown protocol\n"); + R_LOG_ERROR ("Unknown protocol"); } // TODO: support len for binary data? @@ -1345,7 +1345,7 @@ R_API int r_core_rtr_cmds(RCore *core, const char *port) { s->local = r_config_get_i (core->config, "tcp.islocal"); if (!r_socket_listen (s, port, NULL)) { - eprintf ("Error listening on port %s\n", port); + R_LOG_ERROR ("Error listening on port %s", port); r_socket_free (s); return false; } diff --git a/libr/core/rtr_http.c b/libr/core/rtr_http.c index b7ff28a186..7a83688ba4 100644 --- a/libr/core/rtr_http.c +++ b/libr/core/rtr_http.c @@ -531,7 +531,7 @@ static RThreadFunctionRet r_core_rtr_http_thread(RThread *th) { if (!ht || !ht->core) { return false; } - eprintf ("Warning: Background webserver requires http.sandbox=false to run properly\n"); + R_LOG_WARN ("Background webserver requires http.sandbox=false to run properly"); int ret = r_core_rtr_http_run (ht->core, ht->launch, ht->browse, ht->path); R_FREE (ht->path); if (ret) { diff --git a/libr/core/rvc.c b/libr/core/rvc.c index d00f5c0cfa..346e3f640f 100644 --- a/libr/core/rvc.c +++ b/libr/core/rvc.c @@ -134,7 +134,7 @@ static bool repo_exists(const char *path) { break; } if (!r_file_is_directory (files[i]) && !r_file_exists (files[i])) { - eprintf ("Error: Corrupt repo: %s doesn't exist\n", + R_LOG_ERROR ("Corrupt repo: %s doesn't exist", files[i]); r = false; break; diff --git a/libr/core/vasm.c b/libr/core/vasm.c index b732c51c49..d9287eda5d 100644 --- a/libr/core/vasm.c +++ b/libr/core/vasm.c @@ -82,14 +82,14 @@ R_API void r_core_visual_asm(RCore *core, ut64 off) { if (cva.acode && cva.acode->len > 0) { if (r_cons_yesno ('y', "Save changes? (Y/n)")) { if (!r_io_write_at (core->io, off, cva.acode->bytes, cva.acode->len)) { - eprintf ("ERROR: Cannot write in here, check map permissions or reopen the file with oo+\n"); + R_LOG_ERROR ("ERROR: Cannot write in here, check map permissions or reopen the file with oo+"); r_cons_any_key (NULL); } // r_core_cmdf (core, "wx %s @ 0x%"PFMT64x, cva.acode->buf_hex, off); } #if 0 } else if (!cva.acode || cva.acode->len == 0) { - eprintf ("ERROR: Cannot assemble those instructions\n"); + R_LOG_ERROR ("ERROR: Cannot assemble those instructions"); // r_cons_any_key (NULL); #endif } diff --git a/libr/core/vmenus.c b/libr/core/vmenus.c index 30fe11678f..0666adaff2 100644 --- a/libr/core/vmenus.c +++ b/libr/core/vmenus.c @@ -4075,7 +4075,7 @@ onemoretime: int rc = r_anal_op (core->anal, &op, off, core->block + off - core->offset, 32, R_ANAL_OP_MASK_BASIC); if (rc < 1) { - eprintf ("Error analyzing opcode at 0x%08"PFMT64x"\n", off); + R_LOG_ERROR ("Error analyzing opcode at 0x%08"PFMT64x, off); } else { tgt_addr = op.jump != UT64_MAX ? op.jump : op.ptr; RAnalVar *var = r_anal_get_used_function_var (core->anal, op.addr); diff --git a/libr/core/yank.c b/libr/core/yank.c index 38a5837102..70a2a39dcd 100644 --- a/libr/core/yank.c +++ b/libr/core/yank.c @@ -419,13 +419,13 @@ R_API bool r_core_yank_file_ex(RCore *core, const char *input) { adv = consume_chars (input, ' '); len = r_num_math (core->num, input + adv); if (len == 0) { - eprintf ("ERROR: Number of bytes read must be > 0\n"); + R_LOG_ERROR ("ERROR: Number of bytes read must be > 0"); return res; } // get the addr/offset from in the file we want to read adv += find_next_char (input + adv, ' '); if (adv == 0) { - eprintf ("ERROR: Address must be specified\n"); + R_LOG_ERROR ("ERROR: Address must be specified"); return res; } adv++; @@ -435,7 +435,7 @@ R_API bool r_core_yank_file_ex(RCore *core, const char *input) { adv += find_next_char (input + adv, ' '); if (adv == 0) { - eprintf ("ERROR: File must be specified\n"); + R_LOG_ERROR ("ERROR: File must be specified"); return res; } adv++; diff --git a/libr/debug/debug.c b/libr/debug/debug.c index 639c29cbe2..e8cfdcecf4 100644 --- a/libr/debug/debug.c +++ b/libr/debug/debug.c @@ -300,13 +300,13 @@ R_API RBreakpointItem *r_debug_bp_add(RDebug *dbg, ut64 addr, int hw, bool watch } perm = ((map->perm & 1) << 2) | (map->perm & 2) | ((map->perm & 4) >> 2); if (!(perm & R_BP_PROT_EXEC)) { - eprintf ("Warning: setting bp within mapped memory without exec perm\n"); + R_LOG_WARN ("setting bp within mapped memory without exec perm"); } break; } } if (!valid) { - eprintf ("Warning: module's base addr + delta is not a valid address\n"); + R_LOG_WARN ("module's base addr + delta is not a valid address"); free (module_name); return NULL; } @@ -1140,7 +1140,7 @@ R_API int r_debug_step_over(RDebug *dbg, int steps) { R_API bool r_debug_goto_cnum(RDebug *dbg, ut32 cnum) { if (cnum > dbg->session->maxcnum) { - eprintf ("Error: out of cnum range\n"); + R_LOG_ERROR ("out of cnum range"); return false; } dbg->session->cnum = cnum; diff --git a/libr/debug/dsession.c b/libr/debug/dsession.c index b2ff910419..0bcfb73aa1 100644 --- a/libr/debug/dsession.c +++ b/libr/debug/dsession.c @@ -220,7 +220,7 @@ R_API bool r_debug_session_add_reg_change(RDebugSession *session, int arena, ut6 if (!vreg) { vreg = r_vector_new (sizeof (RDebugChangeReg), NULL, NULL); if (!vreg) { - eprintf ("Error: creating a register vector.\n"); + R_LOG_ERROR ("creating a register vector."); return false; } ht_up_insert (session->registers, offset | (arena << 16), vreg); @@ -235,7 +235,7 @@ R_API bool r_debug_session_add_mem_change(RDebugSession *session, ut64 addr, ut8 if (!vmem) { vmem = r_vector_new (sizeof (RDebugChangeMem), NULL, NULL); if (!vmem) { - eprintf ("Error: creating a memory vector.\n"); + R_LOG_ERROR ("creating a memory vector."); return false; } ht_up_insert (session->memory, addr, vmem); @@ -412,7 +412,7 @@ R_API void r_debug_session_serialize(RDebugSession *session, Sdb *db) { static bool session_sdb_save(Sdb *db, const char *path) { char *filename; if (!r_file_is_directory (path)) { - eprintf ("Error: %s is not a directory\n", path); + R_LOG_ERROR ("%s is not a directory", path); return false; } @@ -481,7 +481,7 @@ static bool deserialize_memory_cb(void *user, const char *addr, const char *v) { // Insert a new vector into `memory` HtUP at `addr` RVector *vmem = r_vector_new (sizeof (RDebugChangeMem), NULL, NULL); if (!vmem) { - eprintf ("Error: failed to allocate RVector vmem.\n"); + R_LOG_ERROR ("failed to allocate RVector vmem."); free (json_str); r_json_free (reg_json); return false; @@ -530,7 +530,7 @@ static bool deserialize_registers_cb(void *user, const char *addr, const char *v HtUP *registers = user; RVector *vreg = r_vector_new (sizeof (RDebugChangeReg), NULL, NULL); if (!vreg) { - eprintf ("Error: failed to allocate RVector vreg.\n"); + R_LOG_ERROR ("failed to allocate RVector vreg."); r_json_free (reg_json); free (json_str); return true; @@ -639,7 +639,7 @@ static bool deserialize_checkpoints_cb(void *user, const char *cnum, const char RDebugSnap *snap = R_NEW0 (RDebugSnap); if (!snap) { - eprintf ("Error: failed to allocate RDebugSnap snap\n"); + R_LOG_ERROR ("failed to allocate RDebugSnap snap"); continue; } snap->name = strdup (namej->str_value); @@ -667,7 +667,7 @@ static void deserialize_checkpoints(Sdb *db, RVector *checkpoints) { static bool session_sdb_load_ns(Sdb *db, const char *nspath, const char *filename) { Sdb *tmpdb = sdb_new0 (); if (sdb_open (tmpdb, filename) == -1) { - eprintf ("Error: failed to load %s into sdb\n", filename); + R_LOG_ERROR ("failed to load %s into sdb", filename); sdb_free (tmpdb); return false; } @@ -711,7 +711,7 @@ R_API void r_debug_session_deserialize(RDebugSession *session, Sdb *db) { #define DESERIALIZE(ns, func) do { \ subdb = sdb_ns (db, ns, false); \ if (!subdb) { \ - eprintf ("Error: missing " ns " namespace\n"); \ + R_LOG_ERROR ("missing " ns " namespace"); \ return; \ } \ func; \ diff --git a/libr/debug/p/debug_bf.c b/libr/debug/p/debug_bf.c index 5ce44d4adf..7cbdd89829 100644 --- a/libr/debug/p/debug_bf.c +++ b/libr/debug/p/debug_bf.c @@ -34,7 +34,7 @@ static bool is_io_bf(RDebug *dbg) { return true; } } - eprintf ("error: the iodesc data is not brainfuck friendly\n"); + R_LOG_ERROR ("error: the iodesc data is not brainfuck friendly"); return false; } diff --git a/libr/debug/p/debug_bochs.c b/libr/debug/p/debug_bochs.c index a66f0fe56a..a53c02d0a1 100644 --- a/libr/debug/p/debug_bochs.c +++ b/libr/debug/p/debug_bochs.c @@ -24,7 +24,7 @@ static bool isBochs(RDebug *dbg) { return true; } } - eprintf ("error: the iodesc data is not bochs friendly\n"); + R_LOG_ERROR ("error: the iodesc data is not bochs friendly"); return false; } diff --git a/libr/debug/p/debug_gdb.c b/libr/debug/p/debug_gdb.c index 7ad3c354b8..227920e7a1 100644 --- a/libr/debug/p/debug_gdb.c +++ b/libr/debug/p/debug_gdb.c @@ -382,7 +382,7 @@ static bool r_debug_gdb_attach(RDebug *dbg, int pid) { int bits = dbg->anal->config->bits; gdbr_set_architecture (desc, arch, bits); } else { - eprintf ("ERROR: Underlying IO descriptor is not a GDB one..\n"); + R_LOG_ERROR ("ERROR: Underlying IO descriptor is not a GDB one.."); } } return true; diff --git a/libr/debug/p/debug_native.c b/libr/debug/p/debug_native.c index e2a442a713..cefc1a91ee 100644 --- a/libr/debug/p/debug_native.c +++ b/libr/debug/p/debug_native.c @@ -97,7 +97,7 @@ static int r_debug_handle_signals(RDebug *dbg) { #if __KFBSD__ return bsd_handle_signals (dbg); #else - eprintf ("Warning: signal handling is not supported on this platform\n"); + R_LOG_WARN ("signal handling is not supported on this platform"); return 0; #endif } @@ -239,7 +239,7 @@ static bool r_debug_native_continue(RDebug *dbg, int pid, int tid, int sig) { r_list_foreach (dbg->threads, it, th) { ret = r_debug_ptrace (dbg, PTRACE_CONT, th->pid, 0, 0); if (ret) { - eprintf ("Error: (%d) is running or dead.\n", th->pid); + R_LOG_ERROR ("(%d) is running or dead.", th->pid); } } } else { @@ -301,7 +301,7 @@ static RDebugReasonType r_debug_native_wait(RDebug *dbg, int pid) { RW32Dw *wrap = dbg->user; if (pid == -1) { - eprintf ("ERROR: r_debug_native_wait called with pid -1\n"); + R_LOG_ERROR ("ERROR: r_debug_native_wait called with pid -1"); return R_DEBUG_REASON_ERROR; } @@ -428,7 +428,7 @@ static RDebugReasonType r_debug_native_wait(RDebug *dbg, int pid) { RDebugReasonType reason = R_DEBUG_REASON_UNKNOWN; if (pid == -1) { - eprintf ("ERROR: r_debug_native_wait called with pid -1\n"); + R_LOG_ERROR ("ERROR: r_debug_native_wait called with pid -1"); return R_DEBUG_REASON_ERROR; } @@ -441,7 +441,7 @@ static RDebugReasonType r_debug_native_wait(RDebug *dbg, int pid) { RDebugReasonType reason = R_DEBUG_REASON_UNKNOWN; if (pid == -1) { - eprintf ("ERROR: r_debug_native_wait called with pid -1\n"); + R_LOG_ERROR ("ERROR: r_debug_native_wait called with pid -1"); return R_DEBUG_REASON_ERROR; } @@ -1587,7 +1587,7 @@ static int r_debug_setup_ownership(int fd, RDebug *dbg) { RDebugInfo *info = r_debug_info (dbg, NULL); if (!info) { - eprintf ("Error while getting debug info.\n"); + R_LOG_ERROR ("Error while getting debug info."); return -1; } fchown (fd, info->uid, info->gid); diff --git a/libr/debug/p/debug_rap.c b/libr/debug/p/debug_rap.c index 96edaa6466..dd9f56fe08 100644 --- a/libr/debug/p/debug_rap.c +++ b/libr/debug/p/debug_rap.c @@ -35,7 +35,7 @@ static bool __rap_attach(RDebug *dbg, int pid) { if (!strcmp ("rap", d->plugin->name)) { eprintf ("SUCCESS: rap attach with inferior rap rio worked\n"); } else { - eprintf ("ERROR: Underlying IO descriptor is not a rap one..\n"); + R_LOG_ERROR ("ERROR: Underlying IO descriptor is not a rap one.."); } } return true; diff --git a/libr/debug/p/native/linux/linux_coredump.c b/libr/debug/p/native/linux/linux_coredump.c index d2a1b0d68d..d56714558c 100644 --- a/libr/debug/p/native/linux/linux_coredump.c +++ b/libr/debug/p/native/linux/linux_coredump.c @@ -822,7 +822,7 @@ static proc_per_process_t *get_proc_process_content(RDebug *dbg) { } if (!p->num_threads || p->num_threads < 1) { free (p); - eprintf ("Warning: number of threads is < 1\n"); + R_LOG_WARN ("number of threads is < 1"); return NULL; } file = r_strf ("/proc/%d/status", dbg->pid); diff --git a/libr/debug/p/native/windows/windows_debug.c b/libr/debug/p/native/windows/windows_debug.c index 09245f9e9b..9d2db21f58 100644 --- a/libr/debug/p/native/windows/windows_debug.c +++ b/libr/debug/p/native/windows/windows_debug.c @@ -48,7 +48,7 @@ static PTHREAD_ITEM __r_debug_thread_add(RDebug *dbg, DWORD pid, DWORD tid, HAND } pthread = R_NEW0 (THREAD_ITEM); if (!pthread) { - R_LOG_ERROR ("__r_debug_thread_add: Memory allocation failed.\n"); + R_LOG_ERROR ("__r_debug_thread_add: Memory allocation failed."); return NULL; } *pthread = th; diff --git a/libr/debug/p/native/windows/windows_message.c b/libr/debug/p/native/windows/windows_message.c index 1b195ad661..444c1de349 100644 --- a/libr/debug/p/native/windows/windows_message.c +++ b/libr/debug/p/native/windows/windows_message.c @@ -316,7 +316,7 @@ R_API void r_w32_identify_window(void) { return; } if (!win) { - eprintf ("Error trying to get information from 0x%08"PFMT64x"\n", (ut64)hwnd); + R_LOG_ERROR ("Error trying to get information from 0x%08"PFMT64x, (ut64)hwnd); return; } RTable *tbl = __create_window_table (); diff --git a/libr/debug/p/native/xnu/trap_x86.c b/libr/debug/p/native/xnu/trap_x86.c index b10414b3c2..f3489eb04c 100644 --- a/libr/debug/p/native/xnu/trap_x86.c +++ b/libr/debug/p/native/xnu/trap_x86.c @@ -8,7 +8,7 @@ static bool xnu_x86_hwstep_enable64(RDebug *dbg, bool enable) { xnu_thread_t *th = get_xnu_thread (dbg, dbg->tid); ret = xnu_thread_get_gpr (dbg, th); if (!ret) { - eprintf ("error to get gpr registers in trace bit intel\n"); + R_LOG_ERROR ("error to get gpr registers in trace bit intel"); return false; } state = (R_REG_T *)&th->gpr; @@ -23,7 +23,7 @@ static bool xnu_x86_hwstep_enable64(RDebug *dbg, bool enable) { return false; } if (!xnu_thread_set_gpr (dbg, th)) { - eprintf ("error xnu_thread_set_gpr in modify_trace_bit intel\n"); + R_LOG_ERROR ("error xnu_thread_set_gpr in modify_trace_bit intel"); return false; } return true; @@ -34,7 +34,7 @@ static bool xnu_x86_hwstep_enable32(RDebug *dbg, bool enable) { xnu_thread_t *th = get_xnu_thread (dbg, dbg->tid); int ret = xnu_thread_get_gpr (dbg, th); if (!ret) { - eprintf ("error to get gpr registers in trace bit intel\n"); + R_LOG_ERROR ("error to get gpr registers in trace bit intel"); return false; } state = (R_REG_T *)&th->gpr; @@ -46,7 +46,7 @@ static bool xnu_x86_hwstep_enable32(RDebug *dbg, bool enable) { return false; } if (!xnu_thread_set_gpr (dbg, th)) { - eprintf ("error xnu_thread_set_gpr in modify_trace_bit intel\n"); + R_LOG_ERROR ("error xnu_thread_set_gpr in modify_trace_bit intel"); return false; } return true; diff --git a/libr/debug/p/native/xnu/xnu_debug.c b/libr/debug/p/native/xnu/xnu_debug.c index 4934eed018..3eca5bcc3b 100644 --- a/libr/debug/p/native/xnu/xnu_debug.c +++ b/libr/debug/p/native/xnu/xnu_debug.c @@ -209,7 +209,7 @@ bool xnu_attach(RDebug *dbg, int pid) { } #else if (!xnu_create_exception_thread (dbg, pid)) { - eprintf ("error setting up exception thread\n"); + R_LOG_ERROR ("error setting up exception thread"); return false; } dbg->pid = pid; @@ -310,7 +310,7 @@ bool xnu_continue(RDebug *dbg, int pid, int tid, int sig) { //disable trace bit if enable if (th->stepping) { if (!clear_trace_bit (dbg, th)) { - eprintf ("error clearing trace bit in xnu_continue\n"); + R_LOG_ERROR ("error clearing trace bit in xnu_continue"); return false; } } @@ -474,7 +474,7 @@ RDebugInfo *xnu_info(RDebug *dbg, const char *arg) { } int kinfo_proc_error = xnu_get_kinfo_proc(dbg->pid, &kp); if (kinfo_proc_error) { - eprintf ("Error while querying the process info to sysctl\n"); + R_LOG_ERROR ("Error while querying the process info to sysctl"); return NULL; } rdi->status = R_DBG_PROC_SLEEP; // TODO: Fix this w/o libproc ? diff --git a/libr/debug/p/native/xnu/xnu_excthreads.c b/libr/debug/p/native/xnu/xnu_excthreads.c index a342228d2a..b8cf34dcfc 100644 --- a/libr/debug/p/native/xnu/xnu_excthreads.c +++ b/libr/debug/p/native/xnu/xnu_excthreads.c @@ -18,7 +18,7 @@ static bool modify_trace_bit(RDebug *dbg, xnu_thread_t *th, int enable) { int ret; ret = xnu_thread_get_gpr (dbg, th); if (!ret) { - eprintf ("error to get gpr registers in trace bit intel\n"); + R_LOG_ERROR ("error to get gpr registers in trace bit intel"); return false; } state = (R_REG_T *)&th->gpr; @@ -33,7 +33,7 @@ static bool modify_trace_bit(RDebug *dbg, xnu_thread_t *th, int enable) { return false; } if (!xnu_thread_set_gpr (dbg, th)) { - eprintf ("error xnu_thread_set_gpr in modify_trace_bit intel\n"); + R_LOG_ERROR ("error xnu_thread_set_gpr in modify_trace_bit intel"); return false; } return true; @@ -54,14 +54,14 @@ static bool modify_trace_bit(RDebug *dbg, xnu_thread *th, int enable) { kr = thread_get_state (th->tid, R_REG_STATE_T, (thread_state_t)&state, &state_count); if (kr != KERN_SUCCESS) { - eprintf ("error modify_trace_bit\n"); + R_LOG_ERROR ("error modify_trace_bit"); return false; } state.srr1 = (state.srr1 & ~0x400UL) | (enable ? 0x400UL : 0); kr = thread_set_state (th->tid, R_REG_STATE_T, (thread_state_t)&state, state_count); if (kr != KERN_SUCCESS) { - eprintf ("Error to set thread state modificy_trace_bit ppc\n"); + R_LOG_ERROR ("Error to set thread state modificy_trace_bit ppc"); return false; } return true; @@ -114,7 +114,7 @@ static bool is_thumb_32(ut16 op) { static bool modify_trace_bit(RDebug *dbg, xnu_thread_t *th, int enable) { int ret = xnu_thread_get_drx (dbg, th); if (!ret) { - eprintf ("error to get drx registers modificy_trace_bit arm\n"); + R_LOG_ERROR ("error to get drx registers modificy_trace_bit arm"); return false; } #if __arm64 || __arm64__ || __aarch64 || __aarch64__ @@ -140,7 +140,7 @@ static bool modify_trace_bit(RDebug *dbg, xnu_thread_t *th, int enable) { R_REG_T *regs; ret = xnu_thread_get_gpr (dbg, th); if (!ret) { - eprintf ("error to get gpr register modificy_trace_bit arm\n"); + R_LOG_ERROR ("error to get gpr register modificy_trace_bit arm"); return false; } regs = (R_REG_T*)&th->gpr; @@ -203,7 +203,7 @@ static bool modify_trace_bit(RDebug *dbg, xnu_thread_t *th, int enable) { } //set state if (!xnu_thread_set_drx (dbg, th)) { - eprintf ("error to set drx modificy_trace_bit arm\n"); + R_LOG_ERROR ("error to set drx modificy_trace_bit arm"); return false; } return true; diff --git a/libr/debug/plugin.c b/libr/debug/plugin.c index b2f850f0b1..62056324c4 100644 --- a/libr/debug/plugin.c +++ b/libr/debug/plugin.c @@ -44,7 +44,7 @@ R_API bool r_debug_use(RDebug *dbg, const char *str) { r_reg_set_profile_string (dbg->reg, p); free (p); } else { - eprintf ("Cannot retrieve reg profile from debug plugin (%s)\n", dbg->h->name); + R_LOG_ERROR ("Cannot retrieve reg profile from debug plugin (%s)", dbg->h->name); } } return (dbg && dbg->h); @@ -103,7 +103,7 @@ R_API bool r_debug_plugin_add(RDebug *dbg, RDebugPlugin *foo) { R_API bool r_debug_plugin_set_reg_profile(RDebug *dbg, const char *profile) { char *str = r_file_slurp (profile, NULL); if (!str) { - eprintf ("r_debug_plugin_set_reg_profile: Cannot find '%s'\n", profile); + R_LOG_ERROR ("r_debug_plugin_set_reg_profile: Cannot find '%s'", profile); return false; } if (dbg && dbg->h && dbg->h->set_reg_profile) { diff --git a/libr/debug/snap.c b/libr/debug/snap.c index 37818838fd..c216821559 100644 --- a/libr/debug/snap.c +++ b/libr/debug/snap.c @@ -14,14 +14,14 @@ R_API void r_debug_snap_free(RDebugSnap *snap) { R_API RDebugSnap *r_debug_snap_map(RDebug *dbg, RDebugMap *map) { r_return_val_if_fail (dbg && map, NULL); if (map->size < 1) { - eprintf ("Invalid map size\n"); + R_LOG_ERROR ("Invalid map size"); return NULL; } // TODO: Support streaming memory snapshots to avoid big allocations if (map->size > dbg->maxsnapsize) { char *us = r_num_units (NULL, 0, map->size); const char *name = r_str_get (map->name); - eprintf ("Not snapping map %s (%s > dbg.maxsnapsize)\n", name, us); + R_LOG_ERROR ("Not snapping map %s (%s > dbg.maxsnapsize)", name, us); free (us); return NULL; } @@ -44,7 +44,7 @@ R_API RDebugSnap *r_debug_snap_map(RDebug *dbg, RDebugMap *map) { r_debug_snap_free (snap); return NULL; } - eprintf ("Reading %d byte(s) from 0x%08"PFMT64x "...\n", snap->size, snap->addr); + R_LOG_ERROR ("Reading %d byte(s) from 0x%08"PFMT64x "...", snap->size, snap->addr); dbg->iob.read_at (dbg->iob.io, snap->addr, snap->data, snap->size); return snap; diff --git a/libr/debug/trace.c b/libr/debug/trace.c index 7852ca0fbd..788e8b6358 100644 --- a/libr/debug/trace.c +++ b/libr/debug/trace.c @@ -76,7 +76,7 @@ R_API bool r_debug_trace_ins_before(RDebug *dbg) { break; case R_ANAL_VAL_MEM: if (val->memref > 32) { - eprintf ("Error: adding changes to %d bytes in memory.\n", val->memref); + R_LOG_ERROR ("adding changes to %d bytes in memory.", val->memref); r_list_delete (dbg->cur_op->access, it); break; } @@ -122,7 +122,7 @@ R_API bool r_debug_trace_ins_after(RDebug *dbg) { case R_ANAL_VAL_REG: { if (!val->reg) { - R_LOG_ERROR("invalid register, unable to trace register state\n"); + R_LOG_ERROR ("invalid register, unable to trace register state"); continue; } ut64 data = r_reg_get_value (dbg->reg, val->reg); @@ -135,7 +135,7 @@ R_API bool r_debug_trace_ins_after(RDebug *dbg) { { ut8 buf[32] = {0}; if (!dbg->iob.read_at (dbg->iob.io, val->base, buf, val->memref)) { - eprintf ("Error reading memory at 0x%"PFMT64x"\n", val->base); + R_LOG_ERROR ("Error reading memory at 0x%"PFMT64x, val->base); break; } @@ -162,12 +162,12 @@ R_API int r_debug_trace_pc(RDebug *dbg, ut64 pc) { ut8 buf[32]; RAnalOp op = {0}; if (!dbg->iob.is_valid_offset (dbg->iob.io, pc, 0)) { - eprintf ("trace_pc: cannot read memory at 0x%"PFMT64x"\n", pc); + R_LOG_ERROR ("trace_pc: cannot read memory at 0x%"PFMT64x, pc); return false; } (void)dbg->iob.read_at (dbg->iob.io, pc, buf, sizeof (buf)); if (r_anal_op (dbg->anal, &op, pc, buf, sizeof (buf), R_ANAL_OP_MASK_ESIL) < 1) { - eprintf ("trace_pc: cannot get opcode size at 0x%"PFMT64x"\n", pc); + R_LOG_ERROR ("trace_pc: cannot get opcode size at 0x%"PFMT64x, pc); return false; } r_debug_trace_op (dbg, &op); @@ -182,7 +182,7 @@ R_API void r_debug_trace_op(RDebug *dbg, RAnalOp *op) { r_anal_esil_trace_op (dbg->anal->esil, op); } else { if (dbg->verbose) { - eprintf ("Run aeim to get dbg->anal->esil initialized\n"); + R_LOG_ERROR ("Run aeim to get dbg->anal->esil initialized"); } } if (oldpc != UT64_MAX) { diff --git a/libr/egg/egg.c b/libr/egg/egg.c index 95945f9fbe..e18b9c7707 100644 --- a/libr/egg/egg.c +++ b/libr/egg/egg.c @@ -372,7 +372,7 @@ R_API bool r_egg_compile(REgg *egg) { for (; b; ) { r_egg_lang_parsechar (egg, b); if (egg->lang.elem_n >= sizeof (egg->lang.elem)) { - eprintf ("ERROR: elem too large.\n"); + R_LOG_ERROR ("ERROR: elem too large."); break; } size_t r = r_buf_read (egg->src, (ut8 *)&b, sizeof (b)); @@ -382,7 +382,7 @@ R_API bool r_egg_compile(REgg *egg) { // XXX: some parse fail errors are false positives :( } if (egg->context > 0) { - eprintf ("ERROR: expected '}' at the end of the file. %d left\n", egg->context); + R_LOG_ERROR ("ERROR: expected '}' at the end of the file. %d left", egg->context); return false; } // TODO: handle errors here @@ -573,7 +573,7 @@ R_API void r_egg_finalize(REgg *egg) { const ut8 *buf = r_buf_data (ep->b, &sz); int r = r_buf_write_at (egg->bin, ep->off, buf, sz); if (r < sz) { - eprintf ("Error during patch\n"); + R_LOG_ERROR ("Error during patch"); return; } } else { diff --git a/libr/egg/egg_cfile.c b/libr/egg/egg_cfile.c index f5c6c568fc..2da8c8ecd5 100644 --- a/libr/egg/egg_cfile.c +++ b/libr/egg/egg_cfile.c @@ -194,7 +194,7 @@ static struct cEnv_t* r_egg_cfile_set_cEnv(const char *arch, const char *os, int cEnv->LDFLAGS = strdup (buffer); if (r_egg_cfile_check_cEnv (cEnv)) { - eprintf ("Error with cEnv allocation!\n"); + R_LOG_ERROR ("Error with cEnv allocation!"); goto fail; } @@ -230,7 +230,7 @@ static bool r_egg_cfile_parseCompiled(const char *file) { free (fileExt); fileExt = r_str_newf ("%s.s", file); if (!r_file_dump (fileExt, (const ut8*) buffer, strlen (buffer), true)) { - eprintf ("Error while opening %s.s\n", file); + R_LOG_ERROR ("Error while opening %s.s", file); goto fail; } @@ -268,7 +268,7 @@ R_API char* r_egg_cfile_parser(const char *file, const char *arch, const char *o } if (!r_file_dump (fileExt, (const ut8*) cEnv->SHDR, strlen (cEnv->SHDR), false)) { - eprintf ("Error while opening %s.s\n", file); + R_LOG_ERROR ("Error while opening %s.s", file); goto fail; } diff --git a/libr/egg/egg_lang.c b/libr/egg/egg_lang.c index da26c0f222..a24f59f4a4 100644 --- a/libr/egg/egg_lang.c +++ b/libr/egg/egg_lang.c @@ -585,7 +585,7 @@ R_API char *r_egg_mkvar(REgg *egg, char *out, const char *_str, int delta) { str++; len = strlen (str) - 1; if (!egg->lang.stackfixed || egg->lang.stackfixed < len) { - eprintf ("Warning: No room in the static stackframe! (%d must be %d)\n", + R_LOG_WARN ("No room in the static stackframe! (%d must be %d)", egg->lang.stackfixed, len); } str[len] = '\0'; @@ -1020,7 +1020,7 @@ static void rcc_next(REgg *egg) { if (!strcmp (str, "while")) { char var[128]; if (egg->lang.lastctxdelta >= 0) { - eprintf ("ERROR: Unsupported while syntax\n"); + R_LOG_ERROR ("ERROR: Unsupported while syntax"); return; } sprintf (var, "__begin_%d_%d_%d\n", egg->lang.nfunctions, CTX, egg->lang.nestedi[CTX - 1]); diff --git a/libr/egg/emit_arm.c b/libr/egg/emit_arm.c index 5ff87cfaa3..31f5b8091d 100644 --- a/libr/egg/emit_arm.c +++ b/libr/egg/emit_arm.c @@ -146,7 +146,7 @@ static void emit_arg(REgg *egg, int xs, int num, const char *str) { strncpy (lastargs[num - 1], str, sizeof(lastargs[0]) - 1); } else { if (!atoi (str)) { - eprintf ("Warning: probably a bug?\n"); + R_LOG_WARN ("probably a bug?"); } r_egg_printf (egg, " mov r0, %s\n", str); snprintf (lastargs[num - 1], sizeof (lastargs[0]), "sp, %d", 8 + (num * 4)); diff --git a/libr/egg/emit_esil.c b/libr/egg/emit_esil.c index 9e92f7c9f4..e45d11627a 100644 --- a/libr/egg/emit_esil.c +++ b/libr/egg/emit_esil.c @@ -111,7 +111,7 @@ static void emit_arg(REgg *egg, int xs, int num, const char *str) { strncpy (lastargs[num - 1], str, sizeof(lastargs[0]) - 1); } else { if (!atoi (str)) { - eprintf ("Warning: probably a bug?\n"); + R_LOG_WARN ("probably a bug?"); } r_egg_printf (egg, " mov r0, %s\n", str); snprintf (lastargs[num - 1], sizeof (lastargs[0]), "sp, %d", 8 + (num * 4)); diff --git a/libr/egg/emit_x86.c b/libr/egg/emit_x86.c index aa3530472b..41ace1a6a2 100644 --- a/libr/egg/emit_x86.c +++ b/libr/egg/emit_x86.c @@ -358,7 +358,7 @@ static void emit_get_var(REgg *egg, int type, char *out, int idx) { break; case 1: /* argument */ // OMG WE CAN'T stuff found in relative address in stack in the stack - eprintf ("Warning: Using stack vars in naked functions\n"); + R_LOG_WARN ("Using stack vars in naked functions"); idx = 8; // HACK to make arg0, arg4, ... work if (idx > 0) { sprintf (out, "[" R_SP "+%d]", idx); diff --git a/libr/io/io_cache.c b/libr/io/io_cache.c index 6f163cf629..a5a75f1d48 100644 --- a/libr/io/io_cache.c +++ b/libr/io/io_cache.c @@ -46,7 +46,7 @@ R_API void r_io_cache_commit(RIO *io, ut64 from, ut64 to) { if (r_io_write_at (io, r_itv_begin (c->itv), c->data, r_itv_size (c->itv))) { c->written = true; } else { - eprintf ("Error writing change at 0x%08"PFMT64x"\n", r_itv_begin (c->itv)); + R_LOG_ERROR ("Error writing change at 0x%08"PFMT64x, r_itv_begin (c->itv)); } io->cached = cached; // break; // XXX old behavior, revisit this diff --git a/libr/io/p/io_bochs.c b/libr/io/p/io_bochs.c index 1aa1af64ea..4647242e1c 100644 --- a/libr/io/p/io_bochs.c +++ b/libr/io/p/io_bochs.c @@ -40,7 +40,7 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) { fileCfg = strdup (i + 1); } else { free (fileCfg); - eprintf ("Error can't find :\n"); + R_LOG_ERROR ("Error can't find :"); return NULL; } riob = R_NEW0 (RIOBochs); diff --git a/libr/io/p/io_debug.c b/libr/io/p/io_debug.c index 82ce49a096..522b4718ed 100644 --- a/libr/io/p/io_debug.c +++ b/libr/io/p/io_debug.c @@ -181,7 +181,7 @@ static int fork_and_ptraceme(RIO *io, int bits, const char *cmd) { return pid; err_fork: - eprintf ("Error: Cannot create new process.\n"); + R_LOG_ERROR ("Cannot create new process."); TerminateProcess (pi.hProcess, 1); r_w32dw_free (io->dbgwrap); io->dbgwrap = NULL; diff --git a/libr/io/p/io_procpid.c b/libr/io/p/io_procpid.c index 45aff0a990..8fbcb9cf19 100644 --- a/libr/io/p/io_procpid.c +++ b/libr/io/p/io_procpid.c @@ -74,7 +74,7 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) { } else if (__waitpid (pid)) { ret = pid; } else { - eprintf ("Error in waitpid\n"); + R_LOG_ERROR ("Error in waitpid"); } } else { ret = pid; diff --git a/libr/io/p/io_ptrace.c b/libr/io/p/io_ptrace.c index e43ffeba55..ab995952b5 100644 --- a/libr/io/p/io_ptrace.c +++ b/libr/io/p/io_ptrace.c @@ -239,7 +239,7 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) { } else if (__waitpid (pid)) { ret = pid; } else { - eprintf ("Error in waitpid\n"); + R_LOG_ERROR ("Error in waitpid"); return NULL; } } diff --git a/libr/io/p/io_r2k_windows.c b/libr/io/p/io_r2k_windows.c index f26e9b8203..5052edd550 100644 --- a/libr/io/p/io_r2k_windows.c +++ b/libr/io/p/io_r2k_windows.c @@ -179,7 +179,7 @@ int Init (const char * driverPath) { ret = InitDriver (); } } else { - eprintf ("Error initalizating driver, try r2k://pathtodriver\nEx: radare2.exe r2k://c:\\r2k.sys"); + eprintf ("Error initalizating driver, try r2k://pathtodriver\nEx: radare2.exe r2k://c:\\r2k.sys\n"); } } else { eprintf ("Driver present [OK]\n"); diff --git a/libr/io/p/io_self.c b/libr/io/p/io_self.c index 780bf450f8..569c287cdb 100644 --- a/libr/io/p/io_self.c +++ b/libr/io/p/io_self.c @@ -226,7 +226,7 @@ static int update_self_regions(RIO *io, int pid) { HANDLE h = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, pid); LPTSTR name = calloc (name_size, sizeof (TCHAR)); if (!name) { - R_LOG_ERROR ("io_self/update_self_regions: Failed to allocate memory.\n"); + R_LOG_ERROR ("io_self/update_self_regions: Failed to allocate memory."); CloseHandle (h); return false; } diff --git a/libr/io/p/io_winkd.c b/libr/io/p/io_winkd.c index 0019f7165f..3bde2fd55f 100644 --- a/libr/io/p/io_winkd.c +++ b/libr/io/p/io_winkd.c @@ -44,20 +44,20 @@ static RIODesc *__open(RIO *io, const char *file, int rw, int mode) { } if (!iob) { - eprintf ("Error: Invalid WinDBG path\n"); + R_LOG_ERROR ("Invalid WinDBG path"); return NULL; } void *io_ctx = iob->open (file + 8); if (!io_ctx) { - eprintf ("Error: Could not open the %s\n", iob->name); + R_LOG_ERROR ("Could not open the %s", iob->name); return NULL; } eprintf ("Opened %s %s with fd %p\n", iob->name, file + 8, io_ctx); io_desc_t *desc = io_desc_new (iob, io_ctx); if (!desc) { - eprintf ("Error: Could not create io_desc_t\n"); + R_LOG_ERROR ("Could not create io_desc_t"); return NULL; } diff --git a/libr/io/p/io_xalz.c b/libr/io/p/io_xalz.c index f90a2a92ba..02bb8840c5 100644 --- a/libr/io/p/io_xalz.c +++ b/libr/io/p/io_xalz.c @@ -26,7 +26,7 @@ static RIODesc *__open(RIO *io, const char *pathname, int rw, int mode) { ut8 *obuf = r_inflate_lz4 ((const ut8*)data + 0xc, (uint32_t) sz - 0xc, &consumed, &outsize); if (obuf) { if (osz != outsize) { - R_LOG_WARN ("Invalid decompressed size\n"); + R_LOG_WARN ("Invalid decompressed size"); } mal->buf = obuf; mal->size = osz; diff --git a/libr/io/p/io_zip.c b/libr/io/p/io_zip.c index 8830812723..1d5382c353 100644 --- a/libr/io/p/io_zip.c +++ b/libr/io/p/io_zip.c @@ -326,7 +326,7 @@ static RList *r_io_zip_open_many(RIO *io, const char *file, int rw, int mode) { filename_in_zipfile, ZIP_CREATE, mode, rw); if (zfo && zfo->entry == -1) { - eprintf ("Warning: File did not exist, creating a new one.\n"); + R_LOG_WARN ("File did not exist, creating a new one."); } if (zfo) { zfo->io_backref = io; @@ -504,7 +504,7 @@ static RIODesc *r_io_zip_open(RIO *io, const char *file, int rw, int mode) { RIOZipFileObj *zfo = r_io_zip_alloc_zipfileobj (zip_filename, filename_in_zipfile, ZIP_CREATE, mode, rw); if (zfo) { if (zfo->entry == -1) { - eprintf ("Warning: File did not exist, creating a new one.\n"); + R_LOG_WARN ("File did not exist, creating a new one."); } zfo->io_backref = io; res = r_io_desc_new (io, &r_io_plugin_zip, zfo->name, rw, mode, zfo); diff --git a/libr/parse/c/libtcc.c b/libr/parse/c/libtcc.c index cf7a07a2a1..5df7336f7a 100644 --- a/libr/parse/c/libtcc.c +++ b/libr/parse/c/libtcc.c @@ -229,7 +229,7 @@ ST_FUNC bool tcc_open_bf(TCCState *s1, const char *filename, int initlen) { BufferedFile *bf = malloc (sizeof (BufferedFile) + buflen); if (!bf) { // err - eprintf ("Error\n"); + R_LOG_ERROR ("Error"); return false; } bf->buf_ptr = bf->buffer; diff --git a/libr/search/keyword.c b/libr/search/keyword.c index c2c6830ac8..30d9cd0ef4 100644 --- a/libr/search/keyword.c +++ b/libr/search/keyword.c @@ -103,7 +103,7 @@ R_API RSearchKeyword* r_search_keyword_new_wide(const char *kwbuf, const char *b RRune ch; int num_utf8_bytes = r_utf8_decode ((const ut8 *)p2, kwbuf + len - p2, &ch); if (num_utf8_bytes < 1) { - eprintf ("Warning: Malformed UTF8 at pos %d\n", (int)(p2 - kwbuf)); + R_LOG_WARN ("Malformed UTF8 at pos %d", (int)(p2 - kwbuf)); p[0] = *p2; p[1] = 0; p2++; diff --git a/libr/socket/run.c b/libr/socket/run.c index c5b50dc60c..dea732917b 100644 --- a/libr/socket/run.c +++ b/libr/socket/run.c @@ -872,7 +872,7 @@ R_API int r_run_config_env(RRunProfile *p) { } #else if (p->_docore || p->_maxfd || p->_maxproc || p->_maxstack) - eprintf ("Warning: setrlimits not supported for this platform\n"); + R_LOG_WARN ("setrlimits not supported for this platform"); #endif if (p->_connect) { char *q = strchr (p->_connect, ':'); @@ -1048,7 +1048,7 @@ R_API int r_run_config_env(RRunProfile *p) { #endif if (p->_r2preload) { if (p->_preload) { - eprintf ("Warning: Only one library can be opened at a time\n"); + R_LOG_WARN ("Only one library can be opened at a time"); } #ifdef __WINDOWS__ p->_preload = r_str_r2_prefix (R_JOIN_2_PATHS (R2_LIBDIR, "libr2."R_LIB_EXT)); @@ -1242,7 +1242,7 @@ R_API int r_run_start(RRunProfile *p) { #endif } else { if (p->_pidfile) { - eprintf ("Warning: pidfile doesnt work with 'system'.\n"); + R_LOG_WARN ("pidfile doesnt work with 'system'."); } rc = r_sys_cmd (p->_system); } diff --git a/libr/socket/socket.c b/libr/socket/socket.c index 589a92d32f..d05c757d9d 100644 --- a/libr/socket/socket.c +++ b/libr/socket/socket.c @@ -260,7 +260,7 @@ R_API bool r_socket_connect(RSocket *s, const char *host, const char *port, int WSADATA wsadata; if (WSAStartup (MAKEWORD (1, 1), &wsadata) == SOCKET_ERROR) { - eprintf ("Error creating socket.\n"); + R_LOG_ERROR ("Error creating socket."); return false; } #endif @@ -551,7 +551,7 @@ R_API bool r_socket_listen(RSocket *s, const char *port, const char *certfile) { #if __WINDOWS__ WSADATA wsadata; if (WSAStartup (MAKEWORD (1, 1), &wsadata) == SOCKET_ERROR) { - eprintf ("Error creating socket.\n"); + R_LOG_ERROR ("Error creating socket."); return false; } #endif diff --git a/libr/socket/socket_rap_client.c b/libr/socket/socket_rap_client.c index e69401e2a8..86d8afbeb6 100644 --- a/libr/socket/socket_rap_client.c +++ b/libr/socket/socket_rap_client.c @@ -93,17 +93,17 @@ R_API char *r_socket_rap_client_command(RSocket *s, const char *cmd, RCoreBind * (void) r_socket_read_block (s, (ut8*)bufr, 5); } if (bufr[0] != (char)(RAP_PACKET_CMD | RAP_PACKET_REPLY)) { - eprintf ("Error: Wrong reply for command 0x%02x\n", bufr[0]); + R_LOG_ERROR ("Wrong reply for command 0x%02x", bufr[0]); return NULL; } size_t cmd_len = r_read_at_be32 (bufr, 1); if (cmd_len < 1 || cmd_len > 16384) { - eprintf ("Error: cmd_len is wrong\n"); + R_LOG_ERROR ("cmd_len is wrong"); return NULL; } char *cmd_output = calloc (1, cmd_len + 1); if (!cmd_output) { - eprintf ("Error: Allocating cmd output\n"); + R_LOG_ERROR ("Allocating cmd output"); return NULL; } r_socket_read_block (s, (ut8*)cmd_output, cmd_len); diff --git a/libr/util/axml.c b/libr/util/axml.c index 6958e1d743..624a702887 100644 --- a/libr/util/axml.c +++ b/libr/util/axml.c @@ -314,7 +314,7 @@ R_API char *r_axml_decode(const ut8 *data, const ut64 data_size) { RBuffer *buffer = r_buf_new_with_pointers (data, data_size, false); if (!buffer) { - eprintf ("Error allocating RBuffer\n"); + R_LOG_ERROR ("Error allocating RBuffer"); goto error; } diff --git a/libr/util/file.c b/libr/util/file.c index ff8e137459..dd4cba4429 100644 --- a/libr/util/file.c +++ b/libr/util/file.c @@ -254,7 +254,7 @@ R_API char *r_file_abspath_rel(const char *cwd, const char *file) { PTCHAR f = r_sys_conv_utf8_to_win (file); int s = GetFullPathName (f, MAX_PATH, abspath, NULL); if (s > MAX_PATH) { - // R_LOG_ERROR ("r_file_abspath/GetFullPathName: Path to file too long.\n"); + // R_LOG_ERROR ("r_file_abspath/GetFullPathName: Path to file too long."); eprintf ("r_file_abspath/GetFullPathName: Path to file too long.\n"); } else if (!s) { r_sys_perror ("r_file_abspath/GetFullPathName"); @@ -461,7 +461,7 @@ R_API char *r_file_slurp(const char *str, R_NULLABLE size_t *usz) { } size_t rsz = fread (ret, 1, sz, fd); if (rsz != sz) { - eprintf ("Warning: r_file_slurp: fread: truncated read (%d / %d)\n", (int)rsz, (int)sz); + R_LOG_WARN ("r_file_slurp: fread: truncated read (%d / %d)", (int)rsz, (int)sz); sz = rsz; } fclose (fd); diff --git a/libr/util/format.c b/libr/util/format.c index 41f3c322ca..a825cb460c 100644 --- a/libr/util/format.c +++ b/libr/util/format.c @@ -1328,7 +1328,7 @@ static void r_print_format_nulltermstring(const RPrint* p, int len, int endian, vallen -= 2; } if (vallen > buflen) { - eprintf ("Warning: new string is longer than previous one\n"); + R_LOG_WARN ("new string is longer than previous one"); } p->cb_printf ("wx "); for (i = 0; i < vallen; i++) { @@ -1402,7 +1402,7 @@ static void r_print_format_nulltermwidestring(const RPrint* p, const int len, in vallen -= 2; } if ((size = vallen) > r_wstr_clen((char*)(buf+seeki))) { - eprintf ("Warning: new string is longer than previous one\n"); + R_LOG_WARN ("new string is longer than previous one"); } p->cb_printf ("ww %s @ 0x%08"PFMT64x"\n", newstring, seeki); free(ons); diff --git a/libr/util/punycode.c b/libr/util/punycode.c index 6c368e366b..7303bfee2b 100644 --- a/libr/util/punycode.c +++ b/libr/util/punycode.c @@ -21,7 +21,7 @@ int utf32len (ut32 *input) { ut8 *utf32toutf8 (ut32 *input) { if (!input) { - eprintf ("ERROR input is null\n"); + R_LOG_ERROR ("ERROR input is null"); return NULL; } @@ -30,7 +30,7 @@ ut8 *utf32toutf8 (ut32 *input) { int len = utf32len (input); ut8 *result = calloc (4, len + 1); if (!result) { - eprintf ("ERROR: out of memory\n"); + R_LOG_ERROR ("ERROR: out of memory"); return NULL; } @@ -54,7 +54,7 @@ ut8 *utf32toutf8 (ut32 *input) { result[j] = 0xf0 | ((input[i] >> 18) & 0x7); j += 4; } else { - eprintf ("ERROR in toutf8. Seems like input is invalid\n"); + R_LOG_ERROR ("ERROR in toutf8. Seems like input is invalid"); free (result); return NULL; } @@ -66,7 +66,7 @@ ut8 *utf32toutf8 (ut32 *input) { ut32 *utf8toutf32 (const ut8 *input) { if (!input) { - eprintf ("ERROR input is null\n"); + R_LOG_ERROR ("ERROR input is null"); return NULL; } @@ -77,7 +77,7 @@ ut32 *utf8toutf32 (const ut8 *input) { ut32 *result = calloc (strlen ((const char *) input) + 1, 4); if (!result) { - eprintf ("ERROR: out of memory\n"); + R_LOG_ERROR ("ERROR: out of memory"); return NULL; } @@ -101,7 +101,7 @@ ut32 *utf8toutf32 (const ut8 *input) { (input[i + 3] & 0x3f); i += 4; } else { - eprintf ("ERROR in toutf32. Seems like input is invalid.\n"); + R_LOG_ERROR ("ERROR in toutf32. Seems like input is invalid."); free (result); return NULL; } @@ -354,7 +354,7 @@ R_API char *r_punycode_decode(const char *src, int srclen, int *dstlen) { if (finaldst) { *dstlen = strlen ((const char *) finaldst); } else { - eprintf ("ERROR: finaldst is null\n"); + R_LOG_ERROR ("ERROR: finaldst is null"); return NULL; } return (char *) finaldst; diff --git a/libr/util/sandbox.c b/libr/util/sandbox.c index 4a4cb0a832..b4fb93feeb 100644 --- a/libr/util/sandbox.c +++ b/libr/util/sandbox.c @@ -289,7 +289,7 @@ R_API int r_sandbox_system(const char *x, int n) { free (argv0); return rc; } - eprintf ("Error parsing command arguments\n"); + R_LOG_ERROR ("Error parsing command arguments"); return -1; } #endif diff --git a/libr/util/str.c b/libr/util/str.c index dda72eade0..5fb6e17636 100644 --- a/libr/util/str.c +++ b/libr/util/str.c @@ -1200,7 +1200,7 @@ R_API int r_str_unescape(char *buf) { err |= r_hex_to_byte (&ch, buf[i + 2]); err |= r_hex_to_byte (&ch2, buf[i + 3]); if (err) { - eprintf ("Error: Non-hexadecimal chars in input.\n"); + R_LOG_ERROR ("Non-hexadecimal chars in input."); return 0; // -1? } buf[i] = (ch << 4) + ch2; diff --git a/libr/util/sys.c b/libr/util/sys.c index cde680482c..df27fe9f45 100644 --- a/libr/util/sys.c +++ b/libr/util/sys.c @@ -754,7 +754,7 @@ R_API int r_sys_cmd_str_full(const char *cmd, const char *input, int ilen, char bool ret = true; if (status) { // char *escmd = r_str_escape (cmd); - // eprintf ("error code %d (%s): %s\n", WEXITSTATUS (status), escmd, *sterr); + // R_LOG_ERROR ("error code %d (%s): %s", WEXITSTATUS (status), escmd, *sterr); // eprintf ("(%s)\n", output); // eprintf ("%s: failed command '%s'\n", __func__, escmd); // free (escmd); diff --git a/libr/util/sys_sh.c b/libr/util/sys_sh.c index ed12122657..575ab2f669 100644 --- a/libr/util/sys_sh.c +++ b/libr/util/sys_sh.c @@ -33,7 +33,7 @@ R_API int r_sys_tem_statement(const char *l) { } else if (lc == ';') { if (!inquote) { // XXX shouldnt have this char - R_LOG_ERROR ("Too many arguments\n"); + R_LOG_ERROR ("Too many arguments"); return -1; } } else if (lc == ' ') { @@ -41,7 +41,7 @@ R_API int r_sys_tem_statement(const char *l) { argv[2+(argc * 2)] = pos + 1; argc++; if (argc + 2 >= MAXARG) { - R_LOG_ERROR ("Too many arguments\n"); + R_LOG_ERROR ("Too many arguments"); return -1; } } diff --git a/sys/lint.sh b/sys/lint.sh index 7ea2af90d9..00da03f3f8 100755 --- a/sys/lint.sh +++ b/sys/lint.sh @@ -4,6 +4,6 @@ (git grep 'for (long' | grep -v sys/) && exit 1 (git grep 'for (size_t' | grep -v sys/) && exit 1 -(git grep 'R_LOG_' | grep '\\n' | grep -v sys/) ## && exit 1 +(git grep 'R_LOG_' | grep '\\n' | grep -v sys/) # && exit 1 exit 0