Fix C-style casts

This commit is contained in:
Konstantinos Margaritis
2024-05-15 23:22:39 +03:00
parent afd03a3d85
commit e39db866ce
20 changed files with 108 additions and 92 deletions

View File

@@ -1077,8 +1077,9 @@ bytecode_ptr<NFA> goughCompile(raw_som_dfa &raw, u8 somPrecision,
return bytecode_ptr<NFA>(nullptr);
}
u8 alphaShift
= ((const mcclellan *)getImplNfa(basic_dfa.get()))->alphaShift;
// cppcheck-suppress cstyleCast
const auto nfa = static_cast<const mcclellan *>(getImplNfa(basic_dfa.get()));
u8 alphaShift = nfa->alphaShift;
u32 edge_count = (1U << alphaShift) * raw.states.size();
u32 curr_offset = ROUNDUP_N(basic_dfa->length, 4);
@@ -1119,8 +1120,8 @@ bytecode_ptr<NFA> goughCompile(raw_som_dfa &raw, u8 somPrecision,
u32 gough_size = ROUNDUP_N(curr_offset, 16);
auto gough_dfa = make_zeroed_bytecode_ptr<NFA>(gough_size);
memcpy(gough_dfa.get(), basic_dfa.get(), basic_dfa->length);
memcpy((char *)gough_dfa.get() + haig_offset, &gi, sizeof(gi));
memcpy(reinterpret_cast<char *>(gough_dfa.get()), basic_dfa.get(), basic_dfa->length);
memcpy(reinterpret_cast<char *>(gough_dfa.get()) + haig_offset, &gi, sizeof(gi));
if (gough_dfa->type == MCCLELLAN_NFA_16) {
gough_dfa->type = GOUGH_NFA_16;
} else {
@@ -1133,18 +1134,19 @@ bytecode_ptr<NFA> goughCompile(raw_som_dfa &raw, u8 somPrecision,
gough_dfa->streamStateSize = base_state_size + slot_count * somPrecision;
gough_dfa->scratchStateSize = (u32)(16 + scratch_slot_count * sizeof(u64a));
mcclellan *m = (mcclellan *)getMutableImplNfa(gough_dfa.get());
// cppcheck-suppress cstyleCast
auto *m = reinterpret_cast<mcclellan *>(getMutableImplNfa(gough_dfa.get()));
m->haig_offset = haig_offset;
/* update nfa length, haig_info offset (leave mcclellan length alone) */
gough_dfa->length = gough_size;
/* copy in blocks */
copy_bytes((u8 *)gough_dfa.get() + edge_prog_offset, edge_blocks);
copy_bytes(reinterpret_cast<u8 *>(gough_dfa.get()) + edge_prog_offset, edge_blocks);
if (top_prog_offset) {
copy_bytes((u8 *)gough_dfa.get() + top_prog_offset, top_blocks);
copy_bytes(reinterpret_cast<u8 *>(gough_dfa.get()) + top_prog_offset, top_blocks);
}
copy_bytes((u8 *)gough_dfa.get() + prog_base_offset, temp_blocks);
copy_bytes(reinterpret_cast<u8 *>(gough_dfa.get()) + prog_base_offset, temp_blocks);
return gough_dfa;
}
@@ -1177,7 +1179,7 @@ AccelScheme gough_build_strat::find_escape_strings(dstate_id_t this_idx) const {
void gough_build_strat::buildAccel(dstate_id_t this_idx, const AccelScheme &info,
void *accel_out) {
assert(mcclellan_build_strat::accelSize() == sizeof(AccelAux));
gough_accel *accel = (gough_accel *)accel_out;
gough_accel *accel = reinterpret_cast<gough_accel *>(accel_out);
/* build a plain accelaux so we can work out where we can get to */
mcclellan_build_strat::buildAccel(this_idx, info, &accel->accel);
DEBUG_PRINTF("state %hu is accel with type %hhu\n", this_idx,
@@ -1315,7 +1317,8 @@ void raw_gough_report_info_impl::fillReportLists(NFA *n, size_t base_offset,
for (const raw_gough_report_list &r : rl) {
ro.emplace_back(base_offset);
gough_report_list *p = (gough_report_list *)((char *)n + base_offset);
u8 * n_ptr = reinterpret_cast<u8 *>(n);
gough_report_list *p = reinterpret_cast<gough_report_list *>(n_ptr + base_offset);
u32 i = 0;
for (const som_report &sr : r.reports) {