Skip to content

Commit

Permalink
Fix according to review
Browse files Browse the repository at this point in the history
  • Loading branch information
satk0 committed Jul 27, 2024
1 parent 205ac6e commit 8274a6a
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions libr/anal/sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ R_API bool r_sign_deserialize(RAnal *a, RSignItem *it, const char *k, const char
R_RETURN_VAL_IF_FAIL (a && it && k && v, false);

bool success = true;
char *k2 = R_STR_DUP (k);
char *v2 = R_STR_DUP (v);
char *k2 = strdup (k);
char *v2 = strdup (v);
if (!k2 || !v2) {
success = false;
goto out;
Expand Down
2 changes: 1 addition & 1 deletion libr/core/canal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,7 @@ static void add_single_addr_xrefs(RCore *core, ut64 addr, RGraph *graph) {
r_return_if_fail (graph);
RFlagItem *f = r_flag_get_at (core->flags, addr, false);
char *me = (f && f->offset == addr)
? R_STR_DUP (f->name)
? strdup (f->name)
: r_str_newf ("0x%" PFMT64x, addr);

RGraphNode *curr_node = r_graph_add_node_info (graph, me, NULL, addr);
Expand Down
2 changes: 1 addition & 1 deletion libr/core/cmd_cmp.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ R_API bool r_core_cmpwatch_add(RCore *core, ut64 addr, int size, const char *cmd
found = true;
}
cmpw->size = size;
cmpw->cmd = R_STR_DUP (cmd);
cmpw->cmd = strdup (cmd);
if (!cmpw->cmd) {
free (cmpw);
return false;
Expand Down
2 changes: 1 addition & 1 deletion libr/core/cmd_debug.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,7 @@ R_API void r_core_debug_rr(RCore *core, RReg *reg, int mode) {
valuestr = r_str_newf ("%s0x%"PFMT64x"%s", color, value, colorend);
r_cons_print (Color_RESET);
} else {
namestr = R_STR_DUP (r->name);
namestr = strdup (r->name);
valuestr = r_str_newf ("0x%"PFMT64x, value);
}
ut64 o_offset = core->offset;
Expand Down
2 changes: 1 addition & 1 deletion libr/core/cmd_zign.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ static bool diff_zig(void *data, const char *input) {
return false;
}

char *argv = R_STR_DUP (input);
char *argv = strdup (input);
if (!argv) {
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions libr/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1202,14 +1202,14 @@ static void autocomplete_ms_path(RLineCompletion *completion, RCore *core, const
dirname = r_file_new (pwd, lpath, NULL);
}
}
basename = R_STR_DUP (p + 1);
basename = strdup (p + 1);
} else { // xxx
if (strlen (pwd) == 1) {
dirname = r_str_newf ("%s", R_SYS_DIR);
} else {
dirname = r_str_newf ("%s%s", pwd, R_SYS_DIR);
}
basename = R_STR_DUP (lpath);
basename = strdup (lpath);
}
R_FREE (pwd);

Expand Down Expand Up @@ -1340,7 +1340,7 @@ static void autocomplete_process_path(RLineCompletion *completion, const char *s
path++;
}
#endif
lpath = R_STR_DUP (path);
lpath = strdup (path);
#if R2__WINDOWS__
r_str_replace_ch (lpath, '/', '\\', true);
#endif
Expand All @@ -1351,7 +1351,7 @@ static void autocomplete_process_path(RLineCompletion *completion, const char *s
#if R2__WINDOWS__
dirname = strdup ("\\.\\");
#else
dirname = R_STR_DUP (R_SYS_DIR);
dirname = strdup (R_SYS_DIR);
#endif
} else if (lpath[0] == '~' && lpath[1]) { // ~/xxx/yyy
dirname = r_file_home (lpath + 2);
Expand Down Expand Up @@ -1419,7 +1419,7 @@ static void autocomplete_filename(RLineCompletion *completion, RLineBuffer *buf,
char *pipe = strchr (buf->data, '>');

if (pipe) {
args = R_STR_DUP (pipe);
args = strdup (pipe);
#if 0
if (pipe[1] == ' ') {
// currently unreachable
Expand Down Expand Up @@ -1608,7 +1608,7 @@ static void autocomplete_sdb(RCore *core, RLineCompletion *completion, const cha
if (pipe) {
str = r_str_trim_head_ro (pipe + 1);
}
lpath = R_STR_DUP (str);
lpath = strdup (str);
p1 = strchr (lpath, '/');
if (p1) {
*p1 = 0;
Expand Down
2 changes: 1 addition & 1 deletion libr/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4859,7 +4859,7 @@ static void ds_print_ptr(RDisasmState *ds, int len, int idx) {
f = r_flag_get_i (core->flags, refaddr);
if (f) {
if (strlen (msg) != 1) {
char *msg2 = R_STR_DUP (msg);
char *msg2 = strdup (msg);
if (msg2) {
r_str_filter (msg2, 0);
if (!strncmp (msg2, "UH..", 4)) {
Expand Down
2 changes: 1 addition & 1 deletion libr/core/fortune.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static bool _push_types(RList *type_list, char *fortune_dir) {
char *file;
r_list_foreach (files, iter, file) {
if (r_str_startswith (file, "fortunes.") && file[9]) {
r_list_push (type_list, R_STR_DUP (file + 9));
r_list_push (type_list, strdup (file + 9));
}
}
r_list_free (files);
Expand Down
14 changes: 7 additions & 7 deletions libr/core/panels.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ static bool __check_panel_type(RPanel *panel, const char *type) {
if (!panel || !panel->model->cmd || !type) {
return false;
}
char *tmp = R_STR_DUP (panel->model->cmd);
char *tmp = strdup (panel->model->cmd);
int n = r_str_split (tmp, ' ');
if (!n) {
free (tmp);
Expand Down Expand Up @@ -623,14 +623,14 @@ static void __set_decompiler_cache(RCore *core, char *s) {
RAnalFunction *func = r_anal_get_fcn_in (core->anal, core->offset, R_ANAL_FCN_TYPE_NULL);
if (func) {
if (core->panels_root->cur_pdc_cache) {
sdb_ptr_set (core->panels_root->cur_pdc_cache, r_num_as_string (NULL, func->addr, false), R_STR_DUP (s), 0);
sdb_ptr_set (core->panels_root->cur_pdc_cache, r_num_as_string (NULL, func->addr, false), strdup (s), 0);
} else {
Sdb *sdb = sdb_new0 ();
const char *pdc_now = r_config_get (core->config, "cmd.pdc");
sdb_ptr_set (sdb, r_num_as_string (NULL, func->addr, false), R_STR_DUP (s), 0);
core->panels_root->cur_pdc_cache = sdb;
if (!sdb_exists (core->panels_root->pdc_caches, pdc_now)) {
sdb_ptr_set (core->panels_root->pdc_caches, R_STR_DUP (pdc_now), sdb, 0);
sdb_ptr_set (core->panels_root->pdc_caches, strdup (pdc_now), sdb, 0);
}
}
}
Expand All @@ -639,7 +639,7 @@ static void __set_decompiler_cache(RCore *core, char *s) {

static void __set_read_only(RCore *core, RPanel *p, char *s) {
free (p->model->readOnly);
p->model->readOnly = R_STR_DUP (s);
p->model->readOnly = strdup (s);
__set_dcb (core, p);
__set_pcb (p);
}
Expand Down Expand Up @@ -2294,7 +2294,7 @@ static int __show_all_decompiler_cb(void *user) {
r_config_set (core->config, "cmd.pdc", opt);
RPanel *panel = __get_panel (panels, i++);
panels->n_panels = i;
panel->model->title = R_STR_DUP (opt);
panel->model->title = strdup (opt);
__set_read_only (core, panel, r_core_cmd_str (core, opt));
}
__layout_equal_hor (panels);
Expand All @@ -2317,7 +2317,7 @@ static void __init_modal_db(RCore *core) {
SdbList *sdb_list = sdb_foreach_list (core->panels->db, true);
ls_foreach (sdb_list, sdb_iter, kv) {
const char *key = sdbkv_key (kv);
sdb_ptr_set (db, R_STR_DUP (key), &__create_panel_db, 0);
sdb_ptr_set (db, strdup (key), &__create_panel_db, 0);
}
sdb_ptr_set (db, "Search strings in data sections", &__search_strings_data_create, 0);
sdb_ptr_set (db, "Search strings in the whole bin", &__search_strings_bin_create, 0);
Expand Down Expand Up @@ -2597,7 +2597,7 @@ static void __handle_tab_new_with_cur_panel(RCore *core) {
RPanel *new_panel = __get_panel (new_panels, 0);
__init_panel_param (core, new_panel, cur->model->title, cur->model->cmd);
new_panel->model->cache = cur->model->cache;
new_panel->model->funcName = R_STR_DUP (cur->model->funcName);
new_panel->model->funcName = strdup (cur->model->funcName);
__set_cmd_str_cache (core, new_panel, cur->model->cmdStrCache);
__maximize_panel_size (new_panels);

Expand Down
2 changes: 1 addition & 1 deletion libr/main/ravc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ R_API int r_main_ravc2(int argc, const char **argv) {
if (files) {
size_t i;
for (i = 2; i < argc - 1; i++) {
char *file = R_STR_DUP (argv[opt.ind + i]);
char *file = strdup (argv[opt.ind + i]);
if (!file || !r_list_append (files, file)) {
free (message);
r_list_free (files);
Expand Down
2 changes: 1 addition & 1 deletion libr/util/rvc_git.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static Rvc *open_git(const char *path) {
if (!vc) {
return NULL;
}
vc->path = R_STR_DUP (path);
vc->path = strdup (path);
if (!vc->path) {
free (vc);
return NULL;
Expand Down
6 changes: 3 additions & 3 deletions libr/util/rvc_rvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static Rvc *rvc_rvc_new(const char *path) {
R_LOG_ERROR ("Failed to create repo");
return NULL;
}
rvc->path = R_STR_DUP (path);
rvc->path = strdup (path);
if (!rvc->path) {
free (rvc);
return NULL;
Expand Down Expand Up @@ -325,7 +325,7 @@ static char *absp2rp(Rvc *rvc, const char *absp) {
free (arp);
return NULL;
}
char *p = R_STR_DUP (absp + r_str_len_utf8 (arp));
char *p = strdup (absp + r_str_len_utf8 (arp));
free (arp);
if (!p) {
return NULL;
Expand Down Expand Up @@ -716,7 +716,7 @@ R_API RList *branches_rvc(Rvc *rvc) {
if (!r_str_startswith ((char *)kv->base.key, BPREFIX)) {
continue;
}
if (!r_list_append (ret, R_STR_DUP ((char *)kv->base.key + bplen))
if (!r_list_append (ret, strdup ((char *)kv->base.key + bplen))
&& !ret->head->data) {
r_list_free (ret);
ret = NULL;
Expand Down
2 changes: 1 addition & 1 deletion libr/util/str.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ R_API char *r_str_trunc_ellipsis(const char *str, int len) {
return strdup (str);
}
char *buf = NULL;
if (len) {
if (len > 0) {
buf = r_str_ndup (str, len);
}
if (buf && len > 4) {
Expand Down
2 changes: 1 addition & 1 deletion libr/util/strbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ R_API bool r_strbuf_slice(RStrBuf *sb, int from, int len) {
const char *fr = r_str_ansi_chrn (s, from + 1);
const char *to = r_str_ansi_chrn (s, from + len + 1);
char *r = NULL;
if (to - fr) {
if (to > fr) {
r = r_str_ndup (fr, to - fr);
}
r_strbuf_fini (sb);
Expand Down
2 changes: 1 addition & 1 deletion libr/util/syscmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ R_API char *r_syscmd_join(const char *file1, const char *file2) {
}
r_list_foreach (list2, iter2, str2) {
if (r_str_startswith (str2, field)) {
char *out = R_STR_DUP (field);
char *out = strdup (field);
char *first = strchr (str1, ' ');
char *second = strchr (str2, ' ');
out = r_str_append (out, r_str_get_fail (first, " "));
Expand Down
2 changes: 1 addition & 1 deletion shlr/ar/ar.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static char *name_from_table(ut64 off, filetable *tbl) {
return NULL;
}
char *res = NULL;
if (i - off - 1) {
if (i - off - 1 > 0) {
res = r_str_ndup (buf + off, i - off - 1);
}
return res;
Expand Down

0 comments on commit 8274a6a

Please sign in to comment.