Skip to content

Commit

Permalink
Upgrade to NDK r26c with its new clang-tidy build.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurik committed Feb 27, 2024
1 parent 7c6c27c commit 4140b0b
Show file tree
Hide file tree
Showing 41 changed files with 156 additions and 117 deletions.
2 changes: 1 addition & 1 deletion env/setup-ndk.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
set -e
set -o pipefail
echo y | "${ANDROID_HOME}"/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.2" "ndk;25.2.9519653" "platforms;android-33" >/dev/null
echo y | "${ANDROID_HOME}"/cmdline-tools/latest/bin/sdkmanager "build-tools;29.0.2" "ndk;26.2.11394342" "platforms;android-33" >/dev/null
2 changes: 1 addition & 1 deletion env/target-elf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


include $(pwd)/target-lld.mk
lflags += -Wl,-error-limit=0
#lflags += -Wl,-error-limit=0
lflags += -Wl,--build-id=none
lflags += -Wl,-z,relro
lflags += -Wl,--no-undefined
Expand Down
3 changes: 3 additions & 0 deletions min-v8/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,7 @@ cflags += -mno-ms-bitfields
# https://bugs.chromium.org/p/chromium/issues/detail?id=1016945
cflags/$(pwd/v8)/ += -Wno-builtin-assume-aligned-alignment

# XXX: they might have already changed many of these cases
cflags/$(pwd/v8)/ += -Wno-unused-but-set-variable

archive += $(pwd/v8)/
3 changes: 3 additions & 0 deletions min-wireshark/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ cflags/$(pwd/wireshark)/ += -Wno-pointer-sign
# XXX: fwrite used without check; submit patch
cflags/$(pwd/wireshark)/ += -Wno-unused-result

# XXX: this is only used if you have libgnutls and I don't know what I think about that :/
cflags/$(pwd/wireshark)/epan/dissectors/packet-tls-utils.c += -Wno-unused-but-set-variable

cflags/$(pwd/wireshark)/ += -I$(pwd/wireshark)/epan
cflags/$(pwd/wireshark)/ += -I$(pwd/wireshark)/epan/dfilter
cflags/$(pwd/wireshark)/ += -I$(pwd/wireshark)/epan/dissectors
Expand Down
2 changes: 1 addition & 1 deletion min-zlib/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

source += $(wildcard $(pwd)/libz/*.c)
archive += $(pwd)/libz/
cflags/$(pwd)/libz/ += -Wno-deprecated-non-prototype
cflags/$(pwd)/libz/ += -Wno-unused-function
cflags/$(pwd)/libz/ += -Wno-unused-variable
qflags += -DCHROMIUM_ZLIB_NO_CHROMECONF
cflags += -I$(pwd)/libz
cflags += -I$(pwd)/extra
Expand Down
2 changes: 1 addition & 1 deletion p2p/boost
Submodule boost updated 136 files
2 changes: 1 addition & 1 deletion p2p/c-ares
Submodule c-ares updated 403 files
6 changes: 4 additions & 2 deletions p2p/source/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,13 +817,15 @@ class Flat final :
Flat(const Buffer &buffer) :
data_(nullptr)
{
if ((copy_ = !buffer.each([&](const uint8_t *data, size_t size) {
copy_ = !buffer.each([&](const uint8_t *data, size_t size) {
if (data_ != nullptr)
return false;
size_ = size;
data_ = data;
return true;
}))) {
});

if (copy_) {
size_ = buffer.size();
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
const auto data(new uint8_t[size_]);
Expand Down
2 changes: 1 addition & 1 deletion p2p/source/cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Cache {
}

Type_ &operator ()(const Args_ &args) {
std::unique_lock<std::mutex> lock(mutex_);
const std::unique_lock<std::mutex> lock(mutex_);
const auto &cache(cache_.find(args));
if (cache != cache_.end())
return cache->second;
Expand Down
16 changes: 9 additions & 7 deletions p2p/source/category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@

namespace orc {

// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
static std::mutex mutex_;
static std::map<int, std::exception_ptr> errors_;
static int index_(0);
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
namespace {
// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
std::mutex mutex_;
std::map<int, std::exception_ptr> errors_;
int index_(0);
// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
}

std::string Category::message(int index) const {
try {
Expand All @@ -43,14 +45,14 @@ std::string Category::message(int index) const {
}

std::exception_ptr Category::Convert(int index) noexcept {
std::unique_lock<std::mutex> lock(mutex_);
const std::unique_lock<std::mutex> lock(mutex_);
if (const auto error = errors_.extract(index))
return error.mapped();
orc_insist(false);
}

boost::system::error_code Category::Convert(const std::exception_ptr &error) noexcept {
std::unique_lock<std::mutex> lock(mutex_);
const std::unique_lock<std::mutex> lock(mutex_);
// XXX: clang-tidy might need fixing, as this just bans ?:
// NOLINTNEXTLINE(readability-implicit-bool-conversion)
while (!errors_.try_emplace(++index_ ?: ++index_, error).second);
Expand Down
17 changes: 10 additions & 7 deletions p2p/source/chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@

namespace orc {

static std::optional<Address> MaybeAddress(const Json::Value &address) {
namespace {
std::optional<Address> MaybeAddress(const Json::Value &address) {
if (address.isNull())
return std::nullopt;
return address.asString();
}
} }

static Nested Verify(const Json::Value &proofs, Brick<32> hash, const Region &path) {
namespace {
Nested Verify(const Json::Value &proofs, Brick<32> hash, const Region &path) {
size_t offset(0);
orc_assert(!proofs.isNull());
for (auto e(proofs.size()), i(decltype(e)(0)); i != e; ++i) {
Expand Down Expand Up @@ -73,7 +75,7 @@ static Nested Verify(const Json::Value &proofs, Brick<32> hash, const Region &pa

orc_assert(hash == EmptyVector);
return nullptr;
}
} }

Receipt::Receipt(Json::Value &&value) :
height_(To<uint64_t>(value["blockNumber"].asString())),
Expand Down Expand Up @@ -171,7 +173,7 @@ Record::Record(const uint256_t &chain, const Json::Value &value) :
std::vector<Bytes32> keys;
for (const auto &key : entry["storageKeys"])
keys.emplace_back(Bless(key.asString()));
access.emplace_back(decltype(access_)::value_type(entry["address"].asString(), std::move(keys)));
access.emplace_back(entry["address"].asString(), std::move(keys));
}
return access;
}(),
Expand Down Expand Up @@ -339,14 +341,15 @@ uint256_t Chain::Get(Json::Value::ArrayIndex index, const Json::Value &storages,
return value;
}

static Brick<32> Name(const std::string &name) {
namespace {
Brick<32> Name(const std::string &name) {
if (name.empty())
return Zero<32>();
const auto period(name.find('.'));
if (period == std::string::npos)
return HashK(Tie(Zero<32>(), HashK(name)));
return HashK(Tie(Name(name.substr(period + 1)), HashK(name.substr(0, period))));
}
} }

task<S<Chain>> Chain::New(Endpoint endpoint, Flags flags, uint256_t chain) {
co_return Break<Chain>(std::move(endpoint), std::move(flags), std::move(chain));
Expand Down
4 changes: 2 additions & 2 deletions p2p/source/cipher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Encipher {
Beam operator ()() const;

static Beam All(const EVP_CIPHER *algorithm, const Region &key, const Region &iv, const Buffer &data) {
Encipher cipher(algorithm, key, iv);
const Encipher cipher(algorithm, key, iv);
const auto lhs(cipher(data));
const auto rhs(cipher());
return Beam(Tie(lhs, rhs));
Expand All @@ -74,7 +74,7 @@ class Decipher {
Beam operator ()() const;

static Beam All(const EVP_CIPHER *algorithm, const Region &key, const Region &iv, const Buffer &data) {
Decipher cipher(algorithm, key, iv);
const Decipher cipher(algorithm, key, iv);
const auto lhs(cipher(data));
const auto rhs(cipher());
return Beam(Tie(lhs, rhs));
Expand Down
7 changes: 4 additions & 3 deletions p2p/source/crypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,12 @@ Signature::Signature(const Brick<65> &data) {
}


static const secp256k1_context *Curve() {
namespace {
const secp256k1_context *Curve() {
// NOLINTNEXTLINE(misc-redundant-expression)
static std::unique_ptr<secp256k1_context, decltype(&secp256k1_context_destroy)> context_{secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY), &secp256k1_context_destroy};
static const std::unique_ptr<secp256k1_context, decltype(&secp256k1_context_destroy)> context_{secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY), &secp256k1_context_destroy};
return context_.get();
}
} }

bool operator ==(const Key &lhs, const Key &rhs) {
const auto context(Curve());
Expand Down
4 changes: 2 additions & 2 deletions p2p/source/datagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ bool Datagram(const Buffer &data, const std::function<bool (const Socket &, cons
const auto udp(window.Take<openvpn::UDPHeader>());
orc_assert(window.size() == boost::endian::big_to_native(udp.len) - sizeof(udp));

Socket source(boost::endian::big_to_native(ip4.saddr), boost::endian::big_to_native(udp.source));
Socket destination(boost::endian::big_to_native(ip4.daddr), boost::endian::big_to_native(udp.dest));
const Socket source(boost::endian::big_to_native(ip4.saddr), boost::endian::big_to_native(udp.source));
const Socket destination(boost::endian::big_to_native(ip4.daddr), boost::endian::big_to_native(udp.dest));

return code(source, destination, std::move(window));
}, "parsing packet: " << data); }
Expand Down
4 changes: 2 additions & 2 deletions p2p/source/encoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ std::string utf(const std::u16string &value) {
if (value.empty())
return data;
data.resize(value.size() * 5);
int writ(WideCharToMultiByte(CP_UTF8, 0, w16(value.data()), Fit(value.size()), &data[0], Fit(data.size() * sizeof(data[0])), nullptr, nullptr))
const int writ(WideCharToMultiByte(CP_UTF8, 0, w16(value.data()), Fit(value.size()), &data[0], Fit(data.size() * sizeof(data[0])), nullptr, nullptr))
;
orc_assert(writ != 0);
data.resize(writ / sizeof(data[0]));
Expand All @@ -48,7 +48,7 @@ std::u16string utf(const std::string &value) {
if (value.empty())
return data;
data.resize(value.size());
int writ(MultiByteToWideChar(CP_UTF8, 0, value.data(), Fit(value.size() * sizeof(value[0])), w16(&data[0]), Fit(data.size())));
const int writ(MultiByteToWideChar(CP_UTF8, 0, value.data(), Fit(value.size() * sizeof(value[0])), w16(&data[0]), Fit(data.size())));
orc_assert(writ != 0);
data.resize(writ);
return data;
Expand Down
4 changes: 4 additions & 0 deletions p2p/source/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Error final :

template <typename Type_>
Error operator <<(const Type_ &value) && {
// NOLINTNEXTLINE(misc-const-correctness)
std::ostringstream data;
data << value;
what_ += data.str();
Expand Down Expand Up @@ -89,10 +90,13 @@ class Error final :
orc_log(orc_Log(), "handled error: " << error.what() << std::endl); \
code } catch (...) { code }

// XXX: clang-tidy fails to consider statement expressions
// NOLINTBEGIN(bugprone-assignment-in-if-condition)
#define orc_ignore(code) \
({ bool _failed(false); try code \
orc_catch({ _failed = true; }) \
_failed; })
// NOLINTEND(bugprone-assignment-in-if-condition)

#define orc_except(code) \
try code catch (...) { \
Expand Down
35 changes: 22 additions & 13 deletions p2p/source/load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
#include <winsock2.h>
#endif

#include <fstream>

#include <sys/stat.h>
#include <sys/types.h>

#include <boost/filesystem/string_file.hpp>

#include "syscall.hpp"

namespace orc {
Expand All @@ -42,28 +42,37 @@ void Create(const std::string &path) {
#endif
}

void Delete(const std::string &file) {
orc_syscall(unlink(file.c_str()));
void Delete(const std::string &path) {
orc_syscall(unlink(path.c_str()));
}

bool Exists(const std::string &path) {
return orc_syscall(access(path.c_str(), F_OK), ENOENT) == 0;
}

uint64_t Modified(const std::string &file) {
uint64_t Modified(const std::string &path) {
struct stat info{};
orc_syscall(stat(file.c_str(), &info));
orc_syscall(stat(path.c_str(), &info));
return info.st_mtime;
}

std::string Load(const std::string &file) { orc_block({
std::string Load(const std::string &path) { orc_block({
std::ifstream file;
file.exceptions(std::ifstream::failbit | std::ifstream::badbit);
file.open(path, std::ios::binary);
file.seekg(0, std::ios::end);
std::string data;
boost::filesystem::load_string_file(file, data);
data.resize(file.tellg());
file.seekg(0, std::ios::beg);
file.read(data.data(), data.size());
return data;
}, "loading from " << file); }

void Save(const std::string &file, const std::string &data) { orc_block({
boost::filesystem::save_string_file(file, data);
}, "saving to " << file); }
}, "loading from " << path); }

void Save(const std::string &path, const std::string &data) { orc_block({
std::ofstream file;
file.exceptions(std::ofstream::failbit | std::ofstream::badbit);
file.open(path, std::ios::binary);
file.write(data.data(), data.size());
}, "saving to " << path); }

}
8 changes: 4 additions & 4 deletions p2p/source/load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
namespace orc {

void Create(const std::string &path);
void Delete(const std::string &file);
void Delete(const std::string &path);

bool Exists(const std::string &path);
uint64_t Modified(const std::string &file);
uint64_t Modified(const std::string &path);

std::string Load(const std::string &file);
void Save(const std::string &file, const std::string &data);
std::string Load(const std::string &path);
void Save(const std::string &path, const std::string &data);

}

Expand Down
2 changes: 1 addition & 1 deletion p2p/source/local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class LocalOpening :
continue;
}

Subset subset(data, writ);
const Subset subset(data, writ);
if (Verbose)
Log() << "\e[33mRECV " << writ << " " << subset << "\e[0m" << std::endl;
drain_.Land(subset, endpoint);
Expand Down
4 changes: 2 additions & 2 deletions p2p/source/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Log::~Log() { try {
if (log.find('\e') != std::string::npos)
log += "\e[0m";

std::unique_lock<std::mutex> lock(mutex_);
const std::unique_lock<std::mutex> lock(mutex_);

#if 0
#elif defined(__APPLE__)
Expand All @@ -104,7 +104,7 @@ Log::~Log() { try {
} }

std::string Cause() {
std::unique_lock<std::mutex> lock(mutex_);
const std::unique_lock<std::mutex> lock(mutex_);
return cause_;
}

Expand Down
2 changes: 1 addition & 1 deletion p2p/source/nested.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ std::ostream &operator <<(std::ostream &out, const Nested &value) {
out << Subset(value.str());
} else {
out << '"';
for (uint8_t c : value.str())
for (const uint8_t c : value.str())
if (c >= 0x20 && c < 0x80)
out << c;
else {
Expand Down
Loading

0 comments on commit 4140b0b

Please sign in to comment.