|
9 | 9 | #include <algorithm> |
10 | 10 | #include <regex> |
11 | 11 | #include <map> |
12 | | -#include <sstream> |
13 | 12 | #include <fstream> |
14 | 13 | #include <unordered_map> |
15 | 14 |
|
@@ -54,22 +53,24 @@ struct V { |
54 | 53 |
|
55 | 54 | std::ostream &operator<<(std::ostream &out, V v) { |
56 | 55 | char buffer[30]; |
| 56 | + const auto bufferSize = sizeof(buffer); |
57 | 57 | char *ptr = buffer; |
58 | 58 | auto val = v.v; |
59 | 59 | auto printHalf = [&](auto low, auto high) { |
60 | 60 | for(auto ndx = low; ndx < high; ++ndx) { |
61 | 61 | if(v.intraIndex == ndx) { |
62 | | - ptr += sprintf(ptr, "<"); |
| 62 | + ptr += snprintf(ptr, bufferSize, "<"); |
63 | 63 | } |
64 | | - ptr += sprintf(ptr, "%02lx", val & 0xFF); |
| 64 | + const std::size_t va = val & 0xFF; |
| 65 | + ptr += snprintf(ptr, bufferSize, "%02lx", va); |
65 | 66 | if(v.intraIndex == ndx) { |
66 | | - ptr += sprintf(ptr, ">"); |
| 67 | + ptr += snprintf(ptr, bufferSize, ">"); |
67 | 68 | } |
68 | 69 | val >>= 8; |
69 | 70 | } |
70 | 71 | }; |
71 | 72 | printHalf(0, 4); |
72 | | - ptr += sprintf(ptr, "'"); |
| 73 | + ptr += snprintf(ptr, bufferSize, "'"); |
73 | 74 | printHalf(4, 8); |
74 | 75 | out << buffer; |
75 | 76 | return out; |
@@ -143,7 +144,7 @@ TEST_CASE("Robin Hood", "[api][mapping][swar][robin-hood]") { |
143 | 144 | } |
144 | 145 | return true; |
145 | 146 | }; |
146 | | - |
| 147 | + |
147 | 148 | std::regex words("\\w+"); |
148 | 149 | std::sregex_iterator |
149 | 150 | wordsEnd{}, |
@@ -227,7 +228,7 @@ TEST_CASE("Robin Hood Metadata peek/poke u32 synthetic metadata basic", |
227 | 228 | CHECK(std::tuple{0,0} == zoo::rh::impl::peek(table.md_, 0)); |
228 | 229 | CHECK(std::tuple{0,0} == zoo::rh::impl::peek(table.md_, 2)); |
229 | 230 |
|
230 | | - // If we ask for a skarupke tail |
| 231 | + // If we ask for a skarupke tail |
231 | 232 | FrontendSmall32::Backend be{table.md_.data()}; |
232 | 233 | auto [index, deadline, metadata] = |
233 | 234 | be.findMisaligned_assumesSkarupkeTail(0x7, 1, [](int i) {return true;}); |
@@ -331,7 +332,7 @@ TEST_CASE("Robin Hood Metadata peek/poke u32 synthetic metadata psl one", |
331 | 332 | CHECK(i+1 == missIndex); |
332 | 333 | CHECK((missIndex)%4 == |
333 | 334 | FrontendSmall32::MD{missDeadline}.lsbIndex()); |
334 | | - CHECK(0x02 == |
| 335 | + CHECK(0x02 == |
335 | 336 | missMetadata.at(FrontendSmall32::MD{missDeadline}.lsbIndex())); |
336 | 337 | } |
337 | 338 | { |
@@ -375,7 +376,7 @@ TEST_CASE("Robin Hood Metadata peek/poke u32 synthetic metadata psl not one", |
375 | 376 | CHECK(i-p+4 == missIndex); |
376 | 377 | CHECK((missIndex)%4 == |
377 | 378 | FrontendSmall32::MD{missDeadline}.lsbIndex()); |
378 | | - CHECK(0x04 == |
| 379 | + CHECK(0x04 == |
379 | 380 | missMetadata.at(FrontendSmall32::MD{missDeadline}.lsbIndex())); |
380 | 381 | } |
381 | 382 | } |
@@ -449,7 +450,7 @@ TEST_CASE( |
449 | 450 | m.data_ = MD35u32Ops::SSL{0x0401'8201}; |
450 | 451 | CHECK(0x0000'8001u == m.attemptMatch(SM{hash1}, SM{psl1}).value()); |
451 | 452 | CHECK(0x0000'8001u == SO35u32Ops::attemptMatch(m.data_, SM{hash1}, SM{psl1}).value()); |
452 | | - } |
| 453 | + } |
453 | 454 | } |
454 | 455 |
|
455 | 456 | template<typename Container> |
@@ -485,7 +486,7 @@ TEST_CASE("RH Validation") { |
485 | 486 |
|
486 | 487 | while(corpus) { |
487 | 488 | getline(corpus, line); |
488 | | - |
| 489 | + |
489 | 490 | std::sregex_iterator |
490 | 491 | wordsEnd{}, |
491 | 492 | wordIterator{line.begin(), line.end(), words}; |
|
0 commit comments