cstylecasts and suppressions

This commit is contained in:
gtsoul-tech 2024-05-22 10:16:56 +03:00
parent b312112e87
commit 94eff4aa60
5 changed files with 11 additions and 3 deletions

View File

@ -53,9 +53,11 @@ void hwlmGenerateDumpFiles(const HWLM *h, const string &base) {
switch (h->type) { switch (h->type) {
case HWLM_ENGINE_NOOD: case HWLM_ENGINE_NOOD:
// cppcheck-suppress cstyleCast
noodPrintStats(reinterpret_cast<const noodTable *>(HWLM_C_DATA(h)), f); noodPrintStats(reinterpret_cast<const noodTable *>(HWLM_C_DATA(h)), f);
break; break;
case HWLM_ENGINE_FDR: case HWLM_ENGINE_FDR:
// cppcheck-suppress cstyleCast
fdrPrintStats(reinterpret_cast<const FDR *>(HWLM_C_DATA(h)), f); fdrPrintStats(reinterpret_cast<const FDR *>(HWLM_C_DATA(h)), f);
break; break;
default: default:

View File

@ -123,7 +123,7 @@ void describeNode(const NFA *n, const mcclellan *m, u16 i, FILE *f) {
if (aux->accel_offset) { if (aux->accel_offset) {
dumpAccelDot(f, i, dumpAccelDot(f, i,
&((const gough_accel *)(reinterpret_cast<const char *>(m) + aux->accel_offset))->accel); &(reinterpret_cast<const gough_accel *>(reinterpret_cast<const char *>(m) + aux->accel_offset))->accel);
} }
if (aux->accept_eod) { if (aux->accept_eod) {

View File

@ -126,8 +126,8 @@ void nfaExecLbrTruf_dump(const NFA *nfa, const string &base) {
const lbr_truf *lt = reinterpret_cast<const lbr_truf *>(getImplNfa(nfa)); const lbr_truf *lt = reinterpret_cast<const lbr_truf *>(getImplNfa(nfa));
lbrDumpCommon(&lt->common, f); lbrDumpCommon(&lt->common, f);
CharReach cr = truffle2cr((const u8 *)(&lt->mask1), CharReach cr = truffle2cr(reinterpret_cast<const u8 *>(&lt->mask1),
(const u8 *)(&lt->mask2)); reinterpret_cast<const u8 *>(&lt->mask2));
fprintf(f, "TRUFFLE model, scanning for: %s (%zu chars)\n", fprintf(f, "TRUFFLE model, scanning for: %s (%zu chars)\n",
describeClass(cr, 20, CC_OUT_TEXT).c_str(), cr.count()); describeClass(cr, 20, CC_OUT_TEXT).c_str(), cr.count());
fprintf(f, "\n"); fprintf(f, "\n");

View File

@ -237,6 +237,7 @@ unichar readUtf8CodePoint2c(const char *s) {
static static
unichar readUtf8CodePoint3c(const char *s) { unichar readUtf8CodePoint3c(const char *s) {
// cppcheck-suppress cstyleCast
auto *ts = (const u8 *)s; auto *ts = (const u8 *)s;
assert(ts[0] >= 0xe0 && ts[0] < 0xf0); assert(ts[0] >= 0xe0 && ts[0] < 0xf0);
assert(ts[1] >= 0x80 && ts[1] < 0xc0); assert(ts[1] >= 0x80 && ts[1] < 0xc0);
@ -253,6 +254,7 @@ unichar readUtf8CodePoint3c(const char *s) {
static static
unichar readUtf8CodePoint4c(const char *s) { unichar readUtf8CodePoint4c(const char *s) {
// cppcheck-suppress cstyleCast
auto *ts = (const u8 *)s; auto *ts = (const u8 *)s;
assert(ts[0] >= 0xf0 && ts[0] < 0xf8); assert(ts[0] >= 0xf0 && ts[0] < 0xf8);
assert(ts[1] >= 0x80 && ts[1] < 0xc0); assert(ts[1] >= 0x80 && ts[1] < 0xc0);

View File

@ -52,6 +52,7 @@ TEST(Uniform, loadstore_u8) {
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
u8 in = 1 << i; u8 in = 1 << i;
const char *cin = reinterpret_cast<const char *>(&in); const char *cin = reinterpret_cast<const char *>(&in);
// cppcheck-suppress cstyleCast
u8 out = load_u8(cin); u8 out = load_u8(cin);
EXPECT_EQ(in, out); EXPECT_EQ(in, out);
char ALIGN_DIRECTIVE stored[1]; char ALIGN_DIRECTIVE stored[1];
@ -64,6 +65,7 @@ TEST(Uniform, loadstore_u16) {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
u16 in = 1 << i; u16 in = 1 << i;
const char *cin = reinterpret_cast<const char *>(&in); const char *cin = reinterpret_cast<const char *>(&in);
// cppcheck-suppress cstyleCast
u16 out = load_u16(cin); u16 out = load_u16(cin);
EXPECT_EQ(in, out); EXPECT_EQ(in, out);
void *stored = aligned_zmalloc(2); void *stored = aligned_zmalloc(2);
@ -77,6 +79,7 @@ TEST(Uniform, loadstore_u32) {
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
u32 in = 1U << i; u32 in = 1U << i;
const char *cin = reinterpret_cast<const char *>(&in); const char *cin = reinterpret_cast<const char *>(&in);
// cppcheck-suppress cstyleCast
u32 out = load_u32(cin); u32 out = load_u32(cin);
EXPECT_EQ(in, out); EXPECT_EQ(in, out);
void *stored = aligned_zmalloc(32/8); void *stored = aligned_zmalloc(32/8);
@ -90,6 +93,7 @@ TEST(Uniform, loadstore_u64a) {
for (int i = 0; i < 64; i++) { for (int i = 0; i < 64; i++) {
u64a in = 1ULL << i; u64a in = 1ULL << i;
const char *cin = reinterpret_cast<const char *>(&in); const char *cin = reinterpret_cast<const char *>(&in);
// cppcheck-suppress cstyleCast
u64a out = load_u64a(cin); u64a out = load_u64a(cin);
EXPECT_EQ(in, out); EXPECT_EQ(in, out);
void *stored = aligned_zmalloc(64/8); void *stored = aligned_zmalloc(64/8);