Skip to content

Commit

Permalink
Rename r_flag_get_i -> r_flag_get_item
Browse files Browse the repository at this point in the history
  • Loading branch information
jukuisma committed Jan 17, 2025
1 parent 654890b commit fc19739
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 71 deletions.
2 changes: 1 addition & 1 deletion libr/anal/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

R_API RFlagItem *r_anal_global_get(RAnal *anal, ut64 addr) {
RFlag *flags = anal->flb.f;
RFlagItem *fi = r_flag_get_i (flags, addr);
RFlagItem *fi = r_flag_get_item (flags, addr);
if (fi && fi->space && fi->space->name && !strcmp (fi->space->name, GLOBAL_FLAGSPACE)) {
return fi;
}
Expand Down
2 changes: 1 addition & 1 deletion libr/asm/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static char *filter(RAsmPluginSession *aps, ut64 addr, RFlag *f, RAnalHint *hint
}
}
if (flag && !strncmp (flag->name, "section.", 8)) {
flag = r_flag_get_i (f, off);
flag = r_flag_get_item (f, off);
}
const char *label = fcn? p->label_get (fcn, off): NULL;
if (label || isvalidflag (flag)) {
Expand Down
22 changes: 11 additions & 11 deletions libr/core/canal.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ R_API ut64 r_core_anal_address(RCore *core, ut64 addr) {
}
}
}
if (r_flag_get_i (core->flags, addr)) {
if (r_flag_get_item (core->flags, addr)) {
types |= R_ANAL_ADDR_TYPE_FLAG;
}
if (r_anal_get_fcn_in (core->anal, addr, 0)) {
Expand Down Expand Up @@ -421,7 +421,7 @@ static char *autoname_basic(RCore *core, RAnalFunction *fcn, int mode) {
RVecAnalRef *refs = r_anal_function_get_refs (fcn);
if (refs) {
R_VEC_FOREACH (refs, ref) {
RFlagItem *f = r_flag_get_i (core->flags, ref->addr);
RFlagItem *f = r_flag_get_item (core->flags, ref->addr);
if (!f) {
continue;
}
Expand Down Expand Up @@ -888,7 +888,7 @@ static void function_rename(RFlag *flags, RAnalFunction *fcn) {
const char *fcnpfx = r_anal_functiontype_tostring (fcn->type);
const char *restofname = fcn->name + strlen ("loc.");
fcn->name = r_str_newf ("%s.%s", fcnpfx, restofname);
RFlagItem *f = r_flag_get_i (flags, fcn->addr);
RFlagItem *f = r_flag_get_item (flags, fcn->addr);
if (f) {
r_flag_rename (flags, f, fcn->name);
}
Expand All @@ -904,7 +904,7 @@ static void autoname_imp_trampoline(RCore *core, RAnalFunction *fcn) {
RAnalRef *ref = RVecAnalRef_at (refs, 0);
int rt = R_ANAL_REF_TYPE_MASK (ref->type);
if (rt != R_ANAL_REF_TYPE_CALL) { /* Some fcns don't return */
RFlagItem *flg = r_flag_get_i (core->flags, ref->addr);
RFlagItem *flg = r_flag_get_item (core->flags, ref->addr);
if (flg && r_str_startswith (flg->name, "sym.imp.")) {
R_FREE (fcn->name);
fcn->name = r_str_newf ("sub.%s", flg->name + 8);
Expand Down Expand Up @@ -2361,7 +2361,7 @@ R_API void r_core_anal_datarefs(RCore *core, ut64 addr) {
r_cons_printf ("agn %s\n", me);
found = true;
}
RFlagItem *item = r_flag_get_i (core->flags, ref->addr);
RFlagItem *item = r_flag_get_item (core->flags, ref->addr);
r_strf_buffer (32);
const char *dst = item? item->name: r_strf ("0x%08"PFMT64x, ref->addr);
r_cons_printf ("agn %s\n", dst);
Expand Down Expand Up @@ -2390,7 +2390,7 @@ R_API void r_core_anal_coderefs(RCore *core, ut64 addr) {
continue;
}
r_strf_buffer (32);
RFlagItem *item = r_flag_get_i (core->flags, ref->addr);
RFlagItem *item = r_flag_get_item (core->flags, ref->addr);
const char *dst = item? item->name: r_strf ("0x%08"PFMT64x, ref->addr);
r_cons_printf ("agn %s\n", dst);
r_cons_printf ("age %s %s\n", me, dst);
Expand Down Expand Up @@ -2427,7 +2427,7 @@ static void add_single_addr_xrefs(RCore *core, ut64 addr, RGraph *graph) {
if (ref->addr == UT64_MAX) {
continue;
}
RFlagItem *item = r_flag_get_i (core->flags, ref->addr);
RFlagItem *item = r_flag_get_item (core->flags, ref->addr);
char *src = item? strdup (item->name): r_str_newf ("0x%08" PFMT64x, ref->addr);
RGraphNode *reference_from = r_graph_add_node_info (graph, src, NULL, ref->addr);
free (src);
Expand Down Expand Up @@ -2577,7 +2577,7 @@ R_API void r_core_anal_callgraph(RCore *core, ut64 addr, int fmt) {
break;
case R_GRAPH_FORMAT_GML:
case R_GRAPH_FORMAT_GMLFCN: {
RFlagItem *flag = r_flag_get_i (core->flags, fcni->addr);
RFlagItem *flag = r_flag_get_item (core->flags, fcni->addr);
if (iteration == 0) {
char *msg = flag? strdup (flag->name): r_str_newf ("0x%08"PFMT64x, fcni->addr);
r_cons_printf (" node [\n"
Expand Down Expand Up @@ -2609,7 +2609,7 @@ R_API void r_core_anal_callgraph(RCore *core, ut64 addr, int fmt) {
}
r_list_foreach (calls, iter2, fcnr) {
// TODO: display only code or data refs?
RFlagItem *flag = r_flag_get_i (core->flags, fcnr->addr);
RFlagItem *flag = r_flag_get_item (core->flags, fcnr->addr);
char *fcnr_name = (flag && flag->name) ? flag->name : r_str_newf ("unk.0x%"PFMT64x, fcnr->addr);
switch (fmt) {
case R_GRAPH_FORMAT_GMLFCN:
Expand Down Expand Up @@ -3057,7 +3057,7 @@ static int fcn_print_makestyle(RCore *core, RList *fcns, char mode, bool unique,
// Iterate over all refs from a function
Sdb *uniq = unique ? sdb_new0 (): NULL;
R_VEC_FOREACH (refs, refi) {
RFlagItem *f = r_flag_get_i (core->flags, refi->addr);
RFlagItem *f = r_flag_get_item (core->flags, refi->addr);
char *dst = f? strdup (f->name): r_str_newf ("0x%08"PFMT64x, refi->addr);
if (unique) {
if (sdb_const_get (uniq, dst, NULL)) {
Expand Down Expand Up @@ -5327,7 +5327,7 @@ static void cccb(void *u) {
static bool myvalid(RCore *core, ut64 addr) {
RIO *io = core->io;
#if 1
RFlagItem *fi = r_flag_get_i (core->flags, addr);
RFlagItem *fi = r_flag_get_item (core->flags, addr);
if (fi && strchr (fi->name, '.')) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion libr/core/carg.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ R_API void r_core_print_func_args(RCore *core) {
fcn_name = fcn->name;
} else {
if (core->flags) {
RFlagItem *item = r_flag_get_i (core->flags, pcv);
RFlagItem *item = r_flag_get_item (core->flags, pcv);
if (item) {
fcn_name = item->name;
}
Expand Down
12 changes: 6 additions & 6 deletions libr/core/cmd_anal.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@ static int cmd_an(RCore *core, const char *name, int mode) {
}
RFlagItem *f = r_flag_get_by_spaces (core->flags, false, tgt_addr, R_FLAGS_FS_SYMBOLS, R_FLAGS_FS_IMPORTS, NULL);
if (!f) {
f = r_flag_get_i (core->flags, tgt_addr);
f = r_flag_get_item (core->flags, tgt_addr);
}
RAnalFunction *fcn = r_anal_get_function_at (core->anal, tgt_addr);
if (fcn) {
Expand Down Expand Up @@ -4932,7 +4932,7 @@ static void cmd_afsv(RCore *core, ut64 pcv, int mode) {
if (fcn) {
fcn_name = fcn->name;
} else {
RFlagItem *item = r_flag_get_i (core->flags, pcv);
RFlagItem *item = r_flag_get_item (core->flags, pcv);
if (item) {
fcn_name = item->name;
}
Expand Down Expand Up @@ -8490,7 +8490,7 @@ static void cmd_aep(RCore *core, const char *input) {
// find a pin named like the flag, skip dots if any
RFlagItem *f = r_flag_get_by_spaces (core->flags, false, addr, R_FLAGS_FS_SYMBOLS, R_FLAGS_FS_IMPORTS, NULL);
if (!f) {
f = r_flag_get_i (core->flags, addr);
f = r_flag_get_item (core->flags, addr);
}
if (f) {
const char *last = r_str_rchr (f->name, NULL, '.');
Expand Down Expand Up @@ -9955,7 +9955,7 @@ static void _anal_calls(RCore *core, ut64 addr, ut64 addr_end, bool printCommand
if (valid && op.type == R_ANAL_OP_TYPE_CALL) {
bool isValidCall = true;
if (importsOnly) {
RFlagItem *f = r_flag_get_i (core->flags, op.jump);
RFlagItem *f = r_flag_get_item (core->flags, op.jump);
if (!f || !strstr (f->name, "imp.")) {
isValidCall = false;
}
Expand Down Expand Up @@ -12403,7 +12403,7 @@ static bool r_core_print_bb_gml(RCore *core, RAnalFunction *fcn) {
r_cons_printf ("graph\n[\n" "hierarchic 1\n" "label \"\"\n" "directed 1\n");

r_list_foreach (fcn->bbs, iter, bb) {
RFlagItem *flag = r_flag_get_i (core->flags, bb->addr);
RFlagItem *flag = r_flag_get_item (core->flags, bb->addr);
char *msg = flag? strdup (flag->name): r_str_newf ("0x%08"PFMT64x, bb->addr);
// TODO char *str = r_str_escape_dot (msg);
ht_uu_insert (ht, bb->addr, id);
Expand Down Expand Up @@ -15083,7 +15083,7 @@ static void cmd_anal_aC(RCore *core, const char *input) {
if (fcn) {
fcn_name = fcn->name;
} else {
RFlagItem *item = r_flag_get_i (core->flags, op->jump);
RFlagItem *item = r_flag_get_item (core->flags, op->jump);
if (item) {
fcn_name = item->name;
}
Expand Down
22 changes: 11 additions & 11 deletions libr/core/cmd_flag.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,26 +1388,26 @@ static int cmd_flag(void *data, const char *input) {
p = strchr (arg, ' ');
if (p) {
*p++ = 0;
item = r_flag_get_i (core->flags,
item = r_flag_get_item (core->flags,
r_num_math (core->num, arg));
if (item)
item->size = r_num_math (core->num, p);
} else {
if (*arg) {
item = r_flag_get_i (core->flags, core->offset);
item = r_flag_get_item (core->flags, core->offset);
if (item) {
item->size = r_num_math (core->num, arg);
}
} else {
item = r_flag_get_i (core->flags, r_num_math (core->num, arg));
item = r_flag_get_item (core->flags, r_num_math (core->num, arg));
if (item) {
r_cons_printf ("0x%08"PFMT64x"\n", item->size);
}
}
}
free (arg);
} else { // "fl"
item = r_flag_get_i (core->flags, core->offset);
item = r_flag_get_item (core->flags, core->offset);
if (item) {
r_cons_printf ("0x%08"PFMT64x"\n", item->size);
}
Expand All @@ -1417,7 +1417,7 @@ static int cmd_flag(void *data, const char *input) {
case 'd':
if (input[1] == ' ') {
char cmd[128];
RFlagItem *item = r_flag_get_i (core->flags,
RFlagItem *item = r_flag_get_item (core->flags,
r_num_math (core->num, input+2));
if (item) {
r_cons_printf ("0x%08"PFMT64x"\n", item->offset);
Expand All @@ -1435,7 +1435,7 @@ static int cmd_flag(void *data, const char *input) {
break;
case 'x':
if (input[1] == ' ') {
RFlagItem *item = r_flag_get_i (core->flags,
RFlagItem *item = r_flag_get_item (core->flags,
r_num_math (core->num, input+2));
if (item) {
r_cons_printf ("0x%08"PFMT64x"\n", item->offset);
Expand Down Expand Up @@ -1506,7 +1506,7 @@ static int cmd_flag(void *data, const char *input) {
if (input[2] == ' ') {
off = r_num_math (core->num, input+2);
}
RFlagItem *f = r_flag_get_i (core->flags, off);
RFlagItem *f = r_flag_get_item (core->flags, off);
if (f) {
f->space = r_flag_space_cur (core->flags);
} else {
Expand Down Expand Up @@ -1640,7 +1640,7 @@ static int cmd_flag(void *data, const char *input) {
R_LOG_ERROR ("Cannot find flag with name '%s'", p);
}
} else {
item = r_flag_get_i (core->flags, r_num_math (core->num, p));
item = r_flag_get_item (core->flags, r_num_math (core->num, p));
if (item && item->comment) {
r_cons_println (item->comment);
} else {
Expand Down Expand Up @@ -1674,7 +1674,7 @@ static int cmd_flag(void *data, const char *input) {
}
} else {
new = old;
item = r_flag_get_i (core->flags, core->offset);
item = r_flag_get_item (core->flags, core->offset);
}
if (item) {
if (!r_flag_rename (core->flags, item, new)) {
Expand All @@ -1688,7 +1688,7 @@ static int cmd_flag(void *data, const char *input) {
break;
case 'N':
if (!input[1]) {
RFlagItem *item = r_flag_get_i (core->flags, core->offset);
RFlagItem *item = r_flag_get_item (core->flags, core->offset);
if (item) {
r_cons_printf ("%s\n", item->realname);
}
Expand All @@ -1706,7 +1706,7 @@ static int cmd_flag(void *data, const char *input) {
}
} else {
realname = name;
item = r_flag_get_i (core->flags, core->offset);
item = r_flag_get_item (core->flags, core->offset);
}
if (item) {
r_flag_item_set_realname (item, realname);
Expand Down
2 changes: 1 addition & 1 deletion libr/core/cmd_meta.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ static int cmd_meta_others(RCore *core, const char *input) {
r_str_ncpy (name, p, sizeof (name));
} else {
if (type != 'b' && type != 's') {
RFlagItem *fi = r_flag_get_i (core->flags, addr);
RFlagItem *fi = r_flag_get_item (core->flags, addr);
if (fi) {
r_str_ncpy (name, fi->name, sizeof (name));
}
Expand Down
8 changes: 4 additions & 4 deletions libr/core/cmd_print.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ static void cmd_prcn(RCore *core, const ut8* block, int len, bool bitsmode) {
r_cons_printf (Color_RESET);
}
if (show_flags) {
RFlagItem *fi = r_flag_get_i (core->flags, core->offset + j);
RFlagItem *fi = r_flag_get_item (core->flags, core->offset + j);
if (fi) {
r_cons_printf (" ; %s", fi->name);
}
Expand Down Expand Up @@ -922,7 +922,7 @@ static void cmd_prc(RCore *core, const ut8* block, int len) {
}
if (square) {
if (show_flags) {
RFlagItem *fi = r_flag_get_i (core->flags, core->offset + j);
RFlagItem *fi = r_flag_get_item (core->flags, core->offset + j);
if (fi) {
first_flag_chars (fi->name, &ch, &ch2);
} else {
Expand Down Expand Up @@ -1044,7 +1044,7 @@ static void cmd_prc_zoom(RCore *core, const char *input) {
}
if (square) {
if (show_flags) {
RFlagItem *fi = r_flag_get_i (core->flags, core->offset + j);
RFlagItem *fi = r_flag_get_item (core->flags, core->offset + j);
if (fi) {
if (fi->name[1]) {
ch = fi->name[0];
Expand Down Expand Up @@ -5742,7 +5742,7 @@ static void r_core_disasm_table(RCore *core, int l, const char *input) {
}
r_io_read_at (core->io, ea, bytes, op->size); // XXX ranalop should contain the bytes like rasmop do
char *sbytes = r_hex_bin2strdup(bytes, op->size);
RFlagItem *fi = r_flag_get_i (core->flags, ea);
RFlagItem *fi = r_flag_get_item (core->flags, ea);
char *fn = fi? fi->name: "";
const char *esil = R_STRBUF_SAFEGET (&op->esil);
char *refs = __op_refs (core, op, 0);
Expand Down
10 changes: 5 additions & 5 deletions libr/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ static void setab(RCore *core, const char *arch, int bits) {
}

static const char *getName(RCore *core, ut64 addr) {
RFlagItem *item = r_flag_get_i (core->flags, addr);
RFlagItem *item = r_flag_get_item (core->flags, addr);
if (item) {
if (core->flags->realnames) {
return item->realname
Expand Down Expand Up @@ -368,7 +368,7 @@ static const char *str_callback(RNum *user, ut64 off, int *ok) {
*ok = 0;
}
if (f) {
RFlagItem *item = r_flag_get_i (f, off);
RFlagItem *item = r_flag_get_item (f, off);
if (item) {
if (ok) {
*ok = true;
Expand Down Expand Up @@ -1671,13 +1671,13 @@ R_API int r_core_fgets(char *buf, int len) {

static const char *r_core_print_offname(void *p, ut64 addr) {
RCore *c = (RCore*)p;
RFlagItem *item = r_flag_get_i (c->flags, addr);
RFlagItem *item = r_flag_get_item (c->flags, addr);
return item ? item->name : NULL;
}

static int r_core_print_offsize(void *p, ut64 addr) {
RCore *c = (RCore*)p;
RFlagItem *item = r_flag_get_i (c->flags, addr);
RFlagItem *item = r_flag_get_item (c->flags, addr);
return item ? item->size: -1;
}

Expand Down Expand Up @@ -1770,7 +1770,7 @@ R_API char *r_core_anal_hasrefs(RCore *core, ut64 value, int mode) {
}
return res;
}
RFlagItem *fi = r_flag_get_i (core->flags, value);
RFlagItem *fi = r_flag_get_item (core->flags, value);
return fi? strdup (fi->name): NULL;
}

Expand Down
Loading

0 comments on commit fc19739

Please sign in to comment.