diff --git a/libr/asm/arch/arm/armass.c b/libr/asm/arch/arm/armass.c index 6097337b07..da29bf2644 100644 --- a/libr/asm/arch/arm/armass.c +++ b/libr/asm/arch/arm/armass.c @@ -47,10 +47,7 @@ enum { }; static int strcmpnull(const char *a, const char *b) { - if (!a || !b) { - return -1; - } - return strcmp (a, b); + return (a && b) ? strcmp (a, b) : -1; } // static const char *const arm_shift[] = {"lsl", "lsr", "asr", "ror"}; diff --git a/libr/bin/bin.c b/libr/bin/bin.c index 06333927bd..4ae5744c77 100644 --- a/libr/bin/bin.c +++ b/libr/bin/bin.c @@ -777,7 +777,6 @@ R_API RList *r_bin_patch_relocs(RBin *bin) { o->relocs = tmp; REBASE_PADDR (o, o->relocs, RBinReloc); first = false; - return o->relocs; } return o->relocs; } diff --git a/libr/bin/filter.c b/libr/bin/filter.c index 38ab44d2eb..a04a9efa30 100644 --- a/libr/bin/filter.c +++ b/libr/bin/filter.c @@ -6,16 +6,23 @@ static char *hashify(char *s, ut64 vaddr) { r_return_val_if_fail (s, NULL); + char *ret; char *os = s; while (*s) { if (!IS_PRINTABLE (*s)) { if (vaddr && vaddr != UT64_MAX) { - free (os); - return r_str_newf ("_%" PFMT64d, vaddr); + ret = r_str_newf ("_%" PFMT64d, vaddr); + if (ret) { + free (os); + } + return ret; } ut32 hash = sdb_hash (s); - free (os); - return r_str_newf ("%x", hash); + ret = r_str_newf ("%x", hash); + if (ret) { + free (os); + } + return ret; } s++; } diff --git a/libr/core/cmd_type.c b/libr/core/cmd_type.c index 49d49a0b18..59ef3473ca 100644 --- a/libr/core/cmd_type.c +++ b/libr/core/cmd_type.c @@ -808,6 +808,7 @@ static int cmd_type(void *data, const char *input) { } if (name && (r_type_kind (TDB, name) != R_TYPE_ENUM)) { eprintf ("%s is not an enum\n", name); + free (name); break; } switch (input[1]) { diff --git a/libr/include/r_io.h b/libr/include/r_io.h index 11a6ce83d7..d547131c5b 100644 --- a/libr/include/r_io.h +++ b/libr/include/r_io.h @@ -435,7 +435,6 @@ R_API bool r_io_cache_read(RIO *io, ut64 addr, ut8 *buf, int len); /* io/section.c */ R_API void r_io_section_init (RIO *io); R_API void r_io_section_fini (RIO *io); -R_API int r_io_section_exists_for_id (RIO *io, ut32 id); R_API RIOSection *r_io_section_add (RIO *io, ut64 addr, ut64 vaddr, ut64 size, ut64 vsize, int rwx, const char *name, ut32 bin_id, int fd); R_API RIOSection *r_io_section_get_i (RIO *io, ut32 id); R_API SdbList *r_io_section_bin_get (RIO *io, ut32 bin_id); @@ -449,7 +448,6 @@ R_API bool r_io_section_apply (RIO *io, ut32 id, RIOSectionApplyMethod method); R_API bool r_io_section_apply_bin (RIO *io, ut32 bin_id, RIOSectionApplyMethod method); R_API RIOSection* r_io_section_get(RIO *io, ut64 paddr); R_API RIOSection* r_io_section_vget(RIO *io, ut64 vaddr); -R_API ut64 r_io_section_get_paddr_at(RIO *io, ut64 addr); /* io/p_cache.c */ R_API bool r_io_desc_cache_init (RIODesc *desc); diff --git a/libr/io/section.c b/libr/io/section.c index b0932eccec..4e16a5852a 100644 --- a/libr/io/section.c +++ b/libr/io/section.c @@ -37,20 +37,6 @@ R_API void r_io_section_fini(RIO *io) { io->sec_ids = NULL; } -R_API int r_io_section_exists_for_id(RIO *io, ut32 id) { - SdbListIter *iter; - RIOSection *sec; - if (!io || !io->sections) { - return false; - } - ls_foreach (io->sections, iter, sec) { - if (sec->id == id) { - return true; - } - } - return false; -} - R_API RIOSection *r_io_section_add(RIO *io, ut64 paddr, ut64 vaddr, ut64 size, ut64 vsize, int perm, const char *name, ut32 bin_id, int fd) { @@ -217,22 +203,6 @@ R_API RIOSection* r_io_section_get(RIO *io, ut64 vaddr) { return NULL; } -R_API ut64 r_io_section_get_paddr_at(RIO *io, ut64 paddr) { - if (io) { - SdbList *sects = r_io_sections_get (io, paddr); - ut64 ret = UT64_MAX; - if (sects) { - if (!ls_empty (sects)) { - RIOSection *s = ls_pop (sects); - ret = s->paddr; - } - } - ls_free (sects); - return ret; - } - return UT64_MAX; -} - R_API const char *r_io_section_get_archbits(RIO *io, ut64 vaddr, int *bits) { if (!io) { return NULL; diff --git a/shlr/sdb/src/ls.c b/shlr/sdb/src/ls.c index ef3677ef7c..83ad0cdd23 100644 --- a/shlr/sdb/src/ls.c +++ b/shlr/sdb/src/ls.c @@ -12,11 +12,7 @@ SDB_API SdbList *ls_newf(SdbListFree freefn) { } SDB_API SdbList *ls_new() { - SdbList *list = R_NEW0 (SdbList); - if (!list) { - return NULL; - } - return list; + return R_NEW0 (SdbList); } static void ls_insertion_sort_iter(SdbListIter *iter, SdbListComparator cmp) {