From 94eff4aa6029e5a377f731ae0218a11d23b8c9cd Mon Sep 17 00:00:00 2001 From: gtsoul-tech Date: Wed, 22 May 2024 10:16:56 +0300 Subject: [PATCH] cstylecasts and suppressions --- src/hwlm/hwlm_dump.cpp | 2 ++ src/nfa/goughdump.cpp | 2 +- src/nfa/lbr_dump.cpp | 4 ++-- src/parser/Parser.rl | 2 ++ unit/internal/uniform_ops.cpp | 4 ++++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/hwlm/hwlm_dump.cpp b/src/hwlm/hwlm_dump.cpp index b3a681de..69463519 100644 --- a/src/hwlm/hwlm_dump.cpp +++ b/src/hwlm/hwlm_dump.cpp @@ -53,9 +53,11 @@ void hwlmGenerateDumpFiles(const HWLM *h, const string &base) { switch (h->type) { case HWLM_ENGINE_NOOD: + // cppcheck-suppress cstyleCast noodPrintStats(reinterpret_cast(HWLM_C_DATA(h)), f); break; case HWLM_ENGINE_FDR: + // cppcheck-suppress cstyleCast fdrPrintStats(reinterpret_cast(HWLM_C_DATA(h)), f); break; default: diff --git a/src/nfa/goughdump.cpp b/src/nfa/goughdump.cpp index 060d6046..8717d06a 100644 --- a/src/nfa/goughdump.cpp +++ b/src/nfa/goughdump.cpp @@ -123,7 +123,7 @@ void describeNode(const NFA *n, const mcclellan *m, u16 i, FILE *f) { if (aux->accel_offset) { dumpAccelDot(f, i, - &((const gough_accel *)(reinterpret_cast(m) + aux->accel_offset))->accel); + &(reinterpret_cast(reinterpret_cast(m) + aux->accel_offset))->accel); } if (aux->accept_eod) { diff --git a/src/nfa/lbr_dump.cpp b/src/nfa/lbr_dump.cpp index 813af084..102b655c 100644 --- a/src/nfa/lbr_dump.cpp +++ b/src/nfa/lbr_dump.cpp @@ -126,8 +126,8 @@ void nfaExecLbrTruf_dump(const NFA *nfa, const string &base) { const lbr_truf *lt = reinterpret_cast(getImplNfa(nfa)); lbrDumpCommon(<->common, f); - CharReach cr = truffle2cr((const u8 *)(<->mask1), - (const u8 *)(<->mask2)); + CharReach cr = truffle2cr(reinterpret_cast(<->mask1), + reinterpret_cast(<->mask2)); fprintf(f, "TRUFFLE model, scanning for: %s (%zu chars)\n", describeClass(cr, 20, CC_OUT_TEXT).c_str(), cr.count()); fprintf(f, "\n"); diff --git a/src/parser/Parser.rl b/src/parser/Parser.rl index ae419ec8..668f3778 100644 --- a/src/parser/Parser.rl +++ b/src/parser/Parser.rl @@ -237,6 +237,7 @@ unichar readUtf8CodePoint2c(const char *s) { static unichar readUtf8CodePoint3c(const char *s) { + // cppcheck-suppress cstyleCast auto *ts = (const u8 *)s; assert(ts[0] >= 0xe0 && ts[0] < 0xf0); assert(ts[1] >= 0x80 && ts[1] < 0xc0); @@ -253,6 +254,7 @@ unichar readUtf8CodePoint3c(const char *s) { static unichar readUtf8CodePoint4c(const char *s) { + // cppcheck-suppress cstyleCast auto *ts = (const u8 *)s; assert(ts[0] >= 0xf0 && ts[0] < 0xf8); assert(ts[1] >= 0x80 && ts[1] < 0xc0); diff --git a/unit/internal/uniform_ops.cpp b/unit/internal/uniform_ops.cpp index 17a3f668..31f75e2d 100644 --- a/unit/internal/uniform_ops.cpp +++ b/unit/internal/uniform_ops.cpp @@ -52,6 +52,7 @@ TEST(Uniform, loadstore_u8) { for (int i = 0; i < 8; i++) { u8 in = 1 << i; const char *cin = reinterpret_cast(&in); + // cppcheck-suppress cstyleCast u8 out = load_u8(cin); EXPECT_EQ(in, out); char ALIGN_DIRECTIVE stored[1]; @@ -64,6 +65,7 @@ TEST(Uniform, loadstore_u16) { for (int i = 0; i < 16; i++) { u16 in = 1 << i; const char *cin = reinterpret_cast(&in); + // cppcheck-suppress cstyleCast u16 out = load_u16(cin); EXPECT_EQ(in, out); void *stored = aligned_zmalloc(2); @@ -77,6 +79,7 @@ TEST(Uniform, loadstore_u32) { for (int i = 0; i < 32; i++) { u32 in = 1U << i; const char *cin = reinterpret_cast(&in); + // cppcheck-suppress cstyleCast u32 out = load_u32(cin); EXPECT_EQ(in, out); void *stored = aligned_zmalloc(32/8); @@ -90,6 +93,7 @@ TEST(Uniform, loadstore_u64a) { for (int i = 0; i < 64; i++) { u64a in = 1ULL << i; const char *cin = reinterpret_cast(&in); + // cppcheck-suppress cstyleCast u64a out = load_u64a(cin); EXPECT_EQ(in, out); void *stored = aligned_zmalloc(64/8);