]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
cstylecasts suppress,fixes 287/head
authorgtsoul-tech <gtsoulkanakis@gmail.com>
Mon, 20 May 2024 14:09:30 +0000 (17:09 +0300)
committergtsoul-tech <gtsoulkanakis@gmail.com>
Mon, 20 May 2024 14:09:30 +0000 (17:09 +0300)
src/database.h
src/fdr/fdr_confirm.h
src/nfa/gough_internal.h
src/nfa/mpv_internal.h
src/rose/rose_build_engine_blob.h
src/rose/rose_internal.h
src/smallwrite/smallwrite_internal.h
src/util/arch/common/simd_utils.h
src/util/arch/x86/simd_utils.h
src/util/partial_store.h
src/util/unaligned.h

index 1b94f1b020917be98ce3141d208b0ab8ca877577..b0a9c01b5ad1da0da2ec69ddf3b3efd440c7daca 100644 (file)
@@ -112,6 +112,7 @@ struct hs_database {
 
 static really_inline
 const void *hs_get_bytecode(const struct hs_database *db) {
+    // cppcheck-suppress cstyleCast
     return ((const char *)db + db->bytecode);
 }
 
index a23082cc6dbfb64fd29871d396dd2f051ed5237d..3615a6f8aedf304340663c660d4b043b2a9842c3 100644 (file)
@@ -84,9 +84,10 @@ struct FDRConfirm {
 
 static really_inline
 const u32 *getConfirmLitIndex(const struct FDRConfirm *fdrc) {
+    // cppcheck-suppress cstyleCast
     const u8 *base = (const u8 *)fdrc;
-    const u32 *litIndex =
-        (const u32 *)(base + ROUNDUP_N(sizeof(*fdrc), alignof(u32)));
+    // cppcheck-suppress cstyleCast
+    const u32 *litIndex =(const u32 *)(base + ROUNDUP_N(sizeof(*fdrc), alignof(u32)));
     assert(ISALIGNED(litIndex));
     return litIndex;
 }
index 8bf06e0f7f92bb3ae1f848ffa5caf34c55fc1595..a97ba25885a07c63062756a7c9ed73b0071d25ee 100644 (file)
@@ -92,6 +92,7 @@ struct gough_info {
 static really_inline
 const struct gough_info *get_gough(const struct mcclellan *m) {
     assert(m->haig_offset);
+    // cppcheck-suppress cstyleCast
     const char *n = (const char *)m - sizeof(struct NFA);
     return (const struct gough_info *)(n + m->haig_offset);
 }
@@ -102,6 +103,7 @@ const u32 *get_gough_top_offsets(const struct mcclellan *m) {
     if (!g->top_prog_offset) {
         return NULL;
     }
+    // cppcheck-suppress cstyleCast
     const char *n = (const char *)m - sizeof(struct NFA);
     return (const u32 *)(n + g->top_prog_offset);
 }
index b6b925043aa0706e708a7203d9e241680706f339..0a39a6f3888d4a49cfcbe08470ea3d5f79bd1f6c 100644 (file)
@@ -188,11 +188,13 @@ struct mpv_pq_item {
 static really_inline
 const struct mpv_puffette *get_puff_array(const struct mpv *m,
                                           const struct mpv_kilopuff *kp) {
+    // cppcheck-suppress cstyleCast
     return (const struct mpv_puffette *)((const char *)m + kp->puffette_offset);
 }
 
 static really_inline
 const struct mpv_counter_info *get_counter_info(const struct mpv *m) {
+    // cppcheck-suppress cstyleCast
     return (const struct mpv_counter_info *)((const char *)(m + 1)
                                  + m->kilo_count * sizeof(struct mpv_kilopuff));
 }
index da4e355de2073e0385456b6aca11e80e08727f2a..7c4adcea00dc8068223e0792d2d5475103c2c45c 100644 (file)
@@ -144,6 +144,7 @@ public:
     }
 
     void write_bytes(RoseEngine *engine) {
+        // cppcheck-suppress cstyleCast
         copy_bytes((char *)engine + base_offset, blob);
     }
 
index 7bd6779c3d4198adf0767128efb1f327accabc0a..5986dc7741268726b2857232e9ce5545b1f688a1 100644 (file)
@@ -560,9 +560,10 @@ const struct anchored_matcher_info *getALiteralMatcher(
     if (!t->amatcherOffset) {
         return NULL;
     }
-
+    // cppcheck-suppress cstyleCast
     const char *lt = (const char *)t + t->amatcherOffset;
     assert(ISALIGNED_CL(lt));
+    // cppcheck-suppress cstyleCast
     return (const struct anchored_matcher_info *)lt;
 }
 
@@ -573,9 +574,10 @@ const struct HWLM *getFLiteralMatcher(const struct RoseEngine *t) {
     if (!t->fmatcherOffset) {
         return NULL;
     }
-
+    // cppcheck-suppress cstyleCast
     const char *lt = (const char *)t + t->fmatcherOffset;
     assert(ISALIGNED_CL(lt));
+    // cppcheck-suppress cstyleCast
     return (const struct HWLM *)lt;
 }
 
@@ -584,7 +586,7 @@ const void *getSBLiteralMatcher(const struct RoseEngine *t) {
     if (!t->sbmatcherOffset) {
         return NULL;
     }
-
+    // cppcheck-suppress cstyleCast
     const char *matcher = (const char *)t + t->sbmatcherOffset;
     assert(ISALIGNED_N(matcher, 8));
     return matcher;
@@ -592,8 +594,8 @@ const void *getSBLiteralMatcher(const struct RoseEngine *t) {
 
 static really_inline
 const struct LeftNfaInfo *getLeftTable(const struct RoseEngine *t) {
-    const struct LeftNfaInfo *r
-        = (const struct LeftNfaInfo *)((const char *)t + t->leftOffset);
+    // cppcheck-suppress cstyleCast
+    const struct LeftNfaInfo *r = (const struct LeftNfaInfo *)((const char *)t + t->leftOffset);
     assert(ISALIGNED_N(r, 4));
     return r;
 }
@@ -603,16 +605,16 @@ struct mmbit_sparse_iter; // forward decl
 static really_inline
 const struct mmbit_sparse_iter *getActiveLeftIter(const struct RoseEngine *t) {
     assert(t->activeLeftIterOffset);
-    const struct mmbit_sparse_iter *it = (const struct mmbit_sparse_iter *)
-            ((const char *)t + t->activeLeftIterOffset);
+    // cppcheck-suppress cstyleCast
+    const struct mmbit_sparse_iter *it = (const struct mmbit_sparse_iter *)((const char *)t + t->activeLeftIterOffset);
     assert(ISALIGNED_N(it, 4));
     return it;
 }
 
 static really_inline
 const struct NfaInfo *getNfaInfoByQueue(const struct RoseEngine *t, u32 qi) {
-    const struct NfaInfo *infos
-        = (const struct NfaInfo *)((const char *)t + t->nfaInfoOffset);
+    // cppcheck-suppress cstyleCast
+    const struct NfaInfo *infos= (const struct NfaInfo *)((const char *)t + t->nfaInfoOffset);
     assert(ISALIGNED_N(infos, sizeof(u32)));
 
     return &infos[qi];
@@ -621,6 +623,7 @@ const struct NfaInfo *getNfaInfoByQueue(const struct RoseEngine *t, u32 qi) {
 static really_inline
 const struct NFA *getNfaByInfo(const struct RoseEngine *t,
                                const struct NfaInfo *info) {
+    // cppcheck-suppress cstyleCast
     return (const struct NFA *)((const char *)t + info->nfaOffset);
 }
 
@@ -650,9 +653,8 @@ const struct SmallWriteEngine *getSmallWrite(const struct RoseEngine *t) {
     if (!t->smallWriteOffset) {
         return NULL;
     }
-
-    const struct SmallWriteEngine *smwr =
-        (const struct SmallWriteEngine *)((const char *)t + t->smallWriteOffset);
+    // cppcheck-suppress cstyleCast
+    const struct SmallWriteEngine *smwr =(const struct SmallWriteEngine *)((const char *)t + t->smallWriteOffset);
     return smwr;
 }
 
index 8f350dbeaa3b90387ce449a83ecacfc9cdfb2745..50947ba3cd5af954264e2adef2313dd13ccb962b 100644 (file)
@@ -43,8 +43,8 @@ struct NFA;
 static really_inline
 const struct NFA *getSmwrNfa(const struct SmallWriteEngine *smwr) {
     assert(smwr);
-    const struct NFA *n
-        = (const struct NFA *)((const char *)smwr + sizeof(*smwr));
+    // cppcheck-suppress cstyleCast
+    const struct NFA *n= (const struct NFA *)((const char *)smwr + sizeof(*smwr));
     assert(ISALIGNED_CL(n));
     return n;
 }
index 24331b1037c85de3da5be4406699ec136d432cc4..6f091bc7ae5c2c2ff5e7a0cb976017103eebacfe 100644 (file)
@@ -238,6 +238,7 @@ static really_inline u32 diffrich64_256(m256 a, m256 b) {
 // aligned load
 static really_inline m256 load256(const void *ptr) {
     assert(ISALIGNED_N(ptr, alignof(m256)));
+    // cppcheck-suppress cstyleCast
     m256 rv = { load128(ptr), load128((const char *)ptr + 16) };
     return rv;
 }
@@ -255,11 +256,13 @@ static really_inline m256 loadu2x128(const void *ptr) {
 static really_inline void store256(void *ptr, m256 a) {
     assert(ISALIGNED_N(ptr, alignof(m256)));
     ptr = vectorscan_assume_aligned(ptr, 16);
+    // cppcheck-suppress cstyleCast
     *(m256 *)ptr = a;
 }
 
 // unaligned load
 static really_inline m256 loadu256(const void *ptr) {
+    // cppcheck-suppress cstyleCast
     m256 rv = { loadu128(ptr), loadu128((const char *)ptr + 16) };
     return rv;
 }
@@ -267,6 +270,7 @@ static really_inline m256 loadu256(const void *ptr) {
 // unaligned store
 static really_inline void storeu256(void *ptr, m256 a) {
     storeu128(ptr, a.lo);
+    // cppcheck-suppress cstyleCast
     storeu128((char *)ptr + 16, a.hi);
 }
 
@@ -476,8 +480,8 @@ static really_inline u32 diffrich64_384(m384 a, m384 b) {
 // aligned load
 static really_inline m384 load384(const void *ptr) {
     assert(ISALIGNED_16(ptr));
-    m384 rv = { load128(ptr), load128((const char *)ptr + 16),
-                load128((const char *)ptr + 32) };
+    // cppcheck-suppress cstyleCast
+    m384 rv = { load128(ptr), load128((const char *)ptr + 16),load128((const char *)ptr + 32) };
     return rv;
 }
 
@@ -485,13 +489,14 @@ static really_inline m384 load384(const void *ptr) {
 static really_inline void store384(void *ptr, m384 a) {
     assert(ISALIGNED_16(ptr));
     ptr = vectorscan_assume_aligned(ptr, 16);
+    // cppcheck-suppress cstyleCast
     *(m384 *)ptr = a;
 }
 
 // unaligned load
 static really_inline m384 loadu384(const void *ptr) {
-    m384 rv = { loadu128(ptr), loadu128((const char *)ptr + 16),
-                loadu128((const char *)ptr + 32)};
+    // cppcheck-suppress cstyleCast
+    m384 rv = { loadu128(ptr), loadu128((const char *)ptr + 16),loadu128((const char *)ptr + 32)};
     return rv;
 }
 
@@ -703,6 +708,7 @@ u32 diffrich64_512(m512 a, m512 b) {
 static really_inline
 m512 load512(const void *ptr) {
     assert(ISALIGNED_N(ptr, alignof(m256)));
+    // cppcheck-suppress cstyleCast
     m512 rv = { load256(ptr), load256((const char *)ptr + 32) };
     return rv;
 }
@@ -711,6 +717,7 @@ m512 load512(const void *ptr) {
 static really_inline
 void store512(void *ptr, m512 a) {
     assert(ISALIGNED_N(ptr, alignof(m512)));
+    // cppcheck-suppress cstyleCast
     m512 *x = (m512 *)ptr;
     store256(&x->lo, a.lo);
     store256(&x->hi, a.hi);
@@ -719,6 +726,7 @@ void store512(void *ptr, m512 a) {
 // unaligned load
 static really_inline
 m512 loadu512(const void *ptr) {
+    // cppcheck-suppress cstyleCast
     m512 rv = { loadu256(ptr), loadu256((const char *)ptr + 32) };
     return rv;
 }
index 49797ababa91ded8a574d8bd1315b6b9b45ffab1..1fc158009339588dad53292a913a8416d4da6db2 100644 (file)
@@ -290,6 +290,7 @@ static really_inline m128 andnot128(m128 a, m128 b) {
 static really_inline m128 load128(const void *ptr) {
     assert(ISALIGNED_N(ptr, alignof(m128)));
     ptr = vectorscan_assume_aligned(ptr, 16);
+    // cppcheck-suppress cstyleCast
     return _mm_load_si128((const m128 *)ptr);
 }
 
@@ -297,16 +298,19 @@ static really_inline m128 load128(const void *ptr) {
 static really_inline void store128(void *ptr, m128 a) {
     assert(ISALIGNED_N(ptr, alignof(m128)));
     ptr = vectorscan_assume_aligned(ptr, 16);
+    // cppcheck-suppress cstyleCast
     *(m128 *)ptr = a;
 }
 
 // unaligned load
 static really_inline m128 loadu128(const void *ptr) {
+    // cppcheck-suppress cstyleCast
     return _mm_loadu_si128((const m128 *)ptr);
 }
 
 // unaligned store
 static really_inline void storeu128(void *ptr, m128 a) {
+    // cppcheck-suppress cstyleCast
     _mm_storeu_si128 ((m128 *)ptr, a);
 }
 
index a49d1fae1dd39e9e5dbb9cc029f0ee88f87b5a26..efe357ccc7943ceff457b712b05a9e464696a894 100644 (file)
@@ -43,12 +43,14 @@ void partial_store_u32(void *ptr, u32 value, u32 numBytes) {
         break;
     case 3:
         unaligned_store_u16(ptr, (u16)value);
+        // cppcheck-suppress cstyleCast
         *((u8 *)ptr + 2) = (u8)(value >> 16);
         break;
     case 2:
         unaligned_store_u16(ptr, (u16)value);
         break;
     case 1:
+        // cppcheck-suppress cstyleCast
         *(u8 *)ptr = (u8)value;
         break;
     case 0:
@@ -66,12 +68,14 @@ u32 partial_load_u32(const void *ptr, u32 numBytes) {
         return value;
     case 3:
         value = unaligned_load_u16(ptr);
+        // cppcheck-suppress cstyleCast
         value |= ((u32)(*((const u8 *)ptr + 2)) << 16);
         return value;
     case 2:
         value = unaligned_load_u16(ptr);
         return value;
     case 1:
+        // cppcheck-suppress cstyleCast
         value = *(const u8 *)ptr;
         return value;
     case 0:
@@ -90,15 +94,19 @@ void partial_store_u64a(void *ptr, u64a value, u32 numBytes) {
         break;
     case 7:
         unaligned_store_u32(ptr, (u32)value);
+        // cppcheck-suppress cstyleCast
         unaligned_store_u16((u8 *)ptr + 4, (u16)(value >> 32));
+        // cppcheck-suppress cstyleCast
         *((u8 *)ptr + 6) = (u8)(value >> 48);
         break;
     case 6:
         unaligned_store_u32(ptr, (u32)value);
+        // cppcheck-suppress cstyleCast
         unaligned_store_u16((u8 *)ptr + 4, (u16)(value >> 32));
         break;
     case 5:
         unaligned_store_u32(ptr, (u32)value);
+        // cppcheck-suppress cstyleCast
         *((u8 *)ptr + 4) = (u8)(value >> 32);
         break;
     case 4:
@@ -106,12 +114,14 @@ void partial_store_u64a(void *ptr, u64a value, u32 numBytes) {
         break;
     case 3:
         unaligned_store_u16(ptr, (u16)value);
+        // cppcheck-suppress cstyleCast
         *((u8 *)ptr + 2) = (u8)(value >> 16);
         break;
     case 2:
         unaligned_store_u16(ptr, (u16)value);
         break;
     case 1:
+        // cppcheck-suppress cstyleCast
         *(u8 *)ptr = (u8)value;
         break;
     case 0:
@@ -129,15 +139,19 @@ u64a partial_load_u64a(const void *ptr, u32 numBytes) {
         return value;
     case 7:
         value = unaligned_load_u32(ptr);
+        // cppcheck-suppress cstyleCast
         value |= (u64a)unaligned_load_u16((const u8 *)ptr + 4) << 32;
+        // cppcheck-suppress cstyleCast
         value |= (u64a)(*((const u8 *)ptr + 6)) << 48;
         return value;
     case 6:
         value = unaligned_load_u32(ptr);
+        // cppcheck-suppress cstyleCast
         value |= (u64a)unaligned_load_u16((const u8 *)ptr + 4) << 32;
         return value;
     case 5:
         value = unaligned_load_u32(ptr);
+        // cppcheck-suppress cstyleCast
         value |= (u64a)(*((const u8 *)ptr + 4)) << 32;
         return value;
     case 4:
@@ -145,12 +159,14 @@ u64a partial_load_u64a(const void *ptr, u32 numBytes) {
         return value;
     case 3:
         value = unaligned_load_u16(ptr);
+        // cppcheck-suppress cstyleCast
         value |= (u64a)(*((const u8 *)ptr + 2)) << 16;
         return value;
     case 2:
         value = unaligned_load_u16(ptr);
         return value;
     case 1:
+        // cppcheck-suppress cstyleCast
         value = *(const u8 *)ptr;
         return value;
     case 0:
index a8fba6b1c61668abfb13e2c6e5703843d0b85c36..3f662de1219594d2565e0f29ea7382ff100c8b8a 100644 (file)
@@ -41,6 +41,7 @@
 static really_inline
 u16 unaligned_load_u16(const void *ptr) {
     struct unaligned { u16 u; } PACKED__MAY_ALIAS;
+    // cppcheck-suppress cstyleCast
     const struct unaligned *uptr = (const struct unaligned *)ptr;
     return uptr->u;
 }
@@ -49,6 +50,7 @@ u16 unaligned_load_u16(const void *ptr) {
 static really_inline
 u32 unaligned_load_u32(const void *ptr) {
     struct unaligned { u32 u; } PACKED__MAY_ALIAS;
+    // cppcheck-suppress cstyleCast
     const struct unaligned *uptr = (const struct unaligned *)ptr;
     return uptr->u;
 }
@@ -57,6 +59,7 @@ u32 unaligned_load_u32(const void *ptr) {
 static really_inline
 u64a unaligned_load_u64a(const void *ptr) {
     struct unaligned { u64a u; } PACKED__MAY_ALIAS;
+    // cppcheck-suppress cstyleCast
     const struct unaligned *uptr = (const struct unaligned *)ptr;
     return uptr->u;
 }
@@ -65,6 +68,7 @@ u64a unaligned_load_u64a(const void *ptr) {
 static really_inline
 void unaligned_store_u16(void *ptr, u16 val) {
     struct unaligned { u16 u; } PACKED__MAY_ALIAS;
+    // cppcheck-suppress cstyleCast
     struct unaligned *uptr = (struct unaligned *)ptr;
     uptr->u = val;
 }
@@ -73,6 +77,7 @@ void unaligned_store_u16(void *ptr, u16 val) {
 static really_inline
 void unaligned_store_u32(void *ptr, u32 val) {
     struct unaligned { u32 u; } PACKED__MAY_ALIAS;
+    // cppcheck-suppress cstyleCast
     struct unaligned *uptr = (struct unaligned *)ptr;
     uptr->u = val;
 }
@@ -81,6 +86,7 @@ void unaligned_store_u32(void *ptr, u32 val) {
 static really_inline
 void unaligned_store_u64a(void *ptr, u64a val) {
     struct unaligned { u64a u; } PACKED__MAY_ALIAS;
+    // cppcheck-suppress cstyleCast
     struct unaligned *uptr = (struct unaligned *)ptr;
     uptr->u = val;
 }