fix(3p/nix): apply all clang-tidy fixes

Change-Id: I265e763393422ee1881653527c91024458060825
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1432
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
This commit is contained in:
Kane York 2020-07-24 21:09:44 -07:00 committed by kanepyork
parent 69f402563a
commit ef54f5da9f
65 changed files with 580 additions and 497 deletions

View file

@ -22,16 +22,16 @@ static void search(const unsigned char* s, size_t len, StringSet& hashes,
i = false;
}
for (char base32Char : base32Chars) {
isBase32[(unsigned char)base32Char] = true;
isBase32[static_cast<unsigned char>(base32Char)] = true;
}
initialised = true;
}
for (size_t i = 0; i + refLength <= len;) {
int j;
int j = 0;
bool match = true;
for (j = refLength - 1; j >= 0; --j) {
if (!isBase32[(unsigned char)s[i + j]]) {
if (!isBase32[s[i + j]]) {
i += j + 1;
match = false;
break;
@ -40,7 +40,7 @@ static void search(const unsigned char* s, size_t len, StringSet& hashes,
if (!match) {
continue;
}
std::string ref((const char*)s + i, refLength);
std::string ref(reinterpret_cast<const char*>(s) + i, refLength);
if (hashes.find(ref) != hashes.end()) {
DLOG(INFO) << "found reference to '" << ref << "' at offset " << i;
seen.insert(ref);
@ -68,17 +68,19 @@ void RefScanSink::operator()(const unsigned char* data, size_t len) {
/* It's possible that a reference spans the previous and current
fragment, so search in the concatenation of the tail of the
previous fragment and the start of the current fragment. */
std::string s =
tail + std::string((const char*)data, len > refLength ? refLength : len);
search((const unsigned char*)s.data(), s.size(), hashes, seen);
std::string s = tail + std::string(reinterpret_cast<const char*>(data),
len > refLength ? refLength : len);
search(reinterpret_cast<const unsigned char*>(s.data()), s.size(), hashes,
seen);
search(data, len, hashes, seen);
size_t tailLen = len <= refLength ? len : refLength;
tail = std::string(tail, tail.size() < refLength - tailLen
? 0
: tail.size() - (refLength - tailLen)) +
std::string((const char*)data + len - tailLen, tailLen);
tail =
std::string(tail, tail.size() < refLength - tailLen
? 0
: tail.size() - (refLength - tailLen)) +
std::string(reinterpret_cast<const char*>(data) + len - tailLen, tailLen);
}
PathSet scanForReferences(const std::string& path, const PathSet& refs,