]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Add more C style casts fixes and suppressions
authorKonstantinos Margaritis <konstantinos@vectorcamp.gr>
Sat, 18 May 2024 18:48:40 +0000 (21:48 +0300)
committerKonstantinos Margaritis <konstantinos@vectorcamp.gr>
Sat, 18 May 2024 18:49:54 +0000 (21:49 +0300)
13 files changed:
src/nfa/limex_compile.cpp
src/nfa/mcclellan_internal.h
src/nfa/shengcompile.cpp
src/nfa/tamaramacompile.cpp
src/nfagraph/ng_lbr.cpp
src/parser/utf8_validate.cpp
src/util/alloc.cpp
src/util/uniform_ops.h
unit/hyperscan/extparam.cpp
unit/hyperscan/som.cpp
unit/internal/lbr.cpp
util/database_util.cpp
util/string_util.h

index 5b28e732a280cf6b0034b126f17824af54f59f35..68b91e1aa04ff022f78bf8eaa47c3a40a79471c0 100644 (file)
@@ -2132,7 +2132,7 @@ struct Factory {
                       const vector<NFAStateSet> &squash, implNFA_t *limex,
                       const u32 acceptsOffset, const u32 acceptsEodOffset,
                       const u32 squashOffset, const u32 reportListOffset) {
-        char *limex_base = (char *)limex;
+        char *limex_base = reinterpret_cast<char *>(limex);
 
         DEBUG_PRINTF("acceptsOffset=%u, acceptsEodOffset=%u, squashOffset=%u\n",
                      acceptsOffset, acceptsEodOffset, squashOffset);
@@ -2155,7 +2155,7 @@ struct Factory {
         limex->acceptOffset = acceptsOffset;
         limex->acceptCount = verify_u32(accepts.size());
         DEBUG_PRINTF("NFA has %zu accepts\n", accepts.size());
-        NFAAccept *acceptsTable = (NFAAccept *)(limex_base + acceptsOffset);
+        NFAAccept *acceptsTable = reinterpret_cast<NFAAccept *>(limex_base + acceptsOffset);
         assert(ISALIGNED(acceptsTable));
         transform(accepts.begin(), accepts.end(), acceptsTable,
                   transform_offset_fn);
@@ -2164,7 +2164,7 @@ struct Factory {
         limex->acceptEodOffset = acceptsEodOffset;
         limex->acceptEodCount = verify_u32(acceptsEod.size());
         DEBUG_PRINTF("NFA has %zu EOD accepts\n", acceptsEod.size());
-        NFAAccept *acceptsEodTable = (NFAAccept *)(limex_base + acceptsEodOffset);
+        NFAAccept *acceptsEodTable = reinterpret_cast<NFAAccept *>(limex_base + acceptsEodOffset);
         assert(ISALIGNED(acceptsEodTable));
         transform(acceptsEod.begin(), acceptsEod.end(), acceptsEodTable,
                   transform_offset_fn);
@@ -2173,7 +2173,7 @@ struct Factory {
         limex->squashCount = verify_u32(squash.size());
         limex->squashOffset = squashOffset;
         DEBUG_PRINTF("NFA has %zu report squash masks\n", squash.size());
-        tableRow_t *mask = (tableRow_t *)(limex_base + squashOffset);
+        tableRow_t *mask = reinterpret_cast<tableRow_t *>(limex_base + squashOffset);
         assert(ISALIGNED(mask));
         for (size_t i = 0, end = squash.size(); i < end; i++) {
             maskSetBits(mask[i], squash[i]);
@@ -2195,13 +2195,13 @@ struct Factory {
         for (u32 i = 0; i < num_repeats; i++) {
             repeatOffsets[i] = offset;
             assert(repeats[i]);
-            memcpy((char *)limex + offset, repeats[i].get(), repeats[i].size());
+            memcpy(reinterpret_cast<char *>(limex) + offset, repeats[i].get(), repeats[i].size());
             offset += repeats[i].size();
         }
 
         // Write repeat offset lookup table.
-        assert(ISALIGNED_N((char *)limex + repeatOffsetsOffset, alignof(u32)));
-        copy_bytes((char *)limex + repeatOffsetsOffset, repeatOffsets);
+        assert(ISALIGNED_N(reinterpret_cast<char *>(limex) + repeatOffsetsOffset, alignof(u32)));
+        copy_bytes(reinterpret_cast<char *>(limex) + repeatOffsetsOffset, repeatOffsets);
 
         limex->repeatOffset = repeatOffsetsOffset;
         limex->repeatCount = num_repeats;
@@ -2211,9 +2211,9 @@ struct Factory {
     void writeReportList(const vector<ReportID> &reports, implNFA_t *limex,
                          const u32 reportListOffset) {
         DEBUG_PRINTF("reportListOffset=%u\n", reportListOffset);
-        assert(ISALIGNED_N((char *)limex + reportListOffset,
+        assert(ISALIGNED_N(reinterpret_cast<char *>(limex) + reportListOffset,
                            alignof(ReportID)));
-        copy_bytes((char *)limex + reportListOffset, reports);
+        copy_bytes(reinterpret_cast<char *>(limex) + reportListOffset, reports);
     }
 
     static
@@ -2322,7 +2322,7 @@ struct Factory {
         auto nfa = make_zeroed_bytecode_ptr<NFA>(nfaSize);
         assert(nfa); // otherwise we would have thrown std::bad_alloc
 
-        implNFA_t *limex = (implNFA_t *)getMutableImplNfa(nfa.get());
+        implNFA_t *limex = reinterpret_cast<implNFA_t *>(getMutableImplNfa(nfa.get()));
         assert(ISALIGNED(limex));
 
         writeReachMapping(reach, reachMap, limex, reachOffset);
index 482fdb1bc9e614bc0af85bd4e3efcbf89c97084d..61b87200151a754fedde0b883fb4735af1dbe6ce 100644 (file)
@@ -106,9 +106,10 @@ static really_inline
 const char *findShermanState(UNUSED const struct mcclellan *m,
                              const char *sherman_base_offset, u32 sherman_base,
                              u32 s) {
-    const char *rv
-        = sherman_base_offset + SHERMAN_FIXED_SIZE * (s - sherman_base);
+    const char *rv = sherman_base_offset + SHERMAN_FIXED_SIZE * (s - sherman_base);
+    // cppcheck-suppress cstyleCast
     assert(rv < (const char *)m + m->length - sizeof(struct NFA));
+    // cppcheck-suppress cstyleCast
     UNUSED u8 type = *(const u8 *)(rv + SHERMAN_TYPE_OFFSET);
     assert(type == SHERMAN_STATE);
     return rv;
@@ -123,13 +124,15 @@ char *findMutableShermanState(char *sherman_base_offset, u16 sherman_base,
 static really_inline
 const char *findWideEntry8(UNUSED const struct mcclellan *m,
                            const char *wide_base, u32 wide_limit, u32 s) {
+    // cppcheck-suppress cstyleCast
     UNUSED u8 type = *(const u8 *)wide_base;
     assert(type == WIDE_STATE);
-    const u32 entry_offset
-        = *(const u32 *)(wide_base
+    // cppcheck-suppress cstyleCast
+    const u32 entry_offset = *(const u32 *)(wide_base
         + WIDE_ENTRY_OFFSET8((s - wide_limit) * sizeof(u32)));
 
     const char *rv = wide_base + entry_offset;
+    // cppcheck-suppress cstyleCast
     assert(rv < (const char *)m + m->length - sizeof(struct NFA));
     return rv;
 }
@@ -137,21 +140,23 @@ const char *findWideEntry8(UNUSED const struct mcclellan *m,
 static really_inline
 const char *findWideEntry16(UNUSED const struct mcclellan *m,
                             const char *wide_base, u32 wide_limit, u32 s) {
+    // cppcheck-suppress cstyleCast
     UNUSED u8 type = *(const u8 *)wide_base;
     assert(type == WIDE_STATE);
-    const u32 entry_offset
-        = *(const u32 *)(wide_base
+    // cppcheck-suppress cstyleCast
+    const u32 entry_offset = *(const u32 *)(wide_base
         + WIDE_ENTRY_OFFSET16((s - wide_limit) * sizeof(u32)));
 
     const char *rv = wide_base + entry_offset;
+    // cppcheck-suppress cstyleCast
     assert(rv < (const char *)m + m->length - sizeof(struct NFA));
     return rv;
 }
 
 static really_inline
 char *findMutableWideEntry16(char *wide_base, u32 wide_limit, u32 s) {
-    u32 entry_offset
-        = *(const u32 *)(wide_base
+    // cppcheck-suppress cstyleCast
+    u32 entry_offset = *(const u32 *)(wide_base
         + WIDE_ENTRY_OFFSET16((s - wide_limit) * sizeof(u32)));
 
     return wide_base + entry_offset;
index 2c45229a9fe947c273f04e5dbd35cac55ea2e35b..2fbda9a5f833b500bee6095cd62c05df671ffb38 100644 (file)
@@ -180,7 +180,7 @@ void raw_report_info_impl::fillReportLists(NFA *n, size_t base_offset,
     for (const auto &reps : rl) {
         ro.emplace_back(base_offset);
 
-        report_list *p = (report_list *)((char *)n + base_offset);
+        report_list *p = reinterpret_cast<report_list *>(reinterpret_cast<char *>(n) + base_offset);
 
         u32 i = 0;
         for (const ReportID report : reps.reports) {
@@ -389,17 +389,17 @@ static
 void fillAccelAux(struct NFA *n, dfa_info &info,
                   map<dstate_id_t, AccelScheme> &accelInfo) {
     DEBUG_PRINTF("Filling accel aux structures\n");
-    T *s = (T *)getMutableImplNfa(n);
+    T *s = reinterpret_cast<T *>(getMutableImplNfa(n));
     u32 offset = s->accel_offset;
 
     for (dstate_id_t i = 0; i < info.size(); i++) {
         dstate_id_t state_id = info.raw_id(i);
         if (accelInfo.find(state_id) != accelInfo.end()) {
             s->flags |= SHENG_FLAG_HAS_ACCEL;
-            AccelAux *aux = (AccelAux *)((char *)n + offset);
+            AccelAux *aux = reinterpret_cast<AccelAux *>(reinterpret_cast<char *>(n) + offset);
             info.strat.buildAccel(state_id, accelInfo[state_id], aux);
             sstate_aux *saux =
-                (sstate_aux *)((char *)n + s->aux_offset) + state_id;
+                reinterpret_cast<sstate_aux *>(reinterpret_cast<char *>(n) + s->aux_offset) + state_id;
             saux->accel = offset;
             DEBUG_PRINTF("Accel offset: %u\n", offset);
             offset += ROUNDUP_N(sizeof(AccelAux), alignof(AccelAux));
@@ -429,7 +429,7 @@ void populateBasicInfo<sheng>(struct NFA *n, dfa_info &info,
     n->type = SHENG_NFA;
     n->flags |= info.raw.hasEodReports() ? NFA_ACCEPTS_EOD : 0;
 
-    sheng *s = (sheng *)getMutableImplNfa(n);
+    sheng *s = reinterpret_cast<sheng *>(getMutableImplNfa(n));
     s->aux_offset = aux_offset;
     s->report_offset = report_offset;
     s->accel_offset = accel_offset;
@@ -454,7 +454,7 @@ void populateBasicInfo<sheng32>(struct NFA *n, dfa_info &info,
     n->type = SHENG_NFA_32;
     n->flags |= info.raw.hasEodReports() ? NFA_ACCEPTS_EOD : 0;
 
-    sheng32 *s = (sheng32 *)getMutableImplNfa(n);
+    sheng32 *s = reinterpret_cast<sheng32 *>(getMutableImplNfa(n));
     s->aux_offset = aux_offset;
     s->report_offset = report_offset;
     s->accel_offset = accel_offset;
@@ -479,7 +479,7 @@ void populateBasicInfo<sheng64>(struct NFA *n, dfa_info &info,
     n->type = SHENG_NFA_64;
     n->flags |= info.raw.hasEodReports() ? NFA_ACCEPTS_EOD : 0;
 
-    sheng64 *s = (sheng64 *)getMutableImplNfa(n);
+    sheng64 *s = reinterpret_cast<sheng64 *>(getMutableImplNfa(n));
     s->aux_offset = aux_offset;
     s->report_offset = report_offset;
     s->accel_offset = accel_offset;
@@ -495,15 +495,15 @@ template <typename T>
 static
 void fillTops(NFA *n, dfa_info &info, dstate_id_t id,
               map<dstate_id_t, AccelScheme> &accelInfo) {
-    T *s = (T *)getMutableImplNfa(n);
+    T *s = reinterpret_cast<T *>(getMutableImplNfa(n));
     u32 aux_base = s->aux_offset;
 
     DEBUG_PRINTF("Filling tops for state %u\n", id);
 
-    sstate_aux *aux = (sstate_aux *)((char *)n + aux_base) + id;
+    sstate_aux *aux = reinterpret_cast<sstate_aux *>(reinterpret_cast<char *>(n) + aux_base) + id;
 
     DEBUG_PRINTF("Aux structure for state %u, offset %zd\n", id,
-                 (char *)aux - (char *)n);
+                 reinterpret_cast<char *>(aux) - reinterpret_cast<char *>(n));
 
     /* we could conceivably end up in an accept/dead state on a top event,
      * so mark top as accept/dead state if it indeed is.
@@ -519,13 +519,13 @@ template <typename T>
 static
 void fillAux(NFA *n, dfa_info &info, dstate_id_t id, vector<u32> &reports,
                  vector<u32> &reports_eod, vector<u32> &report_offsets) {
-    T *s = (T *)getMutableImplNfa(n);
+    T *s = reinterpret_cast<T *>(getMutableImplNfa(n));
     u32 aux_base = s->aux_offset;
     auto raw_id = info.raw_id(id);
 
     auto &state = info[id];
 
-    sstate_aux *aux = (sstate_aux *)((char *)n + aux_base) + id;
+    sstate_aux *aux = reinterpret_cast<sstate_aux *>(reinterpret_cast<char *>(n) + aux_base) + id;
 
     DEBUG_PRINTF("Filling aux and report structures for state %u\n", id);
     DEBUG_PRINTF("Aux structure for state %u, offset %zd\n", id,
@@ -542,7 +542,7 @@ void fillAux(NFA *n, dfa_info &info, dstate_id_t id, vector<u32> &reports,
 template <typename T>
 static
 void fillSingleReport(NFA *n, ReportID r_id) {
-    T *s = (T *)getMutableImplNfa(n);
+    T *s = reinterpret_cast<T *>(getMutableImplNfa(n));
 
     DEBUG_PRINTF("Single report ID: %u\n", r_id);
     s->report = r_id;
@@ -689,7 +689,8 @@ bytecode_ptr<NFA> shengCompile_int(raw_dfa &raw, const CompileContext &cc,
         fillAccelOut(accelInfo, accel_states);
     }
 
-    if (!createShuffleMasks<T>((T *)getMutableImplNfa(nfa.get()), info, accelInfo)) {
+    T *s = reinterpret_cast<T *>(getMutableImplNfa(nfa.get()));
+    if (!createShuffleMasks<T>(s, info, accelInfo)) {
         return bytecode_ptr<NFA>(nullptr);
     }
 
@@ -727,18 +728,18 @@ bytecode_ptr<NFA> sheng32Compile(raw_dfa &raw, const CompileContext &cc,
                                  set<dstate_id_t> *accel_states) {
     if (!cc.grey.allowSheng) {
         DEBUG_PRINTF("Sheng is not allowed!\n");
-        bytecode_ptr<NFA>(nullptr);
+        return bytecode_ptr<NFA>(nullptr);
     }
 
 #ifdef HAVE_SVE
     if (svcntb()<32) {
         DEBUG_PRINTF("Sheng32 failed, SVE width is too small!\n");
-        bytecode_ptr<NFA>(nullptr);
+        return bytecode_ptr<NFA>(nullptr);
     }
 #else
     if (!cc.target_info.has_avx512vbmi()) {
         DEBUG_PRINTF("Sheng32 failed, no HS_CPU_FEATURES_AVX512VBMI!\n");
-        bytecode_ptr<NFA>(nullptr);
+        return bytecode_ptr<NFA>(nullptr);
     }
 #endif
 
index 57164908ffbc1d47a3638ed4a177f15a1d31c6a5..d9ae70b689e66dd1577a860a9230882177f64b79 100644 (file)
@@ -142,9 +142,9 @@ buildTamarama(const TamaInfo &tamaInfo, const u32 queue,
     nfa->length = verify_u32(total_size);
     nfa->queueIndex = queue;
 
-    char *ptr = (char *)nfa.get() + sizeof(NFA);
+    char *ptr = reinterpret_cast<char *>(nfa.get()) + sizeof(NFA);
     char *base_offset = ptr;
-    Tamarama *t = (Tamarama *)ptr;
+    Tamarama *t = reinterpret_cast<Tamarama *>(ptr);
     t->numSubEngines = verify_u32(subSize);
     t->activeIdxSize = verify_u8(activeIdxSize);
 
@@ -152,11 +152,11 @@ buildTamarama(const TamaInfo &tamaInfo, const u32 queue,
     copy_bytes(ptr, top_base);
     ptr += byte_length(top_base);
 
-    u32 *offsets = (u32 *)ptr;
+    u32 *offsets = reinterpret_cast<u32 *>(ptr);
     char *sub_nfa_offset = ptr + sizeof(u32) * subSize;
     copyInSubnfas(base_offset, *nfa, tamaInfo, offsets, sub_nfa_offset,
                   activeIdxSize);
-    assert((size_t)(sub_nfa_offset - (char *)nfa.get()) <= total_size);
+    assert(static_cast<size_t>(sub_nfa_offset - reinterpret_cast<char *>(nfa.get())) <= total_size);
     return nfa;
 }
 
index 209afc0512ece23a471ae7dc6780504b1113a470..fef0f439b0a65aff38d205dfa1e7cf73f2565138 100644 (file)
@@ -182,7 +182,7 @@ bytecode_ptr<NFA> buildLbrVerm(const CharReach &cr, const depth &repeatMin,
     enum RepeatType rtype = chooseRepeatType(repeatMin, repeatMax, minPeriod,
                                              is_reset);
     auto nfa = makeLbrNfa<lbr_verm>(LBR_NFA_VERM, rtype, repeatMax);
-    struct lbr_verm *lv = (struct lbr_verm *)getMutableImplNfa(nfa.get());
+    struct lbr_verm *lv = reinterpret_cast<struct lbr_verm *>(getMutableImplNfa(nfa.get()));
     lv->c = escapes.find_first();
 
     fillNfa<lbr_verm>(nfa.get(), &lv->common, report, repeatMin, repeatMax,
index 54c9755e8a8aee449a2002489e39107b41c06a7f..5a209c2c6060688dcefd4969a228fda4c88a3919 100644 (file)
@@ -65,7 +65,7 @@ bool isValidUtf8(const char *expression, const size_t len) {
         return true;
     }
 
-    const u8 *s = (const u8 *)expression;
+    const u8 *s = reinterpret_cast<const u8 *>(expression);
     u32 val;
 
     size_t i = 0;
index a6d30b335c10de53ed53bc70022739ae4af7d9c2..651fb1645bfc3863cbdea8c403fc77c654e27a70 100644 (file)
@@ -68,8 +68,8 @@ namespace ue2 {
 #endif
 
 void *aligned_malloc_internal(size_t size, size_t align) {
-    // cppcheck-suppress cstyleCast
     void *mem= nullptr;;
+    // cppcheck-suppress cstyleCast
     int rv = posix_memalign(&mem, align, size);
     if (rv != 0) {
         DEBUG_PRINTF("posix_memalign returned %d when asked for %zu bytes\n",
index 1c39c936d816305b844b89e71b40f7f89c3c3e26..fddc2253166b8b93c0a5e990a806de40d9b7b3ef 100644 (file)
 #include "unaligned.h"
 
 // Aligned loads
+#ifndef __cplusplus__
 #define load_u8(a)          (*(const u8 *)(a))
 #define load_u16(a)         (*(const u16 *)(a))
 #define load_u32(a)         (*(const u32 *)(a))
 #define load_u64a(a)        (*(const u64a *)(a))
+#else
+#define load_u8(a)          (*(reinterpret_cast<const u8 *>(a))
+#define load_u16(a)         (*(reinterpret_cast<const u16 *>(a))
+#define load_u32(a)         (*(reinterpret_cast<const u32 *>(a))
+#define load_u64a(a)        (*(reinterpret_cast<const u64a *>(a))
+#endif // __cplusplus__
 #define load_m128(a)        load128(a)
 #define load_m256(a)        load256(a)
 #define load_m384(a)        load384(a)
 #define load_m512(a)        load512(a)
 
 // Unaligned loads
+#ifndef __cplusplus__
 #define loadu_u8(a)          (*(const u8 *)(a))
 #define loadu_u16(a)         unaligned_load_u16((const u8 *)(a))
 #define loadu_u32(a)         unaligned_load_u32((const u8 *)(a))
 #define loadu_u64a(a)        unaligned_load_u64a((const u8 *)(a))
+#else
+#define loadu_u8(a)          (*(reinterpret_cast<const u8 *>(a))
+#define loadu_u16(a)         unaligned_load_u16(reinterpret_cast<const u8 *>(a))
+#define loadu_u32(a)         unaligned_load_u32(reinterpret_cast<const u8 *>(a))
+#define loadu_u64a(a)        unaligned_load_u64a(reinterpret_cast<const u8 *>(a))
+#endif // __cplusplus__
 #define loadu_m128(a)        loadu128(a)
 #define loadu_m256(a)        loadu256(a)
 #define loadu_m384(a)        loadu384(a)
 #define loadu_m512(a)        loadu512(a)
 
 // Aligned stores
-#define store_u8(ptr, a)    do { *(u8 *)(ptr) = (a); } while(0)
-#define store_u16(ptr, a)   do { *(u16 *)(ptr) = (a); } while(0)
-#define store_u32(ptr, a)   do { *(u32 *)(ptr) = (a); } while(0)
-#define store_u64a(ptr, a)  do { *(u64a *)(ptr) = (a); } while(0)
+#ifndef __cplusplus__
+#define store_u8(ptr, a)    do { *(reinterpret_cast<u8 *>(ptr)) = (a); } while(0)
+#define store_u16(ptr, a)   do { *(reinterpret_cast<u16 *>(ptr)) = (a); } while(0)
+#define store_u32(ptr, a)   do { *(reinterpret_cast<u32 *>(ptr)) = (a); } while(0)
+#define store_u64a(ptr, a)  do { *(reinterpret_cast<u64a *>(ptr)) = (a); } while(0)
+#else
+#endif // __cplusplus__
 #define store_m128(ptr, a)  store128(ptr, a)
 #define store_m256(ptr, a)  store256(ptr, a)
 #define store_m384(ptr, a)  store384(ptr, a)
 #define store_m512(ptr, a)  store512(ptr, a)
 
 // Unaligned stores
+#ifndef __cplusplus__
 #define storeu_u8(ptr, a)    do { *(u8 *)(ptr) = (a); } while(0)
+#else
+#define storeu_u8(ptr, a)    do { *(reinterpret_cast<u8 *>(ptr)) = (a); } while(0)
+#endif // __cplusplus__
 #define storeu_u16(ptr, a)   unaligned_store_u16(ptr, a)
 #define storeu_u32(ptr, a)   unaligned_store_u32(ptr, a)
 #define storeu_u64a(ptr, a)  unaligned_store_u64a(ptr, a)
index 8839f6b0ea20aa64c28eb2446ef34435832633cf..962218ca4d97144b1ff0fceb1e853839469f1dcf 100644 (file)
@@ -104,7 +104,7 @@ TEST(ExtParam, LargeExactOffset) {
     // Try the exact match.
     corpus = "hatstand" + string(199983, '_') + "teakettle";
     err = hs_scan(db, corpus.c_str(), corpus.length(), 0, scratch, record_cb,
-                  (void *)&c);
+                  reinterpret_cast<void *>(&c));
     ASSERT_EQ(HS_SUCCESS, err);
     ASSERT_EQ(1U, c.matches.size());
     ASSERT_EQ(MatchRecord(200000, 0), c.matches[0]);
index bf2d7c427a0da185db071045dc2284c8749e14c9..261c41e60e52502b818e9537bd3051b03dc846eb 100644 (file)
@@ -52,7 +52,7 @@ static
 int vectorCallback(unsigned id, unsigned long long from,
                    unsigned long long to, unsigned, void *ctx) {
     //printf("match id %u at (%llu,%llu)\n", id, from, to);
-    vector<Match> *matches = (vector<Match> *)ctx;
+    vector<Match> *matches = reinterpret_cast<vector<Match> *>(ctx);
     matches->push_back(Match(id, from, to));
     return 0;
 }
index fafe31eae3921befa8541848f62ea9f53cef8e58..c747c555c3bbc37e263f6f54a83ee0dd07b3bfd2 100644 (file)
@@ -212,7 +212,7 @@ TEST_P(LbrTest, MatchMax) {
     const string corpus = matchingCorpus(params.max);
 
     initQueue();
-    q.buffer = (const u8 *)corpus.c_str();
+    q.buffer = reinterpret_cast<const u8 *>(corpus.c_str());
     q.length = corpus.length();
     u64a end = corpus.length();
 
index 3df75e2a15e217cb3abcc6e0ad3a3610b63cdf35..dbad75618e9e068d9174fb36b2f8f8625eb40fee 100644 (file)
@@ -94,7 +94,7 @@ hs_database_t * loadDatabase(const char *filename, bool verbose) {
     }
     size_t len = st.st_size;
 
-    bytes = (char *)mmap(nullptr, len, PROT_READ, MAP_SHARED, fd, 0);
+    bytes = reinterpret_cast<char *>(mmap(nullptr, len, PROT_READ, MAP_SHARED, fd, 0));
     if (bytes == MAP_FAILED) {
         cout << "mmap failed" << endl;
         close(fd);
index ab3751c1feab8971e303e6915754a033fdb250c2..04d778af8730f29be78cc58dc1571206eb2af43c 100644 (file)
@@ -141,7 +141,7 @@ void prettyPrintRange(std::ostream &out, it_t begin, it_t end) {
 static really_inline
 char *makeHex(const unsigned char *pat, unsigned patlen) {
     size_t hexlen = patlen * 4;
-    char *hexbuf = (char *)malloc(hexlen + 1);
+    char *hexbuf = reinterpret_cast<char *>(malloc(hexlen + 1));
     unsigned i;
     char *buf;
     for (i = 0, buf = hexbuf; i < patlen; i++, buf += 4) {