From 55a95458471e2ae6139c2d1dd0f246a91d2f4b7a Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Fri, 7 Jan 2022 14:36:55 +0100 Subject: Removed unused lambda captures --- zenserver/admin/admin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'zenserver') diff --git a/zenserver/admin/admin.cpp b/zenserver/admin/admin.cpp index 01c35a1d8..676e9a830 100644 --- a/zenserver/admin/admin.cpp +++ b/zenserver/admin/admin.cpp @@ -16,7 +16,7 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler) : m_GcScheduler(Sched m_Router.RegisterRoute( "health", - [this](HttpRouterRequest& Req) { + [](HttpRouterRequest& Req) { CbObjectWriter Obj; Obj.AddBool("ok", true); Req.ServerRequest().WriteResponse(HttpResponseCode::OK, Obj.Save()); @@ -64,7 +64,7 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler) : m_GcScheduler(Sched m_Router.RegisterRoute( "", - [this](HttpRouterRequest& Req) { + [](HttpRouterRequest& Req) { CbObject Payload = Req.ServerRequest().ReadPayloadObject(); CbObjectWriter Obj; -- cgit v1.2.3 From 9086231f3923c0df6d9ef817441bfae5e134e8ff Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 12:07:03 +0100 Subject: Converted use of _format UDL to fmt::format --- zenserver/cache/cachetracking.cpp | 7 ++----- zenserver/cache/structuredcache.cpp | 4 ---- zenserver/cache/structuredcachestore.cpp | 18 ++++++++---------- zenserver/compute/apply.cpp | 18 +++++++----------- zenserver/config.cpp | 6 ++---- zenserver/projectstore.cpp | 19 +++++++------------ zenserver/testing/httptest.cpp | 6 ++---- zenserver/testing/launch.cpp | 4 +--- zenserver/upstream/jupiter.cpp | 1 - zenserver/upstream/upstreamapply.cpp | 17 ++++++----------- zenserver/upstream/upstreamcache.cpp | 18 ++++++------------ zenserver/zenserver.cpp | 15 ++++++--------- 12 files changed, 47 insertions(+), 86 deletions(-) (limited to 'zenserver') diff --git a/zenserver/cache/cachetracking.cpp b/zenserver/cache/cachetracking.cpp index ae132f37f..9119e3122 100644 --- a/zenserver/cache/cachetracking.cpp +++ b/zenserver/cache/cachetracking.cpp @@ -26,8 +26,6 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { -using namespace fmt::literals; - namespace rocksdb = ROCKSDB_NAMESPACE; static constinit auto Epoch = std::chrono::time_point{}; @@ -180,14 +178,14 @@ struct ZenCacheTracker::Impl } else { - throw std::runtime_error("column family iteration failed for '{}': '{}'"_format(RocksdbPath, Status.getState()).c_str()); + throw std::runtime_error(fmt::format("column family iteration failed for '{}': '{}'", RocksdbPath, Status.getState()).c_str()); } Status = rocksdb::DB::Open(Options, RocksdbPath, ColumnDescriptors, &m_RocksDbColumnHandles, &Db); if (!Status.ok()) { - throw std::runtime_error("database open failed for '{}': '{}'"_format(RocksdbPath, Status.getState()).c_str()); + throw std::runtime_error(fmt::format("database open failed for '{}': '{}'", RocksdbPath, Status.getState()).c_str()); } m_RocksDb.reset(Db); @@ -297,7 +295,6 @@ ZenCacheTracker::IterateSnapshots(std::function ChunkRequests; diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp index e74becb3a..4dd2f4264 100644 --- a/zenserver/cache/structuredcachestore.cpp +++ b/zenserver/cache/structuredcachestore.cpp @@ -38,7 +38,6 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { -using namespace fmt::literals; namespace fs = std::filesystem; static CbObject @@ -1066,14 +1065,14 @@ ZenCacheDiskLayer::CacheBucket::PutStandaloneCacheValue(const IoHash& HashKey, c if (Ec) { - throw std::system_error(Ec, "Failed to open temporary file for put at '{}'"_format(m_BucketDir)); + throw std::system_error(Ec, fmt::format("Failed to open temporary file for put at '{}'", m_BucketDir)); } DataFile.WriteAll(Value.Value, Ec); if (Ec) { - throw std::system_error(Ec, "Failed to write payload ({} bytes) to file"_format(NiceBytes(Value.Value.Size()))); + throw std::system_error(Ec, fmt::format("Failed to write payload ({} bytes) to file", NiceBytes(Value.Value.Size()))); } // Move file into place (atomically) @@ -1113,7 +1112,7 @@ ZenCacheDiskLayer::CacheBucket::PutStandaloneCacheValue(const IoHash& HashKey, c if (Ec) { - throw std::system_error(Ec, "Failed to finalize file '{}'"_format(DataFilePath.ToUtf8())); + throw std::system_error(Ec, fmt::format("Failed to finalize file '{}'", DataFilePath.ToUtf8())); } } @@ -1396,7 +1395,6 @@ ZenCacheDiskLayer::TotalSize() const #if ZEN_WITH_TESTS using namespace std::literals; -using namespace fmt::literals; namespace testutils { IoHash CreateKey(size_t KeyValue) { return IoHash::HashBuffer(&KeyValue, sizeof(size_t)); } @@ -1483,7 +1481,7 @@ TEST_CASE("z$.size") for (size_t Key = 0; Key < Count; ++Key) { const size_t Bucket = Key % 4; - Zcs.Put("test_bucket-{}"_format(Bucket), IoHash::HashBuffer(&Key, sizeof(uint32_t)), {.Value = Buffer}); + Zcs.Put(fmt::format("test_bucket-{}", Bucket), IoHash::HashBuffer(&Key, sizeof(uint32_t)), {.Value = Buffer}); } CacheSize = Zcs.StorageSize(); @@ -1501,7 +1499,7 @@ TEST_CASE("z$.size") for (size_t Bucket = 0; Bucket < 4; ++Bucket) { - Zcs.DropBucket("test_bucket-{}"_format(Bucket)); + Zcs.DropBucket(fmt::format("test_bucket-{}", Bucket)); } CHECK_EQ(0, Zcs.StorageSize().DiskSize); } @@ -1526,7 +1524,7 @@ TEST_CASE("z$.size") for (size_t Key = 0; Key < Count; ++Key) { const size_t Bucket = Key % 4; - Zcs.Put("test_bucket-{}"_format(Bucket), IoHash::HashBuffer(&Key, sizeof(uint32_t)), {.Value = Buffer}); + Zcs.Put(fmt::format("test_bucket-{}", Bucket), IoHash::HashBuffer(&Key, sizeof(uint32_t)), {.Value = Buffer}); } CacheSize = Zcs.StorageSize(); @@ -1544,7 +1542,7 @@ TEST_CASE("z$.size") for (size_t Bucket = 0; Bucket < 4; ++Bucket) { - Zcs.DropBucket("test_bucket-{}"_format(Bucket)); + Zcs.DropBucket(fmt::format("test_bucket-{}", Bucket)); } CHECK_EQ(0, Zcs.StorageSize().DiskSize); } @@ -1585,7 +1583,7 @@ TEST_CASE("z$.gc") for (size_t Idx = 0; auto& Cid : Cids) { - Record.AddBinaryAttachment("attachment-{}"_format(Idx++), Cid); + Record.AddBinaryAttachment(fmt::format("attachment-{}", Idx++), Cid); } IoBuffer Buffer = Record.Save().GetBuffer().AsIoBuffer(); diff --git a/zenserver/compute/apply.cpp b/zenserver/compute/apply.cpp index d483fd4f7..95902a752 100644 --- a/zenserver/compute/apply.cpp +++ b/zenserver/compute/apply.cpp @@ -61,8 +61,6 @@ BasicFunctionJob::~BasicFunctionJob() bool BasicFunctionJob::SpawnJob(std::filesystem::path ExePath, std::wstring CommandLine) { - using namespace fmt::literals; - STARTUPINFOEX StartupInfo = {sizeof(STARTUPINFOEX)}; PROCESS_INFORMATION ProcessInfo{}; @@ -82,7 +80,7 @@ BasicFunctionJob::SpawnJob(std::filesystem::path ExePath, std::wstring CommandLi if (!Created) { - throw std::system_error(::GetLastError(), std::system_category(), "Failed to create process '{}'"_format(ExePath).c_str()); + throw std::system_error(::GetLastError(), std::system_category(), fmt::format("Failed to create process '{}'", ExePath).c_str()); } m_ProcessId = ProcessInfo.dwProcessId; @@ -714,7 +712,6 @@ CbPackage HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action) { using namespace std::literals; - using namespace fmt::literals; std::filesystem::path SandboxPath = CreateNewSandbox(); @@ -735,12 +732,12 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action) if (!DataBuffer) { - throw std::runtime_error("worker CAS chunk '{}' missing"_format(ChunkHash)); + throw std::runtime_error(fmt::format("worker CAS chunk '{}' missing", ChunkHash)); } if (DataBuffer.Size() != Size) { - throw std::runtime_error("worker CAS chunk '{}' size: {}, action spec expected {}"_format(ChunkHash, DataBuffer.Size(), Size)); + throw std::runtime_error(fmt::format("worker CAS chunk '{}' size: {}, action spec expected {}", ChunkHash, DataBuffer.Size(), Size)); } zen::WriteFile(FilePath, DataBuffer); @@ -766,12 +763,12 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action) if (!DataBuffer) { - throw std::runtime_error("worker CAS chunk '{}' missing"_format(ChunkHash)); + throw std::runtime_error(fmt::format("worker CAS chunk '{}' missing", ChunkHash)); } if (DataBuffer.Size() != Size) { - throw std::runtime_error("worker CAS chunk '{}' size: {}, action spec expected {}"_format(ChunkHash, DataBuffer.Size(), Size)); + throw std::runtime_error(fmt::format("worker CAS chunk '{}' size: {}, action spec expected {}", ChunkHash, DataBuffer.Size(), Size)); } zen::WriteFile(FilePath, DataBuffer); @@ -790,7 +787,7 @@ HttpFunctionService::ExecAction(const WorkerDesc& Worker, CbObject Action) if (!DataBuffer) { - throw std::runtime_error("input CID chunk '{}' missing"_format(Cid)); + throw std::runtime_error(fmt::format("input CID chunk '{}' missing", Cid)); } zen::WriteFile(FilePath, DataBuffer); @@ -942,11 +939,10 @@ HttpFunctionService::ExecActionUpstream(const WorkerDesc& Worker, CbObject Actio HttpResponseCode HttpFunctionService::ExecActionUpstreamResult(const IoHash& WorkerId, const IoHash& ActionId, CbPackage& Package) { - using namespace fmt::literals; auto Status = m_UpstreamApply->GetStatus(WorkerId, ActionId); if (!Status.Success) { - // throw std::runtime_error("Action {}/{} not found"_format(WorkerId.ToHexString(), ActionId.ToHexString()).c_str()); + // throw std::runtime_error(fmt::format("Action {}/{} not found", WorkerId.ToHexString(), ActionId.ToHexString()).c_str()); return HttpResponseCode::NotFound; } diff --git a/zenserver/config.cpp b/zenserver/config.cpp index 722bc3b97..9fd4bfa69 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -394,8 +394,6 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) void ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptions) { - using namespace fmt::literals; - zen::IoBuffer LuaScript = zen::IoBufferBuilder::MakeFromFile(Path); if (LuaScript) @@ -433,14 +431,14 @@ ParseConfigFile(const std::filesystem::path& Path, ZenServerOptions& ServerOptio std::string ErrorString = sol::to_string(config.status()); - throw std::runtime_error("{} error: {}"_format(ErrorString, err.what())); + throw std::runtime_error(fmt::format("{} error: {}", ErrorString, err.what())); } config(); } catch (std::exception& e) { - throw std::runtime_error("failed to load config script ('{}'): {}"_format(Path, e.what()).c_str()); + throw std::runtime_error(fmt::format("failed to load config script ('{}'): {}", Path, e.what()).c_str()); } if (sol::optional ServerConfig = lua["server"]) diff --git a/zenserver/projectstore.cpp b/zenserver/projectstore.cpp index 4f9897e07..8221199f1 100644 --- a/zenserver/projectstore.cpp +++ b/zenserver/projectstore.cpp @@ -42,8 +42,6 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { -using namespace fmt::literals; - #if USE_ROCKSDB namespace rocksdb = ROCKSDB_NAMESPACE; #endif @@ -154,14 +152,14 @@ struct ProjectStore::OplogStorage : public RefCounted } else { - throw std::runtime_error("column family iteration failed for '{}': '{}'"_format(RocksdbPath, Status.getState()).c_str()); + throw std::runtime_error(fmt::format("column family iteration failed for '{}': '{}'", RocksdbPath, Status.getState()).c_str()); } Status = rocksdb::DB::Open(Options, RocksdbPath, ColumnDescriptors, &m_RocksDbColumnHandles, &Db); if (!Status.ok()) { - throw std::runtime_error("database open failed for '{}': '{}'"_format(RocksdbPath, Status.getState()).c_str()); + throw std::runtime_error(fmt::format("database open failed for '{}': '{}'", RocksdbPath, Status.getState()).c_str()); } m_RocksDb.reset(Db); @@ -1560,7 +1558,7 @@ HttpProjectService::HttpProjectService(CidStore& Store, ProjectStore* Projects) if (!legacy::TryLoadCbPackage(Package, Payload, &UniqueBuffer::Alloc, &Resolver)) { std::filesystem::path BadPackagePath = - Oplog.TempPath() / "bad_packages" / "session{}_request{}"_format(HttpReq.SessionId(), HttpReq.RequestId()); + Oplog.TempPath() / "bad_packages" / fmt::format("session{}_request{}", HttpReq.SessionId(), HttpReq.RequestId()); ZEN_ERROR("Received malformed package! Saving payload to '{}'", BadPackagePath); @@ -1609,8 +1607,6 @@ HttpProjectService::HttpProjectService(CidStore& Store, ProjectStore* Projects) }, HttpVerb::kGet); - using namespace fmt::literals; - m_Router.RegisterRoute( "{project}/oplog/{log}", [this](HttpRouterRequest& Req) { @@ -1623,7 +1619,7 @@ HttpProjectService::HttpProjectService(CidStore& Store, ProjectStore* Projects) { return Req.ServerRequest().WriteResponse(HttpResponseCode::NotFound, HttpContentType::kText, - "project {} not found"_format(ProjectId)); + fmt::format("project {} not found", ProjectId)); } ProjectStore::Project& Prj = *ProjectIt; @@ -1638,7 +1634,7 @@ HttpProjectService::HttpProjectService(CidStore& Store, ProjectStore* Projects) { return Req.ServerRequest().WriteResponse(HttpResponseCode::NotFound, HttpContentType::kText, - "oplog {} not found in project {}"_format(OplogId, ProjectId)); + fmt::format("oplog {} not found in project {}", OplogId, ProjectId)); } ProjectStore::Oplog& Log = *OplogIt; @@ -1777,7 +1773,7 @@ HttpProjectService::HttpProjectService(CidStore& Store, ProjectStore* Projects) { return Req.ServerRequest().WriteResponse(HttpResponseCode::NotFound, HttpContentType::kText, - "project {} not found"_format(ProjectId)); + fmt::format("project {} not found", ProjectId)); } const ProjectStore::Project& Prj = *ProjectIt; @@ -1801,7 +1797,7 @@ HttpProjectService::HttpProjectService(CidStore& Store, ProjectStore* Projects) { return Req.ServerRequest().WriteResponse(HttpResponseCode::NotFound, HttpContentType::kText, - "project {} not found"_format(ProjectId)); + fmt::format("project {} not found", ProjectId)); } m_ProjectStore->DeleteProject(ProjectId); @@ -2142,7 +2138,6 @@ LocalProjectService::~LocalProjectService() TEST_CASE("prj.store") { - using namespace fmt::literals; using namespace std::literals; ScopedTemporaryDirectory TempDir; diff --git a/zenserver/testing/httptest.cpp b/zenserver/testing/httptest.cpp index 924546762..eedf06661 100644 --- a/zenserver/testing/httptest.cpp +++ b/zenserver/testing/httptest.cpp @@ -8,8 +8,6 @@ namespace zen { -using namespace fmt::literals; - HttpTestingService::HttpTestingService() { m_Router.RegisterRoute( @@ -25,7 +23,7 @@ HttpTestingService::HttpTestingService() Sleep(1000); Request.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, - "hello, took me {}"_format(NiceTimeSpanMs(Timer.GetElapsedTimeMs()))); + fmt::format("hello, took me {}", NiceTimeSpanMs(Timer.GetElapsedTimeMs()))); }); }, HttpVerb::kGet); @@ -38,7 +36,7 @@ HttpTestingService::HttpTestingService() Sleep(60000); Request.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, - "hello, took me {}"_format(NiceTimeSpanMs(Timer.GetElapsedTimeMs()))); + fmt::format("hello, took me {}", NiceTimeSpanMs(Timer.GetElapsedTimeMs()))); }); }, HttpVerb::kGet); diff --git a/zenserver/testing/launch.cpp b/zenserver/testing/launch.cpp index 706594b10..f315ec1b4 100644 --- a/zenserver/testing/launch.cpp +++ b/zenserver/testing/launch.cpp @@ -55,8 +55,6 @@ BasicJob::~BasicJob() bool BasicJob::SpawnJob(std::filesystem::path ExePath, std::wstring CommandLine) { - using namespace fmt::literals; - STARTUPINFOEX StartupInfo = {sizeof(STARTUPINFOEX)}; PROCESS_INFORMATION ProcessInfo{}; @@ -76,7 +74,7 @@ BasicJob::SpawnJob(std::filesystem::path ExePath, std::wstring CommandLine) if (!Created) { - throw std::system_error(::GetLastError(), std::system_category(), "Failed to create process '{}'"_format(ExePath).c_str()); + throw std::system_error(::GetLastError(), std::system_category(), fmt::format("Failed to create process '{}'", ExePath).c_str()); } m_ProcessId = ProcessInfo.dwProcessId; diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp index ffb9b1cbf..c952d8e10 100644 --- a/zenserver/upstream/jupiter.cpp +++ b/zenserver/upstream/jupiter.cpp @@ -25,7 +25,6 @@ ZEN_THIRD_PARTY_INCLUDES_END #include using namespace std::literals; -using namespace fmt::literals; namespace zen { diff --git a/zenserver/upstream/upstreamapply.cpp b/zenserver/upstream/upstreamapply.cpp index f8a8c3e62..fe7f7d9c8 100644 --- a/zenserver/upstream/upstreamapply.cpp +++ b/zenserver/upstream/upstreamapply.cpp @@ -53,10 +53,9 @@ namespace detail { , m_CasStore(CasStore) , m_CidStore(CidStore) { - using namespace fmt::literals; - m_DisplayName = "Horde - '{}'"_format(Options.ServiceUrl); + m_DisplayName = fmt::format("Horde - '{}'", Options.ServiceUrl); m_Client = new CloudCacheClient(Options); - m_ChannelId = "zen-{}"_format(zen::GetSessionIdString()); + m_ChannelId = fmt::format("zen-{}", zen::GetSessionIdString()); } virtual ~HordeUpstreamApplyEndpoint() = default; @@ -442,14 +441,13 @@ namespace detail { if (Outcome != ComputeTaskOutcome::Success) { - using namespace fmt::literals; const std::string_view Detail = TaskStatus["d"sv].AsString(); if (!Detail.empty()) { return {.Error{.ErrorCode = -1, - .Reason = "Task {}: {}"_format(ComputeTaskOutcomeToString(Outcome), std::string(Detail))}}; + .Reason = fmt::format("Task {}: {}", ComputeTaskOutcomeToString(Outcome), std::string(Detail))}}; } - return {.Error{.ErrorCode = -1, .Reason = "Task {}"_format(ComputeTaskOutcomeToString(Outcome))}}; + return {.Error{.ErrorCode = -1, .Reason = fmt::format("Task {}", ComputeTaskOutcomeToString(Outcome))}}; } const IoHash TaskId = TaskStatus["h"sv].AsObjectAttachment(); @@ -713,8 +711,6 @@ namespace detail { [[nodiscard]] bool ProcessApplyKey(const UpstreamApplyRecord& ApplyRecord, UpstreamData& Data) { - using namespace fmt::literals; - std::string ExecutablePath; std::map Environment; std::set InputFiles; @@ -749,7 +745,7 @@ namespace detail { for (auto& It : ApplyRecord.WorkerDescriptor["dirs"sv]) { std::string_view Directory = It.AsString(); - std::string DummyFile = "{}/.zen_empty_file"_format(Directory); + std::string DummyFile = fmt::format("{}/.zen_empty_file", Directory); InputFiles.insert(DummyFile); Data.Blobs[EmptyBufferId] = EmptyBuffer; InputFileHashes[DummyFile] = EmptyBufferId; @@ -816,7 +812,6 @@ namespace detail { Data.Objects[SandboxHash] = std::move(Sandbox); { - using namespace fmt::literals; std::string_view HostPlatform = ApplyRecord.WorkerDescriptor["host"sv].AsString(); if (HostPlatform.empty()) { @@ -829,7 +824,7 @@ namespace detail { bool Exclusive = ApplyRecord.WorkerDescriptor["exclusive"sv].AsBool(); // TODO: Remove override when Horde accepts the UE style Host Platforms (Win64, Linux, Mac) - std::string Condition = "Platform == '{}'"_format(HostPlatform); + std::string Condition = fmt::format("Platform == '{}'", HostPlatform); if (HostPlatform == "Win64") { Condition += " && Pool == 'Win-RemoteExec'"; diff --git a/zenserver/upstream/upstreamcache.cpp b/zenserver/upstream/upstreamcache.cpp index 38179f490..eb9d4fa95 100644 --- a/zenserver/upstream/upstreamcache.cpp +++ b/zenserver/upstream/upstreamcache.cpp @@ -270,8 +270,6 @@ namespace detail { { ZEN_TRACE_CPU("Upstream::Horde::PutCacheRecord"); - using namespace fmt::literals; - ZEN_ASSERT(CacheRecord.PayloadIds.size() == Payloads.size()); const int32_t MaxAttempts = 3; @@ -313,7 +311,7 @@ namespace detail { if (It == std::end(CacheRecord.PayloadIds)) { - OutReason = "payload '{}' MISSING from local cache"_format(PayloadId); + OutReason = fmt::format("payload '{}' MISSING from local cache", PayloadId); return false; } @@ -329,7 +327,7 @@ namespace detail { if (!BlobResult.Success) { - OutReason = "upload payload '{}' FAILED, reason '{}'"_format(PayloadId, BlobResult.Reason); + OutReason = fmt::format("upload payload '{}' FAILED, reason '{}'", PayloadId, BlobResult.Reason); return false; } @@ -350,7 +348,7 @@ namespace detail { if (!RefResult.Success) { - return {.Reason = "upload cache record '{}/{}' FAILED, reason '{}'"_format(CacheRecord.Key.Bucket, + return {.Reason = fmt::format("upload cache record '{}/{}' FAILED, reason '{}'", CacheRecord.Key.Bucket, CacheRecord.Key.Hash, RefResult.Reason), .Success = false}; @@ -371,7 +369,7 @@ namespace detail { if (!FinalizeResult.Success) { - return {.Reason = "finalize cache record '{}/{}' FAILED, reason '{}'"_format(CacheRecord.Key.Bucket, + return {.Reason = fmt::format("finalize cache record '{}/{}' FAILED, reason '{}'", CacheRecord.Key.Bucket, CacheRecord.Key.Hash, FinalizeResult.Reason), .Success = false}; @@ -389,7 +387,7 @@ namespace detail { if (!FinalizeResult.Success) { - return {.Reason = "finalize '{}/{}' FAILED, reason '{}'"_format(CacheRecord.Key.Bucket, + return {.Reason = fmt::format("finalize '{}/{}' FAILED, reason '{}'", CacheRecord.Key.Bucket, CacheRecord.Key.Hash, FinalizeResult.Reason), .Success = false}; @@ -403,7 +401,7 @@ namespace detail { Sb << MissingHash.ToHexString() << ","; } - return {.Reason = "finalize '{}/{}' FAILED, still needs payload(s) '{}'"_format(CacheRecord.Key.Bucket, + return {.Reason = fmt::format("finalize '{}/{}' FAILED, still needs payload(s) '{}'", CacheRecord.Key.Bucket, CacheRecord.Key.Hash, Sb.ToString()), .Success = false}; @@ -480,8 +478,6 @@ namespace detail { virtual UpstreamEndpointHealth Initialize() override { - using namespace fmt::literals; - const ZenEndpoint& Ep = GetEndpoint(); if (Ep.Ok) { @@ -500,8 +496,6 @@ namespace detail { virtual UpstreamEndpointHealth CheckHealth() override { - using namespace fmt::literals; - try { if (m_Client.IsNull()) diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index 6e5d2fe93..40d40e908 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -114,7 +114,6 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { using namespace std::literals; -using namespace fmt::literals; namespace utils { asio::error_code ResolveHostname(asio::io_context& Ctx, @@ -139,7 +138,7 @@ namespace utils { { for (const asio::ip::tcp::endpoint Ep : Endpoints) { - OutEndpoints.push_back("http://{}:{}"_format(Ep.address().to_string(), Ep.port())); + OutEndpoints.push_back(fmt::format("http://{}:{}", Ep.address().to_string(), Ep.port())); } } @@ -152,8 +151,6 @@ class ZenServer : public IHttpStatusProvider public: void Initialize(const ZenServerOptions& ServerOptions, ZenServerState::ZenServerEntry* ServerEntry) { - using namespace fmt::literals; - m_ServerEntry = ServerEntry; m_DebugOptionForcedCrash = ServerOptions.ShouldCrash; const int ParentPid = ServerOptions.OwnerPid; @@ -180,11 +177,11 @@ public: // Initialize/check mutex based on base port - std::string MutexName = "zen_{}"_format(ServerOptions.BasePort); + std::string MutexName = fmt::format("zen_{}", ServerOptions.BasePort); if (zen::NamedMutex::Exists(MutexName) || ((m_ServerMutex.Create(MutexName) == false))) { - throw std::runtime_error("Failed to create mutex '{}' - is another instance already running?"_format(MutexName).c_str()); + throw std::runtime_error(fmt::format("Failed to create mutex '{}' - is another instance already running?", MutexName).c_str()); } InitializeState(ServerOptions); @@ -585,7 +582,7 @@ ZenServer::InitializeState(const ZenServerOptions& ServerOptions) else { WipeState = true; - WipeReason = "No manifest present at '{}'"_format(ManifestPath); + WipeReason = fmt::format("No manifest present at '{}'", ManifestPath); } } else @@ -598,7 +595,7 @@ ZenServer::InitializeState(const ZenServerOptions& ServerOptions) ZEN_ERROR("Manifest validation failed: {}, state will be wiped", ValidationResult); WipeState = true; - WipeReason = "Validation of manifest at '{}' failed: {}"_format(ManifestPath, ValidationResult); + WipeReason = fmt::format("Validation of manifest at '{}' failed: {}", ManifestPath, ValidationResult); } else { @@ -609,7 +606,7 @@ ZenServer::InitializeState(const ZenServerOptions& ServerOptions) if (ManifestVersion != ZEN_CFG_SCHEMA_VERSION) { WipeState = true; - WipeReason = "Manifest schema version: {}, differs from required: {}"_format(ManifestVersion, ZEN_CFG_SCHEMA_VERSION); + WipeReason = fmt::format("Manifest schema version: {}, differs from required: {}", ManifestVersion, ZEN_CFG_SCHEMA_VERSION); } } } -- cgit v1.2.3 From bc57f3cd904721d7a179da0ce73ab6b7d3d6a670 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 12:20:12 +0100 Subject: Deleted two unused include statements --- zenserver/cache/structuredcachestore.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'zenserver') diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp index 4dd2f4264..68b7e2a48 100644 --- a/zenserver/cache/structuredcachestore.cpp +++ b/zenserver/cache/structuredcachestore.cpp @@ -26,8 +26,6 @@ #endif #include -#include -#include ZEN_THIRD_PARTY_INCLUDES_START #include -- cgit v1.2.3 From 0d80759883b95f25ab4b6714203ff6178c7f1b5a Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 12:20:27 +0100 Subject: Unused lambda capture compile fixes --- zenserver/diag/diagsvcs.cpp | 2 +- zenserver/testing/httptest.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'zenserver') diff --git a/zenserver/diag/diagsvcs.cpp b/zenserver/diag/diagsvcs.cpp index eed23dff2..ef2baa1b4 100644 --- a/zenserver/diag/diagsvcs.cpp +++ b/zenserver/diag/diagsvcs.cpp @@ -44,7 +44,7 @@ HttpHealthService::HttpHealthService() { m_Router.RegisterRoute( "", - [this](HttpRouterRequest& RoutedReq) { + [](HttpRouterRequest& RoutedReq) { HttpServerRequest& HttpReq = RoutedReq.ServerRequest(); HttpReq.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, u8"OK!"sv); }, diff --git a/zenserver/testing/httptest.cpp b/zenserver/testing/httptest.cpp index eedf06661..230d5d6c5 100644 --- a/zenserver/testing/httptest.cpp +++ b/zenserver/testing/httptest.cpp @@ -12,13 +12,13 @@ HttpTestingService::HttpTestingService() { m_Router.RegisterRoute( "hello", - [this](HttpRouterRequest& Req) { Req.ServerRequest().WriteResponse(HttpResponseCode::OK); }, + [](HttpRouterRequest& Req) { Req.ServerRequest().WriteResponse(HttpResponseCode::OK); }, HttpVerb::kGet); m_Router.RegisterRoute( "hello_slow", - [this](HttpRouterRequest& Req) { - Req.ServerRequest().WriteResponseAsync([this](HttpServerRequest& Request) { + [](HttpRouterRequest& Req) { + Req.ServerRequest().WriteResponseAsync([](HttpServerRequest& Request) { Stopwatch Timer; Sleep(1000); Request.WriteResponse(HttpResponseCode::OK, @@ -30,8 +30,8 @@ HttpTestingService::HttpTestingService() m_Router.RegisterRoute( "hello_veryslow", - [this](HttpRouterRequest& Req) { - Req.ServerRequest().WriteResponseAsync([this](HttpServerRequest& Request) { + [](HttpRouterRequest& Req) { + Req.ServerRequest().WriteResponseAsync([](HttpServerRequest& Request) { Stopwatch Timer; Sleep(60000); Request.WriteResponse(HttpResponseCode::OK, @@ -43,14 +43,14 @@ HttpTestingService::HttpTestingService() m_Router.RegisterRoute( "hello_throw", - [this](HttpRouterRequest& Req) { - Req.ServerRequest().WriteResponseAsync([this](HttpServerRequest&) { throw std::runtime_error("intentional error"); }); + [](HttpRouterRequest& Req) { + Req.ServerRequest().WriteResponseAsync([](HttpServerRequest&) { throw std::runtime_error("intentional error"); }); }, HttpVerb::kGet); m_Router.RegisterRoute( "hello_noresponse", - [this](HttpRouterRequest& Req) { Req.ServerRequest().WriteResponseAsync([this](HttpServerRequest&) {}); }, + [](HttpRouterRequest& Req) { Req.ServerRequest().WriteResponseAsync([](HttpServerRequest&) {}); }, HttpVerb::kGet); m_Router.RegisterRoute( @@ -82,7 +82,7 @@ HttpTestingService::HttpTestingService() m_Router.RegisterRoute( "echo", - [this](HttpRouterRequest& Req) { + [](HttpRouterRequest& Req) { IoBuffer Body = Req.ServerRequest().ReadPayload(); Req.ServerRequest().WriteResponse(HttpResponseCode::OK, HttpContentType::kBinary, Body); }, @@ -90,7 +90,7 @@ HttpTestingService::HttpTestingService() m_Router.RegisterRoute( "package", - [this](HttpRouterRequest& Req) { + [](HttpRouterRequest& Req) { CbPackage Pkg = Req.ServerRequest().ReadPayloadPackage(); Req.ServerRequest().WriteResponse(HttpResponseCode::OK, Pkg); }, -- cgit v1.2.3 From 3b90970ef117efc2e165a9d0f3b519f261face1a Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 12:29:54 +0100 Subject: Compiler support for C++20's using-enum is wildly incomplete --- zenserver/cache/structuredcache.cpp | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) (limited to 'zenserver') diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index 3bcc3be87..6ce9ada22 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -155,16 +155,14 @@ HttpStructuredCacheService::HandleCacheBucketRequest(HttpServerRequest& Request, ZEN_UNUSED(Request, Bucket); switch (Request.RequestVerb()) { - using enum HttpVerb; - - case kHead: - case kGet: + case HttpVerb::kHead: + case HttpVerb::kGet: { // Query stats } break; - case kDelete: + case HttpVerb::kDelete: // Drop bucket if (m_CacheStore.DropBucket(Bucket)) @@ -187,16 +185,14 @@ HttpStructuredCacheService::HandleCacheRecordRequest(HttpServerRequest& Request, { switch (Request.RequestVerb()) { - using enum HttpVerb; - - case kHead: - case kGet: + case HttpVerb::kHead: + case HttpVerb::kGet: { HandleGetCacheRecord(Request, Ref, Policy); } break; - case kPut: + case HttpVerb::kPut: HandlePutCacheRecord(Request, Ref, Policy); break; default: @@ -588,15 +584,13 @@ HttpStructuredCacheService::HandleCachePayloadRequest(HttpServerRequest& Request { switch (Request.RequestVerb()) { - using enum HttpVerb; - - case kHead: - case kGet: + case HttpVerb::kHead: + case HttpVerb::kGet: { HandleGetCachePayload(Request, Ref, Policy); } break; - case kPut: + case HttpVerb::kPut: HandlePutCachePayload(Request, Ref, Policy); break; default: @@ -772,9 +766,7 @@ HttpStructuredCacheService::HandleRpcRequest(zen::HttpServerRequest& Request) { switch (Request.RequestVerb()) { - using enum HttpVerb; - - case kPost: + case HttpVerb::kPost: { const HttpContentType ContentType = Request.RequestContentType(); const HttpContentType AcceptType = Request.AcceptContentType(); -- cgit v1.2.3 From 09fe7a461d2cff5000f3d3c07b5cc5cdacdec141 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 12:30:32 +0100 Subject: Removed ZEN_UNUSED() statement that is unnecessary --- zenserver/cache/structuredcache.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'zenserver') diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index 6ce9ada22..139081530 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -152,7 +152,6 @@ HttpStructuredCacheService::HandleRequest(HttpServerRequest& Request) void HttpStructuredCacheService::HandleCacheBucketRequest(HttpServerRequest& Request, std::string_view Bucket) { - ZEN_UNUSED(Request, Bucket); switch (Request.RequestVerb()) { case HttpVerb::kHead: -- cgit v1.2.3 From fa08a67cde4b63176929ade6203946fdc15ae152 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 12:30:54 +0100 Subject: Fixed unused-lambda-capture compile errors --- zenserver/cache/structuredcache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'zenserver') diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index 139081530..29bec8788 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -223,7 +223,7 @@ HttpStructuredCacheService::HandleGetCacheRecord(zen::HttpServerRequest& Request if (!SkipAttachments) { - CacheRecord.IterateAttachments([this, &Ref, &Package, &AttachmentCount, &ValidCount](CbFieldView AttachmentHash) { + CacheRecord.IterateAttachments([this, &Package, &AttachmentCount, &ValidCount](CbFieldView AttachmentHash) { if (IoBuffer Chunk = m_CidStore.FindChunkByCid(AttachmentHash.AsHash())) { Package.AddAttachment(CbAttachment(CompressedBuffer::FromCompressed(SharedBuffer(Chunk)))); @@ -891,7 +891,7 @@ HttpStructuredCacheService::HandleRpcGetCacheRecords(zen::HttpServerRequest& Req if (!UpstreamRequests.empty() && m_UpstreamCache) { const auto OnCacheRecordGetComplete = - [this, &CacheKeys, &CacheValues, &RpcResponse, PartialOnError, SkipAttachments](CacheRecordGetCompleteParams&& Params) { + [this, &CacheValues, &RpcResponse, PartialOnError, SkipAttachments](CacheRecordGetCompleteParams&& Params) { ZEN_ASSERT(Params.KeyIndex < CacheValues.size()); IoBuffer CacheValue; @@ -1136,7 +1136,7 @@ HttpStructuredCacheService::HandleRpcGetCachePayloads(zen::HttpServerRequest& Re if (!UpstreamRequests.empty() && m_UpstreamCache) { - const auto OnCachePayloadGetComplete = [this, &ChunkRequests, &Chunks](CachePayloadGetCompleteParams&& Params) { + const auto OnCachePayloadGetComplete = [this, &Chunks](CachePayloadGetCompleteParams&& Params) { if (CompressedBuffer Compressed = CompressedBuffer::FromCompressed(SharedBuffer(Params.Payload))) { m_CidStore.AddChunk(Compressed); -- cgit v1.2.3 From 0c9085ba269315788771d77726dee5815a1945d8 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 13:20:12 +0100 Subject: LLVM-12 C++ lib's emplace_back() doesn't like classes all that much --- zenserver/cache/structuredcache.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'zenserver') diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index 29bec8788..ef312d800 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -1018,7 +1018,10 @@ HttpStructuredCacheService::HandleRpcGetCachePayloads(zen::HttpServerRequest& Re const uint64_t RawSize = RequestObject["RawSize"sv].AsUInt64(); const uint32_t ChunkPolicy = RequestObject["Policy"sv].AsUInt32(); - ChunkRequests.emplace_back(Key, ChunkId, PayloadId, RawOffset, RawSize, static_cast(ChunkPolicy)); + // Note we could use emplace_back here but [Apple] LLVM-12's C++ library + // can't infer a constructor like other platforms (or can't handle an + // initializer list like others do). + ChunkRequests.push_back({Key, ChunkId, PayloadId, RawOffset, RawSize, static_cast(ChunkPolicy)}); } if (ChunkRequests.empty()) -- cgit v1.2.3 From de7410c27c36d84b34860bb0d6015f7ee23c780d Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 13:21:30 +0100 Subject: Unused lambda capture compile error --- zenserver/projectstore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zenserver') diff --git a/zenserver/projectstore.cpp b/zenserver/projectstore.cpp index 8221199f1..42d785126 100644 --- a/zenserver/projectstore.cpp +++ b/zenserver/projectstore.cpp @@ -1598,7 +1598,7 @@ HttpProjectService::HttpProjectService(CidStore& Store, ProjectStore* Projects) m_Router.RegisterRoute( "{project}/oplog/{log}/{op}", - [this](HttpRouterRequest& Req) { + [](HttpRouterRequest& Req) { HttpServerRequest& HttpReq = Req.ServerRequest(); // TODO: look up op and respond with the payload! -- cgit v1.2.3 From e98906fab0f189d8268e270560d7d3d56dc0ea4d Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 10 Jan 2022 13:21:43 +0100 Subject: Two missing override keywords --- zenserver/upstream/upstreamcache.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'zenserver') diff --git a/zenserver/upstream/upstreamcache.cpp b/zenserver/upstream/upstreamcache.cpp index eb9d4fa95..c9ba59780 100644 --- a/zenserver/upstream/upstreamcache.cpp +++ b/zenserver/upstream/upstreamcache.cpp @@ -48,7 +48,7 @@ namespace detail { virtual ~JupiterUpstreamEndpoint() = default; - virtual const UpstreamEndpointInfo& GetEndpointInfo() const { return m_Info; } + virtual const UpstreamEndpointInfo& GetEndpointInfo() const override { return m_Info; } virtual UpstreamEndpointHealth Initialize() override { return CheckHealth(); } @@ -474,7 +474,7 @@ namespace detail { ~ZenUpstreamEndpoint() = default; - virtual const UpstreamEndpointInfo& GetEndpointInfo() const { return m_Info; } + virtual const UpstreamEndpointInfo& GetEndpointInfo() const override { return m_Info; } virtual UpstreamEndpointHealth Initialize() override { -- cgit v1.2.3