mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-09-29 19:24:25 +03:00
cStyleCasts
This commit is contained in:
@@ -70,7 +70,7 @@ TEST(CRC, alignments) {
|
||||
|
||||
// test the crc32c function at different alignments
|
||||
for (u8 i = 0; i < 32; i++) {
|
||||
u32 crc = Crc32c_ComputeBuf(0, (u8 *)a.data() + i, 4000);
|
||||
u32 crc = Crc32c_ComputeBuf(0, reinterpret_cast<u8 *>(a.data()) + i, 4000);
|
||||
ASSERT_EQ(crc, 0x94f04377U);
|
||||
}
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ struct LbrTestParams {
|
||||
|
||||
static
|
||||
int onMatch(u64a, u64a, ReportID, void *ctx) {
|
||||
unsigned *matches = (unsigned *)ctx;
|
||||
unsigned *matches = reinterpret_cast<unsigned *>(ctx);
|
||||
(*matches)++;
|
||||
return MO_CONTINUE_MATCHING;
|
||||
}
|
||||
@@ -191,7 +191,7 @@ TEST_P(LbrTest, MatchMin) {
|
||||
const string corpus = matchingCorpus(params.min);
|
||||
|
||||
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();
|
||||
|
||||
@@ -238,7 +238,7 @@ TEST_P(LbrTest, QueueExecToMatch) {
|
||||
const string corpus = matchingCorpus(params.min);
|
||||
|
||||
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();
|
||||
|
||||
|
@@ -305,7 +305,7 @@ TEST(MultiBit, It3) {
|
||||
const size_t test_size = 60;
|
||||
mmbit_holder ba(test_size, 4);
|
||||
|
||||
fill_n((u8 *)ba, mmbit_size(test_size) + 4, 0xff);
|
||||
fill_n(static_cast<u8 *>(ba), mmbit_size(test_size) + 4, 0xff);
|
||||
|
||||
mmbit_clear(ba, test_size);
|
||||
|
||||
|
@@ -66,13 +66,13 @@ void pack_bits<u64a>(char *out, const u64a *v, const u32 *bits,
|
||||
template <>
|
||||
void unpack_bits<u32>(u32 *v, const char *in, const u32 *bits,
|
||||
unsigned elements) {
|
||||
return unpack_bits_32(v, (const u8 *)in, bits, elements);
|
||||
return unpack_bits_32(v, reinterpret_cast<const u8 *>(in), bits, elements);
|
||||
}
|
||||
|
||||
template <>
|
||||
void unpack_bits<u64a>(u64a *v, const char *in, const u32 *bits,
|
||||
unsigned elements) {
|
||||
return unpack_bits_64(v, (const u8 *)in, bits, elements);
|
||||
return unpack_bits_64(v, reinterpret_cast<const u8 *>(in), bits, elements);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@@ -738,7 +738,7 @@ protected:
|
||||
ptr = new char[sizeof(RepeatInfo) +
|
||||
sizeof(u64a) * (rsi.patchSize + 2)];
|
||||
|
||||
info = (struct RepeatInfo *)ptr;
|
||||
info = reinterpret_cast<struct RepeatInfo *>(ptr);
|
||||
|
||||
info->type = REPEAT_SPARSE_OPTIMAL_P;
|
||||
info->repeatMin = test_info.repeatMin;
|
||||
@@ -756,7 +756,7 @@ protected:
|
||||
info->patchesOffset = rsi.patchesOffset;
|
||||
|
||||
u32 repeatMax = info->patchSize;
|
||||
u64a *table = (u64a *)(ROUNDUP_PTR((ptr + sizeof(RepeatInfo)),
|
||||
u64a *table = reinterpret_cast<u64a *>(ROUNDUP_PTR((ptr + sizeof(RepeatInfo)),
|
||||
alignof(u64a)));
|
||||
for (u32 i = 0; i < repeatMax + 1; i++) {
|
||||
table[i] = rsi.table[i];
|
||||
@@ -859,8 +859,8 @@ TEST_P(SparseOptimalTest, TwoTopsNeg) {
|
||||
}
|
||||
}
|
||||
|
||||
const struct RepeatRingControl *xs = (const struct RepeatRingControl *)
|
||||
ctrl;
|
||||
const struct RepeatRingControl *xs = reinterpret_cast<const struct RepeatRingControl *>
|
||||
(ctrl);
|
||||
ASSERT_EQ(exit2, repeatNextMatch(info, ctrl, state,
|
||||
MAX(xs->offset, exit)));
|
||||
ASSERT_EQ(exit2, repeatNextMatch(info, ctrl, state,
|
||||
|
@@ -39,8 +39,8 @@ TEST(RVermicelli, ExecNoMatch1) {
|
||||
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
for (size_t j = 0; j < 16; j++) {
|
||||
const u8 *begin = (const u8 *)t1 + i;
|
||||
const u8 *end = (const u8 *)t1 + strlen(t1) - j;
|
||||
const u8 *begin = reinterpret_cast<const u8 *>(t1) + i;
|
||||
const u8 *end = reinterpret_cast<const u8 *>(t1) + strlen(t1) - j;
|
||||
|
||||
const u8 *rv = rvermicelliExec('a', 0, begin, end);
|
||||
ASSERT_EQ(begin - 1, rv);
|
||||
@@ -58,12 +58,12 @@ TEST(RVermicelli, Exec1) {
|
||||
char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbb";
|
||||
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
const u8 *rv = rvermicelliExec('a', 0, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) - i);
|
||||
const u8 *rv = rvermicelliExec('a', 0, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 48, (size_t)rv);
|
||||
|
||||
rv = rvermicelliExec('A', 1, (u8 *)t1 + i, (u8 *)t1 + strlen(t1));
|
||||
rv = rvermicelliExec('A', 1, reinterpret_cast<const u8 *>(t1) + i, reinterpret_cast<const u8 *>(t1) + strlen(t1));
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 48, (size_t)rv);
|
||||
}
|
||||
@@ -73,12 +73,12 @@ TEST(RVermicelli, Exec2) {
|
||||
char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbb";
|
||||
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
const u8 *rv = rvermicelliExec('a', 0, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) - i);
|
||||
const u8 *rv = rvermicelliExec('a', 0, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 48, (size_t)rv);
|
||||
|
||||
rv = rvermicelliExec('A', 1, (u8 *)t1, (u8 *)t1 + strlen(t1) - i);
|
||||
rv = rvermicelliExec('A', 1, reinterpret_cast<const u8 *>(t1), reinterpret_cast<const u8 *>(t1) + strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 48, (size_t)rv);
|
||||
}
|
||||
@@ -88,12 +88,12 @@ TEST(RVermicelli, Exec3) {
|
||||
char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbaaaaaaaaaaaaaaaaaaaaaaAbbbbbbbbbbbbbbbbbbbbbb";
|
||||
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
const u8 *rv = rvermicelliExec('a', 0, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) - i);
|
||||
const u8 *rv = rvermicelliExec('a', 0, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1)+ strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 47, (size_t)rv);
|
||||
|
||||
rv = rvermicelliExec('A', 1, (u8 *)t1, (u8 *)t1 + strlen(t1) - i);
|
||||
rv = rvermicelliExec('A', 1, reinterpret_cast<const u8 *>(t1), reinterpret_cast<const u8 *>(t1) + strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 48, (size_t)rv);
|
||||
}
|
||||
@@ -104,11 +104,11 @@ TEST(RVermicelli, Exec4) {
|
||||
|
||||
for (size_t i = 0; i < 31; i++) {
|
||||
t1[16 + i] = 'a';
|
||||
const u8 *rv = rvermicelliExec('a', 0, (u8 *)t1, (u8 *)t1 + strlen(t1));
|
||||
const u8 *rv = rvermicelliExec('a', 0, reinterpret_cast<const u8 *>(t1), reinterpret_cast<const u8 *>(t1) + strlen(t1));
|
||||
|
||||
ASSERT_EQ((size_t)&t1[16 + i], (size_t)rv);
|
||||
|
||||
rv = rvermicelliExec('A', 1, (u8 *)t1, (u8 *)t1 + strlen(t1));
|
||||
rv = rvermicelliExec('A', 1, reinterpret_cast<const u8 *>(t1), reinterpret_cast<const u8 *>(t1) + strlen(t1));
|
||||
|
||||
ASSERT_EQ((size_t)&t1[16 + i], (size_t)rv);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ TEST(RVermicelli, Exec4) {
|
||||
|
||||
TEST(RNVermicelli, ExecNoMatch1) {
|
||||
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
|
||||
const u8 *buf = (const u8 *)t1;
|
||||
const u8 *buf = reinterpret_cast<const u8 *>(t1);
|
||||
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
SCOPED_TRACE(i);
|
||||
@@ -136,7 +136,7 @@ TEST(RNVermicelli, ExecNoMatch1) {
|
||||
|
||||
TEST(RNVermicelli, Exec1) {
|
||||
char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbb";
|
||||
const u8 *buf = (const u8 *)t1;
|
||||
const u8 *buf = reinterpret_cast<const u8 *>(t1);
|
||||
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
SCOPED_TRACE(i);
|
||||
@@ -152,7 +152,7 @@ TEST(RNVermicelli, Exec1) {
|
||||
|
||||
TEST(RNVermicelli, Exec2) {
|
||||
char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbb";
|
||||
const u8 *buf = (const u8 *)t1;
|
||||
const u8 *buf = reinterpret_cast<const u8 *>(t1);
|
||||
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
SCOPED_TRACE(i);
|
||||
@@ -168,7 +168,7 @@ TEST(RNVermicelli, Exec2) {
|
||||
|
||||
TEST(RNVermicelli, Exec3) {
|
||||
char t1[] = "bbbbbbbbbbbbbbbbbabbbbbbbbaaaaaaaaaaaaaaaaaaaaaaAbbbbbbbbbbbbbbbbbbbbbb";
|
||||
const u8 *buf = (const u8 *)t1;
|
||||
const u8 *buf = reinterpret_cast<const u8 *>(t1);
|
||||
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
SCOPED_TRACE(i);
|
||||
@@ -184,7 +184,7 @@ TEST(RNVermicelli, Exec3) {
|
||||
|
||||
TEST(RNVermicelli, Exec4) {
|
||||
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
|
||||
const u8 *buf = (const u8 *)t1;
|
||||
const u8 *buf = reinterpret_cast<const u8 *>(t1);
|
||||
|
||||
for (size_t i = 0; i < 31; i++) {
|
||||
SCOPED_TRACE(i);
|
||||
@@ -204,23 +204,23 @@ TEST(RDoubleVermicelli, Exec1) {
|
||||
char t1[] = "bbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbb";
|
||||
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
const u8 *rv = rvermicelliDoubleExec('a', 'b', 0, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) - i);
|
||||
const u8 *rv = rvermicelliDoubleExec('a', 'b', 0, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 50, (size_t)rv);
|
||||
|
||||
rv = rvermicelliDoubleExec('A', 'B', 1, (u8 *)t1 + i,
|
||||
(u8 *)t1 + strlen(t1));
|
||||
rv = rvermicelliDoubleExec('A', 'B', 1, reinterpret_cast<const u8 *>(t1)+ i,
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1));
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 50, (size_t)rv);
|
||||
|
||||
rv = rvermicelliDoubleExec('b', 'a', 0, (u8 *)t1 + i,
|
||||
(u8 *)t1 + strlen(t1));
|
||||
rv = rvermicelliDoubleExec('b', 'a', 0, reinterpret_cast<const u8 *>(t1) + i,
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1));
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 49, (size_t)rv);
|
||||
|
||||
rv = rvermicelliDoubleExec('B', 'A', 1, (u8 *)t1 + i,
|
||||
(u8 *)t1 + strlen(t1));
|
||||
rv = rvermicelliDoubleExec('B', 'A', 1, reinterpret_cast<const u8 *>(t1) + i,
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1));
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 49, (size_t)rv);
|
||||
}
|
||||
@@ -230,13 +230,13 @@ TEST(RDoubleVermicelli, Exec2) {
|
||||
char t1[] = "bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbaaaaabbbbbbbbbbbbbbbbbb";
|
||||
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
const u8 *rv = rvermicelliDoubleExec('a', 'a', 0, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) - i);
|
||||
const u8 *rv = rvermicelliDoubleExec('a', 'a', 0, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 52, (size_t)rv);
|
||||
|
||||
rv = rvermicelliDoubleExec('A', 'A', 1, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) - i);
|
||||
rv = rvermicelliDoubleExec('A', 'A', 1, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 52, (size_t)rv);
|
||||
}
|
||||
@@ -247,23 +247,23 @@ TEST(RDoubleVermicelli, Exec3) {
|
||||
char t1[] = "bbbbbbbbbbbbbbbbbaAaaAAaaaaaaaaaaaaaaaaaabbbbbbbaaaaabbbbbbbbbbbbbbbbbb";
|
||||
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
const u8 *rv = rvermicelliDoubleExec('A', 'a', 0, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) - i );
|
||||
const u8 *rv = rvermicelliDoubleExec('A', 'a', 0, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1) - i );
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 23, (size_t)rv);
|
||||
|
||||
rv = rvermicelliDoubleExec('A', 'A', 1, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) - i);
|
||||
rv = rvermicelliDoubleExec('A', 'A', 1, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 52, (size_t)rv);
|
||||
|
||||
rv = rvermicelliDoubleExec('A', 'A', 0, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) - i);
|
||||
rv = rvermicelliDoubleExec('A', 'A', 0, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 22, (size_t)rv);
|
||||
|
||||
rv = rvermicelliDoubleExec('a', 'A', 0, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) - i);
|
||||
rv = rvermicelliDoubleExec('a', 'A', 0, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)t1 + 21, (size_t)rv);
|
||||
}
|
||||
@@ -275,11 +275,11 @@ TEST(RDoubleVermicelli, Exec4) {
|
||||
for (size_t i = 0; i < 31; i++) {
|
||||
t1[32 + i] = 'a';
|
||||
t1[32 + i - 1] = 'a';
|
||||
const u8 *rv = rvermicelliDoubleExec('a', 'a', 0, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1));
|
||||
const u8 *rv = rvermicelliDoubleExec('a', 'a', 0, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1));
|
||||
ASSERT_EQ((size_t)&t1[32 + i], (size_t)rv);
|
||||
|
||||
rv = rvermicelliDoubleExec('A', 'A', 1, (u8 *)t1, (u8 *)t1 + strlen(t1));
|
||||
rv = rvermicelliDoubleExec('A', 'A', 1, reinterpret_cast<const u8 *>(t1), reinterpret_cast<const u8 *>(t1) + strlen(t1));
|
||||
|
||||
ASSERT_EQ((size_t)&t1[32 + i], (size_t)rv);
|
||||
}
|
||||
@@ -291,13 +291,13 @@ TEST(RDoubleVermicelli, Exec5) {
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
for (size_t j = 1; j <= 16; j++) {
|
||||
t1[strlen(t1) - i - j] = 'a';
|
||||
const u8 *rv = rvermicelliDoubleExec('b', 'a', 0, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) - i);
|
||||
const u8 *rv = rvermicelliDoubleExec('b', 'a', 0, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1) - i);
|
||||
|
||||
ASSERT_EQ((size_t)&t1[strlen(t1) - i - j], (size_t)rv);
|
||||
|
||||
rv = rvermicelliDoubleExec('B', 'A', 1, (u8 *)t1,
|
||||
(u8 *)t1 + strlen(t1) -i );
|
||||
rv = rvermicelliDoubleExec('B', 'A', 1, reinterpret_cast<const u8 *>(t1),
|
||||
reinterpret_cast<const u8 *>(t1) + strlen(t1) -i );
|
||||
|
||||
ASSERT_EQ((size_t)&t1[strlen(t1) - i - j], (size_t)rv);
|
||||
|
||||
|
Reference in New Issue
Block a user