std::array<char, IPAddressV6::kToFullyQualifiedSize> ip;
size_t pos = 0;
int count = 0;
- for (int p = pieces.size() - 1; p >= 0; p--) {
- ip[pos] = pieces[p][0];
+ for (size_t i = 1; i <= pieces.size(); i++) {
+ ip[pos] = pieces[pieces.size() - i][0];
pos++;
count++;
// add ':' every 4 chars
forwardPointers_(reinterpret_cast<SkipValueType*>(
result.forwardPointers)),
result_(result) {
- std::fill(result.data.begin(), result.data.end(), 0);
+ std::fill(result.data.begin(), result.data.end(), '\0');
}
EliasFanoEncoderV2(size_t size, ValueType upperBound)
void JemallocNodumpAllocator::deallocate(void* p, void* userData) {
const uint64_t flags = reinterpret_cast<uint64_t>(userData);
- dallocx != nullptr ? dallocx(p, flags) : free(p);
+ dallocx != nullptr ? dallocx(p, static_cast<int>(flags)) : free(p);
}
JemallocNodumpAllocator& globalJemallocNodumpAllocator() {
assert(sslState_ == STATE_UNINIT);
noTransparentTls_ = true;
totalConnectTimeout_ = totalConnectTimeout;
- AsyncSSLSocketConnector* connector =
- new AsyncSSLSocketConnector(this, callback, totalConnectTimeout.count());
+ AsyncSSLSocketConnector* connector = new AsyncSSLSocketConnector(
+ this, callback, int(totalConnectTimeout.count()));
AsyncSocket::connect(
- connector, address, connectTimeout.count(), options, bindAddr);
+ connector, address, int(connectTimeout.count()), options, bindAddr);
}
bool AsyncSSLSocket::needsPeerVerification() const {
queue.append(std::move(sslSock->preReceivedData_));
queue.trimStart(len);
sslSock->preReceivedData_ = queue.move();
- return len;
+ return static_cast<int>(len);
} else {
- auto result = recv(OpenSSLUtils::getBioFd(b, nullptr), out, outl, 0);
+ auto result = int(recv(OpenSSLUtils::getBioFd(b, nullptr), out, outl, 0));
if (result <= 0 && OpenSSLUtils::getBioShouldRetryWrite(result)) {
BIO_set_retry_read(b);
}
}
}
- for (size_t i = 0; i < (size_t)sk_GENERAL_NAME_num(altNames); i++) {
+ for (int i = 0; i < sk_GENERAL_NAME_num(altNames); i++) {
auto name = sk_GENERAL_NAME_value(altNames, i);
if ((addr4 != nullptr || addr6 != nullptr) && name->type == GEN_IPADD) {
// Extra const-ness for paranoia
QueueAppender appender{&queue, 125};
std::vector<uint8_t> data;
data.resize(1000);
- std::iota(data.begin(), data.end(), 0);
+ std::iota(data.begin(), data.end(), uint8_t(0));
// Add 100 byte
appender.pushAtMost(data.data(), 100);
// Add 900 bytes
TEST(IOBufQueue, Preallocate) {
IOBufQueue queue(clOptions);
queue.append(string("Hello"));
- pair<void*,uint32_t> writable = queue.preallocate(2, 64, 64);
+ pair<void*, uint64_t> writable = queue.preallocate(2, 64, 64);
checkConsistency(queue);
EXPECT_NE((void*)nullptr, writable.first);
EXPECT_LE(2, writable.second);
}
EXPECT_EQ(
vals.size(),
- std::unordered_set<uint32_t>(vals.begin(), vals.end()).size());
+ std::unordered_set<uint64_t>(vals.begin(), vals.end()).size());
}
}
for (size_t i = 0; i < count; i++) {
size_t size = sizeDist(rnd);
uint8_t* p = static_cast<uint8_t*>(arena_->allocate(size));
- areas_.emplace_back(rnd() & 0xff, Range<uint8_t*>(p, size));
+ areas_.emplace_back(uint8_t(rnd() & 0xff), Range<uint8_t*>(p, size));
}
// Fill each area with a different value, to prove that they don't overlap
// Fill in random order.
- std::random_shuffle(
- areas_.begin(), areas_.end(),
- [&rnd] (int n) -> int {
- return std::uniform_int_distribution<uint32_t>(0, n-1)(rnd);
- });
+ std::random_shuffle(areas_.begin(), areas_.end(), [&rnd](ptrdiff_t n) {
+ return std::uniform_int_distribution<uint32_t>(0, n - 1)(rnd);
+ });
for (auto& p : areas_) {
std::fill(p.second.begin(), p.second.end(), p.first);