From 89b31924b02a7b49f476a05c90195b9b7a613e80 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 8 Oct 2020 01:12:48 +0200 Subject: [PATCH] Fix some warnings found by Clang. --- plocate.cpp | 4 ++-- turbopfor-encode.h | 5 ++++- turbopfor.h | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plocate.cpp b/plocate.cpp index a9a961e..336483b 100644 --- a/plocate.cpp +++ b/plocate.cpp @@ -162,7 +162,7 @@ Corpus::~Corpus() void Corpus::find_trigram(uint32_t trgm, function cb) { uint32_t bucket = hash_trigram(trgm, hdr.hashtable_size); - engine->submit_read(fd, sizeof(Trigram) * (hdr.extra_ht_slots + 2), hdr.hash_table_offset_bytes + sizeof(Trigram) * bucket, [this, trgm, bucket, cb{ move(cb) }](string s) { + engine->submit_read(fd, sizeof(Trigram) * (hdr.extra_ht_slots + 2), hdr.hash_table_offset_bytes + sizeof(Trigram) * bucket, [this, trgm, cb{ move(cb) }](string s) { const Trigram *trgmptr = reinterpret_cast(s.data()); for (unsigned i = 0; i < hdr.extra_ht_slots + 1; ++i) { if (trgmptr[i].trgm == trgm) { @@ -382,7 +382,7 @@ void do_search_file(const vector &needles, const char *filename) if (done) break; } - engine.submit_read(fd, len, trgmptr.offset, [trgmptr, len, &done, &in1, &in2, &out](string s) { + engine.submit_read(fd, len, trgmptr.offset, [trgmptr{trgmptr}, len{len}, &done, &in1, &in2, &out](string s) { if (done) return; uint32_t trgm __attribute__((unused)) = trgmptr.trgm; diff --git a/turbopfor-encode.h b/turbopfor-encode.h index 532aa19..693bd30 100644 --- a/turbopfor-encode.h +++ b/turbopfor-encode.h @@ -13,9 +13,12 @@ #include "turbopfor-common.h" +#include + #include #include #include +#include template void write_le(Docid val, void *out) @@ -27,7 +30,7 @@ void write_le(Docid val, void *out) } else if constexpr (sizeof(Docid) == 2) { val = htole16(val); } else if constexpr (sizeof(Docid) == 1) { - val = val; + // No change. } else { assert(false); } diff --git a/turbopfor.h b/turbopfor.h index a21727a..6f8ef6f 100644 --- a/turbopfor.h +++ b/turbopfor.h @@ -8,6 +8,8 @@ // delta-plus-1 is implemented, and only 32-bit docids are tested), // but aim to be more portable and (ideally) easier-to-understand. // In particular, they will compile on x86 without SSE4.1 or AVX support. +// Unlike the reference code, only GCC and GCC-compatible compilers +// (e.g. Clang) are supported. // // The main reference is https://michael.stapelberg.ch/posts/2019-02-05-turbopfor-analysis/, // although some implementation details have been worked out by studying the -- 2.39.2