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

@@ -127,7 +127,7 @@ void andMask(u8 *dest, const u8 *a, const u8 *b, u32 num_bytes) {
}
void FDRCompiler::createInitialState(FDR *fdr) {
u8 *start = (u8 *)&fdr->start;
u8 *start = reinterpret_cast<u8 *>(&fdr->start);
/* initial state should to be 1 in each slot in the bucket up to bucket
* minlen - 1, and 0 thereafter */
@@ -175,7 +175,7 @@ bytecode_ptr<FDR> FDRCompiler::setupFDR() {
auto fdr = make_zeroed_bytecode_ptr<FDR>(size, 64);
assert(fdr); // otherwise would have thrown std::bad_alloc
u8 *fdr_base = (u8 *)fdr.get();
u8 *fdr_base = reinterpret_cast<u8 *>(fdr.get());
// Write header.
fdr->size = size;

View File

@@ -58,7 +58,7 @@ u64a make_u64a_mask(const vector<u8> &v) {
u64a mask = 0;
size_t vlen = v.size();
size_t len = std::min(vlen, sizeof(mask));
unsigned char *m = (unsigned char *)&mask;
u8 *m = reinterpret_cast<u8 *>(&mask);
memcpy(m + sizeof(mask) - len, &v[vlen - len], len);
return mask;
}
@@ -245,10 +245,10 @@ bytecode_ptr<FDRConfirm> getFDRConfirm(const vector<hwlmLiteral> &lits,
fdrc->groups = gm;
// After the FDRConfirm, we have the lit index array.
u8 *fdrc_base = (u8 *)fdrc.get();
u8 *fdrc_base = reinterpret_cast<u8 *>(fdrc.get());
u8 *ptr = fdrc_base + sizeof(*fdrc);
ptr = ROUNDUP_PTR(ptr, alignof(u32));
u32 *bitsToLitIndex = (u32 *)ptr;
u32 *bitsToLitIndex = reinterpret_cast<u32 *>(ptr);
ptr += bitsToLitIndexSize;
// After the lit index array, we have the LitInfo structures themselves,
@@ -265,7 +265,7 @@ bytecode_ptr<FDRConfirm> getFDRConfirm(const vector<hwlmLiteral> &lits,
LiteralIndex litIdx = *i;
// Write LitInfo header.
LitInfo &finalLI = *(LitInfo *)ptr;
LitInfo &finalLI = *(reinterpret_cast<LitInfo *>(ptr));
finalLI = tmpLitInfo[litIdx];
ptr += sizeof(LitInfo); // String starts directly after LitInfo.
@@ -317,7 +317,7 @@ setupFullConfs(const vector<hwlmLiteral> &lits,
auto buf = make_zeroed_bytecode_ptr<u8>(totalSize, 64);
assert(buf); // otherwise would have thrown std::bad_alloc
u32 *confBase = (u32 *)buf.get();
u32 *confBase = reinterpret_cast<u32 *>(buf.get());
u8 *ptr = buf.get() + totalConfSwitchSize;
assert(ISALIGNED_CL(ptr));

View File

@@ -208,8 +208,8 @@ bytecode_ptr<u8> setupFDRFloodControl(const vector<hwlmLiteral> &lits,
auto buf = make_zeroed_bytecode_ptr<u8>(totalSize, 16);
assert(buf); // otherwise would have thrown std::bad_alloc
u32 *floodHeader = (u32 *)buf.get();
FDRFlood *layoutFlood = (FDRFlood *)(buf.get() + floodHeaderSize);
u32 *floodHeader = reinterpret_cast<u32 *>(buf.get());
FDRFlood *layoutFlood = reinterpret_cast<FDRFlood *>(buf.get() + floodHeaderSize);
u32 currentFloodIndex = 0;
for (const auto &m : flood2chars) {

View File

@@ -328,7 +328,7 @@ bool pack(const vector<hwlmLiteral> &lits,
static
void initReinforcedTable(u8 *rmsk) {
u64a *mask = (u64a *)rmsk;
u64a *mask = reinterpret_cast<u64a *>(rmsk);
fill_n(mask, N_CHARS, 0x00ffffffffffffffULL);
}
@@ -576,8 +576,8 @@ bytecode_ptr<FDR> TeddyCompiler::build() {
auto fdr = make_zeroed_bytecode_ptr<FDR>(size, 64);
assert(fdr); // otherwise would have thrown std::bad_alloc
Teddy *teddy = (Teddy *)fdr.get(); // ugly
u8 *teddy_base = (u8 *)teddy;
Teddy *teddy = reinterpret_cast<Teddy *>(fdr.get()); // ugly
u8 *teddy_base = reinterpret_cast<u8 *>(teddy);
// Write header.
teddy->size = size;