Skip to content

Commit

Permalink
Add other vector foreach macros
Browse files Browse the repository at this point in the history
  • Loading branch information
pelijah committed Apr 21, 2024
1 parent 6158e3f commit a5020b3
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ AlignConsecutiveMacros: true
AlignTrailingComments: false
AlignOperands: false
Cpp11BracedListStyle: false
ForEachMacros: ['rz_list_foreach', 'rz_list_foreach_safe', 'rz_vector_foreach', 'rz_pvector_foreach', 'rz_rbtree_foreach', 'rz_interval_tree_foreach', 'ls_foreach', 'rz_skiplist_foreach', 'graph_foreach_anode']
ForEachMacros: ['rz_list_foreach', 'rz_list_foreach_safe', 'rz_vector_foreach', 'rz_vector_foreach_prev', 'rz_vector_enumerate', 'rz_pvector_foreach', 'rz_rbtree_foreach', 'rz_interval_tree_foreach', 'ls_foreach', 'rz_skiplist_foreach', 'graph_foreach_anode']
SortIncludes: false
RequiresClausePosition: SingleLine
TypenameMacros: ['HT_', 'Ht_', 'HtName_']
2 changes: 1 addition & 1 deletion librz/arch/jmptbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ RZ_API bool rz_analysis_get_delta_jmptbl_info(RZ_NONNULL RzAnalysis *analysis, R
if (isValid) {
params->case_shift = 0;
void **it;
rz_vector_foreach_prev(&v, it) {
rz_vector_foreach_prev (&v, it) {
const ut64 op_off = *(ut64 *)it;
ut64 op_addr = lea_address + op_off;
rz_analysis_op_init(&tmp_aop);
Expand Down
2 changes: 1 addition & 1 deletion librz/arch/var.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RZ_API int rz_analysis_var_storage_cmp(
case RZ_ANALYSIS_VAR_STORAGE_COMPOSITE: {
RzAnalysisVarStoragePiece *ap = NULL;
ut32 i = 0;
rz_vector_enumerate(a->composite, ap, i) {
rz_vector_enumerate (a->composite, ap, i) {
RzAnalysisVarStoragePiece *bp = rz_vector_index_ptr(b->composite, i);
int xcmp = ap->offset_in_bits - bp->offset_in_bits;
if (xcmp != 0) {
Expand Down
2 changes: 1 addition & 1 deletion librz/bin/dwarf/line.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ static void line_unit_dump(
rz_strbuf_append(sb, "Line table statements:\n");
void *opsit;
size_t i;
rz_vector_enumerate(&unit->ops, opsit, i) {
rz_vector_enumerate (&unit->ops, opsit, i) {
RzBinDwarfLineOp *op = opsit;
rz_strbuf_append(sb, "\t");
line_op_dump(op, &unit->hdr, sb);
Expand Down
4 changes: 2 additions & 2 deletions librz/bin/dwarf/op.c
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ RZ_API void rz_bin_dwarf_expression_dump(
Operation *op = NULL;
ut32 i;
const ut32 end = rz_vector_len(exprs) - 1;
rz_vector_enumerate(exprs, op, i) {
rz_vector_enumerate (exprs, op, i) {
rz_strbuf_append(sb, rz_str_get(opt->expr_indent));
Operation_dump(op, sb);
if (i < end) {
Expand Down Expand Up @@ -1671,7 +1671,7 @@ RZ_API void rz_bin_dwarf_location_composite_dump(
ut32 i = 0;
const ut32 end = rz_vector_len(composite) - 1;
RzBinDwarfPiece *piece = NULL;
rz_vector_enumerate(composite, piece, i) {
rz_vector_enumerate (composite, piece, i) {
rz_strbuf_append(sb, rz_str_get(opt->composite_indent));
rz_strbuf_appendf(sb, "(.%" PFMT64u ", %" PFMT64u "): ", piece->bit_offset, piece->size_in_bits);

Expand Down
2 changes: 1 addition & 1 deletion librz/bin/format/elf/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#define rz_bin_elf_enumerate_sections(bin, section, i) \
if (Elf_(rz_bin_elf_has_sections)(bin)) \
rz_vector_enumerate((bin)->sections, section, i)
rz_vector_enumerate ((bin)->sections, section, i)

#define rz_bin_elf_foreach_relocs(bin, reloc) \
if (Elf_(rz_bin_elf_has_relocs)(bin)) \
Expand Down
2 changes: 1 addition & 1 deletion librz/bin/format/elf/elf_sections.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ static RzVector /*<RzBinElfSection>*/ *convert_sections_from_shdr(ELFOBJ *bin, R

size_t i;
Elf_(Shdr) * section;
rz_vector_enumerate(sections, section, i) {
rz_vector_enumerate (sections, section, i) {
RzBinElfSection tmp = convert_elf_section(bin, options, section, i);
if (!rz_vector_push(result, &tmp)) {
rz_vector_free(result);
Expand Down
2 changes: 1 addition & 1 deletion librz/core/cesil.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ RZ_API bool rz_core_esil_continue_back(RZ_NONNULL RzCore *core) {
bool bp_found = false;
int idx = 0;
RzAnalysisEsilRegChange *reg;
rz_vector_foreach_prev(vreg, reg) {
rz_vector_foreach_prev (vreg, reg) {
if (reg->idx >= esil->trace->idx) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion librz/core/seek.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ RZ_API RzList /*<RzCoreSeekItem *>*/ *rz_core_seek_list(RzCore *core) {
rz_list_append(res, cur);

i = 1;
rz_vector_foreach_prev(&core->seek_history.redos, it) {
rz_vector_foreach_prev (&core->seek_history.redos, it) {
RzCoreSeekItem *dup = dup_seek_history_item(it, i++);
if (!dup) {
goto err;
Expand Down
4 changes: 2 additions & 2 deletions librz/debug/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ RZ_API int rz_debug_continue_kill(RzDebug *dbg, int sig) {
RzRegItem *ripc = rz_reg_get(dbg->reg, dbg->reg->name[RZ_REG_NAME_PC], RZ_REG_TYPE_GPR);
RzVector *vreg = ht_up_find(dbg->session->registers, ripc->offset | (ripc->arena << 16), NULL);
RzDebugChangeReg *reg;
rz_vector_foreach_prev(vreg, reg) {
rz_vector_foreach_prev (vreg, reg) {
if (reg->cnum <= dbg->session->cnum) {
continue;
}
Expand Down Expand Up @@ -1471,7 +1471,7 @@ RZ_API bool rz_debug_continue_back(RzDebug *dbg) {
return false;
}
RzDebugChangeReg *reg;
rz_vector_foreach_prev(vreg, reg) {
rz_vector_foreach_prev (vreg, reg) {
if (reg->cnum >= dbg->session->cnum) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions librz/debug/p/debug_dmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static int rz_debug_dmp_attach(RzDebug *dbg, int pid) {
}
const ut64 current_thread_offset = ctx->windctx.is_64bit ? 8 : 4;
ut64 *kprcb;
rz_vector_foreach_prev(&ctx->KiProcessorBlock, kprcb) {
rz_vector_foreach_prev (&ctx->KiProcessorBlock, kprcb) {
const ut64 current_thread = winkd_read_ptr_at(&ctx->windctx, ctx->windctx.read_at_kernel_virtual, *kprcb + current_thread_offset);
WindThread *thread = winkd_get_thread_at(&ctx->windctx, current_thread);
if (!thread) {
Expand Down Expand Up @@ -275,7 +275,7 @@ static RzList /*<RzDebugPid *>*/ *rz_debug_dmp_pids(RzDebug *dbg, int pid) {
const ut64 current_thread_offset = ctx->windctx.is_64bit ? 8 : 4;
ut64 *kprcb;
// Get currently running processes
rz_vector_foreach_prev(&ctx->KiProcessorBlock, kprcb) {
rz_vector_foreach_prev (&ctx->KiProcessorBlock, kprcb) {
const ut64 current_thread = winkd_read_ptr_at(&ctx->windctx, ctx->windctx.read_at_kernel_virtual, *kprcb + current_thread_offset);
ut64 current_process = winkd_read_ptr_at(&ctx->windctx, ctx->windctx.read_at_kernel_virtual, current_thread + ctx->kthread_process_offset);
rz_vector_push(&procs, &current_process);
Expand Down
2 changes: 1 addition & 1 deletion librz/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static bool del_hook(void *user, const ut64 k, const void *v) {
RzEventCallbackHook *hook;
size_t i;
rz_return_val_if_fail(cbs, false);
rz_vector_enumerate(cbs, hook, i) {
rz_vector_enumerate (cbs, hook, i) {
if (hook->handle == handle) {
rz_vector_remove_at(cbs, i, NULL);
break;
Expand Down
6 changes: 3 additions & 3 deletions test/unit/test_debug_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static bool compare_registers_cb(void *user, const ut64 key, const void *value)
mu_assert_eq(actual_vreg->len, expected_vreg->len, "vreg length");

size_t i;
rz_vector_enumerate(actual_vreg, actual_reg, i) {
rz_vector_enumerate (actual_vreg, actual_reg, i) {
expected_reg = rz_vector_index_ptr(expected_vreg, i);
mu_assert_eq(actual_reg->cnum, expected_reg->cnum, "cnum");
mu_assert_eq(actual_reg->data, expected_reg->data, "data");
Expand All @@ -133,7 +133,7 @@ static bool compare_memory_cb(void *user, const ut64 key, const void *value) {
mu_assert_eq(actual_vmem->len, expected_vmem->len, "vmem length");

size_t i;
rz_vector_enumerate(actual_vmem, actual_mem, i) {
rz_vector_enumerate (actual_vmem, actual_mem, i) {
expected_mem = rz_vector_index_ptr(expected_vmem, i);
mu_assert_eq(actual_mem->cnum, expected_mem->cnum, "cnum");
mu_assert_eq(actual_mem->data, expected_mem->data, "data");
Expand Down Expand Up @@ -176,7 +176,7 @@ static bool test_session_load(void) {
size_t i, chkpt_idx;
RzDebugCheckpoint *chkpt, *ref_chkpt;
mu_assert_eq(s->checkpoints->len, ref->checkpoints->len, "checkpoints length");
rz_vector_enumerate(s->checkpoints, chkpt, chkpt_idx) {
rz_vector_enumerate (s->checkpoints, chkpt, chkpt_idx) {
ref_chkpt = rz_vector_index_ptr(ref->checkpoints, chkpt_idx);
// Registers
for (i = 0; i < RZ_REG_TYPE_LAST; i++) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ static bool test_vector_foreach(void) {

int acc_prev[5] = { 0 };
i = 5;
rz_vector_foreach_prev(&v, it) {
rz_vector_foreach_prev (&v, it) {
mu_assert_eq(acc_prev[*it], 0, "unset acc_prev element");
acc_prev[*it] = i++;
}
Expand Down

0 comments on commit a5020b3

Please sign in to comment.