From 3ca357b182b13f5181eccf6d4b7713611e237434 Mon Sep 17 00:00:00 2001 From: dav1901 <44604348+dav1901@users.noreply.github.com> Date: Tue, 4 Dec 2018 15:19:30 +0200 Subject: [PATCH] Fix few clang warnings (#12394) --- libr/bin/p/bin_mach0.c | 4 +++- libr/core/cmd_type.c | 2 +- libr/core/visual.c | 8 ++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/libr/bin/p/bin_mach0.c b/libr/bin/p/bin_mach0.c index 05b0eb27ff..901a4d2b4a 100644 --- a/libr/bin/p/bin_mach0.c +++ b/libr/bin/p/bin_mach0.c @@ -77,7 +77,9 @@ static bool load(RBinFile *bf) { } load_bytes (bf, &bf->o->bin_obj, bytes, sz, bf->o->loadaddr, bf->sdb); if (!bf->o || !bf->o->bin_obj) { - MACH0_(mach0_free) (bf->o->bin_obj); + if (bf->o) { + MACH0_(mach0_free) (bf->o->bin_obj); + } return false; } struct MACH0_(obj_t) *mo = bf->o->bin_obj; diff --git a/libr/core/cmd_type.c b/libr/core/cmd_type.c index 6409de6211..92f5848b50 100644 --- a/libr/core/cmd_type.c +++ b/libr/core/cmd_type.c @@ -814,7 +814,7 @@ static int cmd_type(void *data, const char *input) { ls_free (l); } else { // "tej ENUM" RListIter *iter; - RTypeEnum *member = R_NEW0 (RTypeEnum); + RTypeEnum *member; if (member_name) { res = r_type_enum_member (TDB, name, NULL, r_num_math (core->num, member_name)); // NEVER REACHED diff --git a/libr/core/visual.c b/libr/core/visual.c index 4aba50e8f1..e165c81fd0 100644 --- a/libr/core/visual.c +++ b/libr/core/visual.c @@ -1099,7 +1099,6 @@ repeat: int maxcount = 9; int rows, cols = r_cons_get_size (&rows); - idx = 0; count = 0; char *dis = NULL; rows -= 4; @@ -2312,7 +2311,7 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) { cur = core->print->cur - 1; } snprintf (buf, sizeof (buf), "%s @ $$0!%i", p, - core->blocksize - core->print->cur); + core->blocksize - cur); r_core_cmd (core, buf, 0); free (p); break; @@ -2422,7 +2421,7 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) { r_io_sundo_push (core->io, core->offset, r_print_get_cursor (core->print)); break; case 'G': - ret = 0; + ret = -1; int scols = r_config_get_i (core->config, "hex.cols"); if (core->file) { if (core->io->va) { @@ -2442,8 +2441,6 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) { r_io_fd_size (core->io, core->file->fd) - core->blocksize + 2 * scols, 1); } - } else { - ret = -1; } if (ret != -1) { r_io_sundo_push (core->io, core->offset, r_print_get_cursor (core->print)); @@ -2943,7 +2940,6 @@ R_API int r_core_visual_cmd(RCore *core, const char *arg) { // have to escape any quotes. int j, len = strlen (buf); char *duped = strdup (buf); - i = 4, j = 4; for (i = 4, j = 4; i < len; ++i,++j) { char c = duped[i]; if (c == '"' && i != (len - 1)) {