Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored Aug 1, 2024
1 parent c2d8da4 commit b5d113b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion libr/arch/p/pyc/pyc_dis.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static char *parse_arg(pyc_opcode_object *op, ut32 oparg, pyc_code_object *cobj,
if (oparg < 0 || oparg >= CMP_OP_SIZE) {
return NULL;
}
arg = R_STR_DUP (cmp_op[oparg]);
arg = strdup (cmp_op[oparg]);
}
if (op->type & HASFREE) {
if (!cellvars || !freevars) {
Expand Down
2 changes: 1 addition & 1 deletion libr/bin/p/bin_lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static void addString(const ut8 *buf, ut64 offset, ut64 length, ParseStruct *par
}

binstring->string = NULL;
if (length) {
if (length > 0) {
binstring->string = r_str_ndup ((char *) buf + offset, length);
}
binstring->vaddr = binstring->paddr = offset;
Expand Down
2 changes: 1 addition & 1 deletion libr/core/cmd_anal.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10183,7 +10183,7 @@ static char *get_buf_asm(RCore *core, ut64 from, ut64 addr, RAnalFunction *fcn,
buf_asm = r_print_colorize_opcode (core->print, str,
core->cons->context->pal.reg, core->cons->context->pal.num, false, fcn ? fcn->addr : 0);
} else {
buf_asm = R_STR_DUP (str);
buf_asm = strdup (str);
}
return buf_asm;
}
Expand Down
6 changes: 3 additions & 3 deletions libr/core/cmd_help.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ static char *filterFlags(RCore *core, const char *msg) {
end = strchr (dollar + 2, '}');
if (end) {
word = NULL;
if (end-dollar-2) {
word = r_str_ndup (dollar+2, end-dollar-2);
if (end - dollar - 2 > 0) {
word = r_str_ndup (dollar + 2, end - dollar - 2);
}
end++;
} else {
Expand All @@ -475,7 +475,7 @@ static char *filterFlags(RCore *core, const char *msg) {
end = dollar + strlen (dollar);
}
word = NULL;
if (end-dollar-1) {
if (end - dollar - 1 > 0) {
word = r_str_ndup (dollar+1, end-dollar-1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions libr/core/panels.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ static void __set_decompiler_cache(RCore *core, char *s) {
} 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);
sdb_ptr_set (sdb, r_num_as_string (NULL, func->addr, false), strdup (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, strdup (pdc_now), sdb, 0);
Expand Down Expand Up @@ -5236,7 +5236,7 @@ static void __add_menu(RCore *core, const char *parent, const char *name, RPanel
}
item->n_sub = 0;
item->selectedIndex = 0;
item->name = name ? R_STR_DUP (name) : NULL;
item->name = R_STR_DUP (name);
item->sub = NULL;
item->cb = cb;
item->p = R_NEW0 (RPanel);
Expand Down
2 changes: 1 addition & 1 deletion libr/main/rax2.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ static bool rax(RNum *num, char *str, int len, int last, RaxActions *flags, RaxM
}
if (flags->octal2raw) { // -o
char *modified_str = (*str == '0')
? R_STR_DUP (str)
? strdup (str)
: r_str_newf ("0%s", str);
const char *errstr = NULL;
ut64 n = r_num_calc (num, modified_str, &errstr);
Expand Down

0 comments on commit b5d113b

Please sign in to comment.