Skip to content

Commit

Permalink
Unshadow 'nl' argument in ds_comment calls
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored Jun 10, 2024
1 parent b3847c4 commit a927554
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 34 deletions.
53 changes: 20 additions & 33 deletions libr/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ static void ds_comment_lineup(RDisasmState *ds) {
ds_comment_align (ds);
}

static void ds_comment_(RDisasmState *ds, bool align, bool nl, const char *format, va_list ap) {
static void ds_comment_(RDisasmState *ds, bool align, bool donl, const char *format, va_list ap) {
char *s = r_str_newvf (format, ap);
char *p = s;
bool multiline = strchr (p, '\n');
Expand Down Expand Up @@ -560,14 +560,14 @@ static void ds_comment_(RDisasmState *ds, bool align, bool nl, const char *forma
if (!nl) {
break;
}
if (!ds->show_cmt_right && nl) {
if (!ds->show_cmt_right) {
r_cons_newline ();
}
first = false;
p = nl + 1;
}
free (s);
if (!ds->show_cmt_right && nl) {
if (!ds->show_cmt_right && donl) {
ds_newline (ds);
}
}
Expand Down Expand Up @@ -1309,14 +1309,12 @@ static void ds_hint_begin(RDisasmState *ds, ut64 at) {
}
}
RAnalFunction *fcn = r_anal_get_fcn_in (core->anal, at, 0);
if (fcn) {
if (fcn->bits == 16 || fcn->bits == 32) {
if (!ds->hint) {
ds->hint = R_NEW0 (RAnalHint);
}
ds->hint->bits = fcn->bits;
ds->hint->new_bits = fcn->bits;
if (fcn && (fcn->bits == 16 || fcn->bits == 32)) {
if (!ds->hint) {
ds->hint = R_NEW0 (RAnalHint);
}
ds->hint->bits = fcn->bits;
ds->hint->new_bits = fcn->bits;
}
}

Expand Down Expand Up @@ -4003,11 +4001,7 @@ static void ds_print_vliw(RDisasmState *ds, bool after) {
}
} else {
if (v > 0) {
if (c > 0) {
r_cons_printf ("}{");
} else {
r_cons_printf ("{");
}
r_cons_printf ((c > 0)? "}{": "{");
ds->vliw_count = v;
}
}
Expand Down Expand Up @@ -5382,14 +5376,13 @@ static void delete_last_comment(RDisasmState *ds) {
return;
}
const char *ll = r_cons_get_buffer ();
if (!ll) {
return;
}
ll += ds->buf_line_begin;
const char *begin = ll;
if (begin) {
ds_newline (ds);
ds_begin_cont (ds);
if (ll) {
ll += ds->buf_line_begin;
const char *begin = ll;
if (begin) {
ds_newline (ds);
ds_begin_cont (ds);
}
}
}

Expand All @@ -5414,7 +5407,7 @@ static void mipsTweak(RDisasmState *ds) {
RCore *core = ds->core;
const char *asm_arch = r_config_get (core->config, "asm.arch");
if (asm_arch && *asm_arch && strstr (asm_arch, "mips")) {
if (r_config_get_i (core->config, "anal.gpfixed")) {
if (r_config_get_b (core->config, "anal.gpfixed")) {
ut64 gp = r_config_get_i (core->config, "anal.gp");
r_reg_setv (core->anal->reg, "gp", gp);
}
Expand Down Expand Up @@ -5469,6 +5462,7 @@ static void ds_comment_call(RDisasmState *ds) {
// ds_comment_start (ds, "");
ds_comment_esil (ds, true, false, "%s", ds->show_color ? ds->pal_comment : "");
if (fcn_type) {
// XXX this makes some emu.str function signature + call arguments to be displayed one line below the call
ds_comment_middle (ds, "%s %s%s%s(", ds->cmtoken, r_str_getf (fcn_type),
(*fcn_type && fcn_type[strlen (fcn_type) - 1] == '*') ? "" : " ",
r_str_getf (key));
Expand Down Expand Up @@ -5828,6 +5822,7 @@ static void ds_print_comments_right(RDisasmState *ds) {
}
free (desc);
#if 1
// TODO: if0 this block
if ((ds->analop.type == R_ANAL_OP_TYPE_CALL || ds->analop.type & R_ANAL_OP_TYPE_UCALL) && ds->show_calls) {
ds_print_calls_hints (ds);
}
Expand Down Expand Up @@ -6067,10 +6062,6 @@ R_API int r_core_print_disasm(RCore *core, ut64 addr, ut8 *buf, int len, int cou
if (pdu_condition) {
ds->count_bytes = false;
ds->count = INT_MAX;

/*if (pdu_condition_type == esil) {
pdu_condition_esil = (const char *)pdu_condition;
} else*/
if (pdu_condition_type == pdu_instruction) {
pdu_condition_instruction = (const char *)pdu_condition;
} else if (pdu_condition_type == pdu_opcode) {
Expand Down Expand Up @@ -6864,11 +6855,7 @@ R_API int r_core_print_disasm_instructions_with_buf(RCore *core, ut64 address, u
const char *opcolor = NULL;
if (R_STR_ISEMPTY (ds->opstr)) {
free (ds->opstr);
if (unaligned) {
ds->opstr = strdup ("unaligned");
} else {
ds->opstr = strdup ("invalid");
}
ds->opstr = strdup (unaligned? "unaligned": "invalid");
}
if (ds->show_color) {
opcolor = r_print_color_op_type (core->print, ds->analop.type);
Expand Down
8 changes: 7 additions & 1 deletion test/unit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ $(UNITS_BINDIR)/%: %.c
$(CC) $< -o $@ $(CFLAGS) $(LDFLAGS)

run: $(BINS)
r=0 ; cd .. ; for a in $(BINS) ; do echo "$$a" ; $(ASAN_LD_PRELOAD) ./unit/$$a || r=1; done ; echo unit$$r ; exit $$r
R=0 ; r=0 ; cd .. ; \
for a in $(BINS) ; do \
echo "$$a" ; \
R=0 ; $(ASAN_LD_PRELOAD) ./unit/$$a || R=1; \
if [ "$$R" = 1 ]; then r=1; echo '[XX]'; fi; \
done ; \
echo unit$$r ; exit $$r

clean:
rm -f $(BINS)
Expand Down

0 comments on commit a927554

Please sign in to comment.