diff options
| author | Stefan Boberg <[email protected]> | 2025-11-01 14:04:35 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2025-11-01 14:04:35 +0100 |
| commit | a58da97f98697580bf128ed5723ba720cc30f0dc (patch) | |
| tree | 798e392ddf76128a506293dc0803aaf852203dcd /src | |
| parent | fix use-after-free in TEST_CASE("compactcas.threadedinsert") (#620) (diff) | |
| download | zen-a58da97f98697580bf128ed5723ba720cc30f0dc.tar.xz zen-a58da97f98697580bf128ed5723ba720cc30f0dc.zip | |
Various fixes to address issues flagged by gcc / non-UE toolchain build (#621)
* gcc: avoid using memset on nontrivial struct
* redundant `return std::move`
* fixed various compilation issues flagged by gcc
* fix issue in xmake.lua detecting whether we are building with the UE toolchain or not
* add GCC ignore -Wundef (comment is inaccurate)
* remove redundant std::move
* don't catch exceptions by value
* unreferenced variables
* initialize "by the book" instead of memset
* remove unused exception reference
* add #include <cstring> to fix gcc build
* explicitly poulate KeyValueMap by traversing input spans fixes gcc compilation
* remove unreferenced variable
* eliminate redundant `std::move` which gcc complains about
* fix gcc compilation by including <cstring>
* tag unreferenced variable to fix gcc compilation
* fixes for various cases of naming members the same as their type
Diffstat (limited to 'src')
41 files changed, 201 insertions, 166 deletions
diff --git a/src/zen/cmds/builds_cmd.cpp b/src/zen/cmds/builds_cmd.cpp index 3ba8cdfcc..93feab2a6 100644 --- a/src/zen/cmds/builds_cmd.cpp +++ b/src/zen/cmds/builds_cmd.cpp @@ -96,6 +96,17 @@ namespace { std::atomic<uint8_t> Abort; std::atomic<uint8_t> Pause; uint8_t Padding2[2]; + + void Initialize() + { + Magic = kMagicV1; + Pid.store(0); + memset(SessionId, 0, sizeof(SessionId)); + Padding1[0] = Padding1[1] = Padding1[2] = Padding1[3] = 0; + Abort.store(0); + Pause.store(0); + Padding2[0] = Padding2[1] = 0; + } }; struct MemMap @@ -182,12 +193,8 @@ namespace { } ZenStateSharedData* data = (ZenStateSharedData*)MemMap->GetData(); - memset(data, 0, sizeof(ZenStateSharedData)); - data->Magic = ZenStateSharedData::kMagicV1; + data->Initialize(); data->Pid.store(gsl::narrow<uint32_t>(Pid)); - data->SessionId; - data->Abort.store(false); - data->Pause.store(false); const Oid SessionId = GetSessionId(); memcpy(data->SessionId, &SessionId, sizeof SessionId); @@ -557,7 +564,7 @@ namespace { return Count * 1000000 / ElapsedWallTimeUS; } - void ValidateBuildPart(BuildStorage& Storage, const Oid& BuildId, Oid BuildPartId, const std::string_view BuildPartName) + void ValidateBuildPart(BuildStorageBase& Storage, const Oid& BuildId, Oid BuildPartId, const std::string_view BuildPartName) { ZEN_TRACE_CPU("ValidateBuildPart"); @@ -1210,7 +1217,7 @@ namespace { return SB.ToString(); } - std::vector<std::pair<Oid, std::string>> ResolveBuildPartNames(BuildStorage& Storage, + std::vector<std::pair<Oid, std::string>> ResolveBuildPartNames(BuildStorageBase& Storage, const Oid& BuildId, const std::vector<Oid>& BuildPartIds, std::span<const std::string> BuildPartNames, @@ -3276,7 +3283,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) .AllowResume = true, .RetryCount = 2}; - auto CreateBuildStorage = [&](BuildStorage::Statistics& StorageStats, + auto CreateBuildStorage = [&](BuildStorageBase::Statistics& StorageStats, BuildStorageCache::Statistics& StorageCacheStats, const std::filesystem::path& TempPath, bool RequireNamespace, @@ -3582,7 +3589,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } } - BuildStorage::Statistics StorageStats; + BuildStorageBase::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; const std::filesystem::path ZenFolderPath = m_ZenFolderPath.empty() @@ -3670,7 +3677,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } } - BuildStorage::Statistics StorageStats; + BuildStorageBase::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; if (m_ZenFolderPath.empty()) @@ -3737,7 +3744,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) throw OptionParseException(fmt::format("'--max-count' ('{}') is invalid", m_ListBlocksMaxCount), SubOption->help()); } - BuildStorage::Statistics StorageStats; + BuildStorageBase::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; if (m_ZenFolderPath.empty()) @@ -3810,7 +3817,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) ParsePath(); - BuildStorage::Statistics StorageStats; + BuildStorageBase::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; if (m_ZenFolderPath.empty()) @@ -3943,7 +3950,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } MakeSafeAbsolutePathÍnPlace(m_ZenFolderPath); - BuildStorage::Statistics StorageStats; + BuildStorageBase::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; StorageInstance Storage = CreateBuildStorage(StorageStats, @@ -4022,7 +4029,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } MakeSafeAbsolutePathÍnPlace(m_ZenFolderPath); - BuildStorage::Statistics StorageStats; + BuildStorageBase::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; StorageInstance Storage = CreateBuildStorage(StorageStats, @@ -4073,7 +4080,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) InitializeWorkerPools(m_BoostWorkerThreads); - BuildStorage::Statistics StorageStats; + BuildStorageBase::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; if (m_ZenFolderPath.empty()) @@ -4158,7 +4165,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) InitializeWorkerPools(m_BoostWorkerThreads); - BuildStorage::Statistics StorageStats; + BuildStorageBase::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; if (m_ZenFolderPath.empty()) @@ -4215,7 +4222,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) ZenState InstanceState; - BuildStorage::Statistics StorageStats; + BuildStorageBase::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; if (m_ZenFolderPath.empty()) @@ -4278,7 +4285,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) EPartialBlockRequestMode PartialBlockRequestMode = ParseAllowPartialBlockRequests(); - BuildStorage::Statistics StorageStats; + BuildStorageBase::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; StorageInstance Storage = CreateBuildStorage(StorageStats, @@ -4394,7 +4401,7 @@ BuildsCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) EPartialBlockRequestMode PartialBlockRequestMode = ParseAllowPartialBlockRequests(); - BuildStorage::Statistics StorageStats; + BuildStorageBase::Statistics StorageStats; BuildStorageCache::Statistics StorageCacheStats; const std::filesystem::path DownloadPath = m_Path.parent_path() / (m_BuildPartName + "_test"); diff --git a/src/zen/cmds/cache_cmd.cpp b/src/zen/cmds/cache_cmd.cpp index 2679df10a..2aa142973 100644 --- a/src/zen/cmds/cache_cmd.cpp +++ b/src/zen/cmds/cache_cmd.cpp @@ -688,7 +688,7 @@ CacheGetCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) { return Compressed.Decompress().AsIoBuffer(); }; - return std::move(Buffer); + return Buffer; }; IoBuffer ChunkData = m_Decompress ? TryDecompress(Result.ResponsePayload) : Result.ResponsePayload; diff --git a/src/zen/cmds/projectstore_cmd.cpp b/src/zen/cmds/projectstore_cmd.cpp index e400b96e7..af6f9aa7c 100644 --- a/src/zen/cmds/projectstore_cmd.cpp +++ b/src/zen/cmds/projectstore_cmd.cpp @@ -2020,7 +2020,7 @@ OplogMirrorCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** arg { return Compressed.Decompress().AsIoBuffer(); }; - return std::move(Buffer); + return Buffer; }; IoBuffer ChunkData = @@ -2385,8 +2385,8 @@ OplogDownloadCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** a throw OptionParseException("'--build-id' is malformed", m_Options.help()); } - BuildStorage::Statistics StorageStats; - HttpClient BuildStorageHttp(ResolveRes.HostUrl, ClientSettings); + BuildStorageBase::Statistics StorageStats; + HttpClient BuildStorageHttp(ResolveRes.HostUrl, ClientSettings); if (!m_Quiet) { @@ -2402,7 +2402,7 @@ OplogDownloadCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** a std::filesystem::path StorageTempPath = std::filesystem::temp_directory_path() / ("zen_" + Oid::NewOid().ToString()); - std::unique_ptr<BuildStorage> BuildStorage = + std::unique_ptr<BuildStorageBase> BuildStorage = CreateJupiterBuildStorage(Log(), BuildStorageHttp, StorageStats, m_Namespace, m_Bucket, m_AllowRedirect, StorageTempPath); Stopwatch Timer; diff --git a/src/zen/cmds/run_cmd.cpp b/src/zen/cmds/run_cmd.cpp index 00ab16fe5..ee47eb9f3 100644 --- a/src/zen/cmds/run_cmd.cpp +++ b/src/zen/cmds/run_cmd.cpp @@ -105,7 +105,6 @@ RunCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) } bool TimedRun = false; - auto CommandStartTime = std::chrono::system_clock::now(); auto CommandDeadlineTime = std::chrono::system_clock::now(); if (m_RunTime > 0) diff --git a/src/zen/cmds/workspaces_cmd.cpp b/src/zen/cmds/workspaces_cmd.cpp index b118d20a4..a7be7e7c5 100644 --- a/src/zen/cmds/workspaces_cmd.cpp +++ b/src/zen/cmds/workspaces_cmd.cpp @@ -712,7 +712,8 @@ WorkspaceShareCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** HttpClient::KeyValueMap{{"fieldnames", "id,clientpath"}})) { std::unordered_map<std::string, Oid> PathToOid; - for (CbFieldView EntryView : Result.AsObject()["files"sv]) + CbObjectView ResultObj = Result.AsObject(); + for (CbFieldView EntryView : ResultObj["files"sv]) { CbObjectView Entry = EntryView.AsObjectView(); PathToOid[std::string(Entry["clientpath"sv].AsString())] = Entry["id"sv].AsObjectId(); diff --git a/src/zenbase/include/zenbase/zenbase.h b/src/zenbase/include/zenbase/zenbase.h index 401bcd088..63a7e9f88 100644 --- a/src/zenbase/include/zenbase/zenbase.h +++ b/src/zenbase/include/zenbase/zenbase.h @@ -89,8 +89,8 @@ _Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wundef\"") \ _Pragma("clang diagnostic ignored \"-Wunused-parameter\"") _Pragma("clang diagnostic ignored \"-Wunused-variable\"") # elif ZEN_COMPILER_GCC -# define ZEN_THIRD_PARTY_INCLUDES_START \ - _Pragma("GCC diagnostic push") /* NB. ignoring -Wundef doesn't work with GCC */ \ +# define ZEN_THIRD_PARTY_INCLUDES_START \ + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wundef\"") \ _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") _Pragma("GCC diagnostic ignored \"-Wunused-variable\"") # endif #endif diff --git a/src/zencore/compactbinaryjson.cpp b/src/zencore/compactbinaryjson.cpp index 02f22ba4d..abbec360a 100644 --- a/src/zencore/compactbinaryjson.cpp +++ b/src/zencore/compactbinaryjson.cpp @@ -752,13 +752,6 @@ TEST_CASE("uson.json") Buffer.insert(Buffer.end(), AppendBytes, AppendBytes + Count); }; - auto Append = [&](const CbFieldView& Field) { - Field.WriteToStream([&](const void* Data, size_t Count) { - const uint8_t* AppendBytes = reinterpret_cast<const uint8_t*>(Data); - Buffer.insert(Buffer.end(), AppendBytes, AppendBytes + Count); - }); - }; - CbObject DataObjects[] = {MakeObject("Empty object"sv, {}), MakeObject("OneField object"sv, {5}), MakeObject("TwoField object"sv, {-5, 999}), diff --git a/src/zencore/compactbinaryutil.cpp b/src/zencore/compactbinaryutil.cpp index 074bdaffd..d9703bf1a 100644 --- a/src/zencore/compactbinaryutil.cpp +++ b/src/zencore/compactbinaryutil.cpp @@ -14,7 +14,7 @@ ValidateAndReadCompactBinaryObject(const SharedBuffer&& Payload, CbValidateError { if (OutError = ValidateCompactBinary(Payload.GetView(), CbValidateMode::Default); OutError == CbValidateError::None) { - CbObject Object(std::move(Payload)); + CbObject Object(Payload); if (Object.GetView().GetSize() != Payload.GetSize()) { OutError |= CbValidateError::OutOfBounds; diff --git a/src/zencore/filesystem.cpp b/src/zencore/filesystem.cpp index 8a58f136e..7f341818b 100644 --- a/src/zencore/filesystem.cpp +++ b/src/zencore/filesystem.cpp @@ -2695,7 +2695,7 @@ GetDirectoryContent(const std::filesystem::path& RootDir, }, WorkerThreadPool::EMode::DisableBacklog); } - catch (const std::exception Ex) + catch (const std::exception& Ex) { ZEN_ERROR("Failed scheduling work to scan folder '{}'. Reason: '{}'", Path, Ex.what()); PendingWorkCount.CountDown(); diff --git a/src/zencore/include/zencore/compactbinaryutil.h b/src/zencore/include/zencore/compactbinaryutil.h index eecc3344b..2617c749f 100644 --- a/src/zencore/include/zencore/compactbinaryutil.h +++ b/src/zencore/include/zencore/compactbinaryutil.h @@ -57,7 +57,7 @@ namespace compactbinary_helpers { inline void WriteArray(std::span<const Type> Values, std::string_view ArrayName, CbWriter& Output) { Output.BeginArray(ArrayName); - for (const Type Value : Values) + for (const Type& Value : Values) { Output << Value; } diff --git a/src/zencore/include/zencore/jobqueue.h b/src/zencore/include/zencore/jobqueue.h index 470ed3fc6..d348bd021 100644 --- a/src/zencore/include/zencore/jobqueue.h +++ b/src/zencore/include/zencore/jobqueue.h @@ -48,7 +48,7 @@ public: virtual bool CancelJob(JobId Id) = 0; virtual void Stop() = 0; - enum class Status : uint32_t + enum class JobStatus : uint32_t { Queued, Running, @@ -56,7 +56,7 @@ public: Completed }; - struct State + struct JobState { std::string CurrentOp; std::string CurrentOpDetails; @@ -68,8 +68,8 @@ public: struct JobInfo { - JobId Id; - Status Status; + JobId Id; + JobStatus Status; }; virtual std::vector<JobInfo> GetJobs() = 0; @@ -77,8 +77,8 @@ public: struct JobDetails { std::string Name; - Status Status; - State State; + JobStatus Status; + JobState State; std::chrono::system_clock::time_point CreateTime; std::chrono::system_clock::time_point StartTime; std::chrono::system_clock::time_point EndTime; @@ -89,7 +89,7 @@ public: // Will only respond once when status is Complete or Aborted virtual std::optional<JobDetails> Get(JobId Id) = 0; - static std::string_view ToString(Status Status); + static std::string_view ToString(JobStatus Status); }; std::unique_ptr<JobQueue> MakeJobQueue(int WorkerCount, std::string_view QueueName); diff --git a/src/zencore/jobqueue.cpp b/src/zencore/jobqueue.cpp index bd391909d..75c1be42b 100644 --- a/src/zencore/jobqueue.cpp +++ b/src/zencore/jobqueue.cpp @@ -45,7 +45,7 @@ public: JobId Id; JobFunction Callback; std::atomic_bool CancelFlag; - State State; + JobState State; JobClock::Tick CreateTick; JobClock::Tick StartTick; JobClock::Tick EndTick; @@ -223,7 +223,7 @@ public: QueueLock.WithSharedLock([&]() { for (auto It : RunningJobs) { - Jobs.push_back({.Id = JobId{It.first}, .Status = Status::Running}); + Jobs.push_back({.Id = JobId{It.first}, .Status = JobStatus::Running}); } for (auto It : CompletedJobs) { @@ -232,7 +232,7 @@ public: DeadJobs.push_back(JobId{It.first}); continue; } - Jobs.push_back({.Id = JobId{It.first}, .Status = Status::Completed}); + Jobs.push_back({.Id = JobId{It.first}, .Status = JobStatus::Completed}); } for (auto It : AbortedJobs) { @@ -241,11 +241,11 @@ public: DeadJobs.push_back(JobId{It.first}); continue; } - Jobs.push_back({.Id = JobId{It.first}, .Status = Status::Aborted}); + Jobs.push_back({.Id = JobId{It.first}, .Status = JobStatus::Aborted}); } for (auto It : QueuedJobs) { - Jobs.push_back({.Id = It->Id, .Status = Status::Queued}); + Jobs.push_back({.Id = It->Id, .Status = JobStatus::Queued}); } }); if (!DeadJobs.empty()) @@ -264,7 +264,7 @@ public: // Will only respond once when Complete is true virtual std::optional<JobDetails> Get(JobId Id) override { - auto Convert = [](Status Status, Job& Job) -> JobDetails { + auto Convert = [](JobStatus Status, Job& Job) -> JobDetails { return JobDetails{ .Name = Job.Name, .Status = Status, @@ -286,25 +286,25 @@ public: QueueLock.WithExclusiveLock([&]() { if (auto It = RunningJobs.find(Id.Id); It != RunningJobs.end()) { - Result = Convert(Status::Running, *It->second); + Result = Convert(JobStatus::Running, *It->second); return; } if (auto It = CompletedJobs.find(Id.Id); It != CompletedJobs.end()) { - Result = Convert(Status::Completed, *It->second); + Result = Convert(JobStatus::Completed, *It->second); CompletedJobs.erase(It); return; } if (auto It = AbortedJobs.find(Id.Id); It != AbortedJobs.end()) { - Result = Convert(Status::Aborted, *It->second); + Result = Convert(JobStatus::Aborted, *It->second); AbortedJobs.erase(It); return; } if (auto It = std::find_if(QueuedJobs.begin(), QueuedJobs.end(), [&Id](const RefPtr<Job>& Job) { return Job->Id.Id == Id.Id; }); It != QueuedJobs.end()) { - Result = Convert(Status::Queued, *(*It)); + Result = Convert(JobStatus::Queued, *(*It)); return; } }); @@ -421,22 +421,22 @@ public: }; std::string_view -JobQueue::ToString(Status Status) +JobQueue::ToString(JobStatus Status) { using namespace std::literals; switch (Status) { - case JobQueue::Status::Queued: + case JobQueue::JobStatus::Queued: return "Queued"sv; break; - case JobQueue::Status::Running: + case JobQueue::JobStatus::Running: return "Running"sv; break; - case JobQueue::Status::Aborted: + case JobQueue::JobStatus::Aborted: return "Aborted"sv; break; - case JobQueue::Status::Completed: + case JobQueue::JobStatus::Completed: return "Completed"sv; break; default: @@ -496,6 +496,7 @@ TEST_CASE("JobQueue") } Context.ReportProgress("done", "", 100, 0); }); + ZEN_UNUSED(Id); }, WorkerThreadPool::EMode::EnableBacklog); } @@ -528,22 +529,22 @@ TEST_CASE("JobQueue") RemainingJobs.reserve(Statuses.size()); for (const auto& It : Statuses) { - JobQueue::Status Status = It.Status; + JobQueue::JobStatus Status = It.Status; JobId Id = It.Id; std::optional<JobQueue::JobDetails> CurrentState; - if (Status != JobQueue::Status::Queued) + if (Status != JobQueue::JobStatus::Queued) { CurrentState = Queue->Get(Id); CHECK(CurrentState.has_value()); } switch (Status) { - case JobQueue::Status::Queued: + case JobQueue::JobStatus::Queued: PendingCount++; RemainingJobs.push_back(Id); break; - case JobQueue::Status::Running: + case JobQueue::JobStatus::Running: ZEN_DEBUG( "{} running. '{}{}' {}% '{}'", Id.Id, @@ -556,10 +557,10 @@ TEST_CASE("JobQueue") Join(CurrentState->State.Messages, " "sv)); RemainingJobs.push_back(Id); break; - case JobQueue::Status::Aborted: + case JobQueue::JobStatus::Aborted: ZEN_DEBUG("{} aborted. Reason: '{}'", Id.Id, CurrentState->State.AbortReason); break; - case JobQueue::Status::Completed: + case JobQueue::JobStatus::Completed: ZEN_DEBUG("{} completed. '{}'", Id.Id, Join(CurrentState->State.Messages, " "sv)); break; default: diff --git a/src/zencore/memory/mallocrpmalloc.cpp b/src/zencore/memory/mallocrpmalloc.cpp index ffced27c9..c45186b77 100644 --- a/src/zencore/memory/mallocrpmalloc.cpp +++ b/src/zencore/memory/mallocrpmalloc.cpp @@ -7,6 +7,7 @@ #if ZEN_RPMALLOC_ENABLED # include "rpmalloc.h" +# include <cstring> /** Value we fill a memory block with after it is free, in UE_BUILD_DEBUG **/ # define DEBUG_FILL_FREED (0xdd) diff --git a/src/zencore/memory/memoryarena.cpp b/src/zencore/memory/memoryarena.cpp index 9c907a66d..8807f3264 100644 --- a/src/zencore/memory/memoryarena.cpp +++ b/src/zencore/memory/memoryarena.cpp @@ -2,6 +2,8 @@ #include <zencore/memory/memoryarena.h> +#include <cstring> + namespace zen { MemoryArena::~MemoryArena() diff --git a/src/zencore/memtrack/tagtrace.cpp b/src/zencore/memtrack/tagtrace.cpp index 473bd773b..70a74365d 100644 --- a/src/zencore/memtrack/tagtrace.cpp +++ b/src/zencore/memtrack/tagtrace.cpp @@ -141,7 +141,10 @@ private: static uint32_t KeyHash(int32_t Key) { return static_cast<uint32>(Key); } static void ClearEntries(FTagNameSetEntry* Entries, int32_t EntryCount) { - memset(Entries, 0, EntryCount * sizeof(FTagNameSetEntry)); + for (int32_t Index = 0; Index < EntryCount; ++Index) + { + Entries[Index].SetKeyValue(0, false); + } } }; typedef TGrowOnlyLockFreeHash<FTagNameSetEntry, int32_t, bool> FTagNameSet; diff --git a/src/zenhttp/httpclientauth.cpp b/src/zenhttp/httpclientauth.cpp index 8754c57d6..72df12d02 100644 --- a/src/zenhttp/httpclientauth.cpp +++ b/src/zenhttp/httpclientauth.cpp @@ -133,8 +133,6 @@ namespace zen { namespace httpclientauth { int ExitCode = Proc.WaitExitCode(); - auto EndTime = std::chrono::system_clock::now(); - if (ExitCode == 0) { IoBuffer Body = IoBufferBuilder::MakeFromFile(AuthTokenPath); diff --git a/src/zenhttp/include/zenhttp/httpclient.h b/src/zenhttp/include/zenhttp/httpclient.h index b12bdefb8..4fec1ec3f 100644 --- a/src/zenhttp/include/zenhttp/httpclient.h +++ b/src/zenhttp/include/zenhttp/httpclient.h @@ -144,8 +144,20 @@ public: : Entries({{{std::string(Entry.first), std::string(Entry.second)}}}) { } - KeyValueMap(std::span<std::pair<std::string_view, std::string_view>>&& List) : Entries(List.begin(), List.end()) {} - KeyValueMap(std::initializer_list<std::pair<std::string_view, std::string_view>>&& List) : Entries(List.begin(), List.end()) {} + KeyValueMap(std::span<std::pair<std::string_view, std::string_view>>&& List) + { + for (const auto& kv : List) + { + Entries.emplace(std::string(kv.first), std::string(kv.second)); + } + } + KeyValueMap(std::initializer_list<std::pair<std::string_view, std::string_view>>&& List) + { + for (const auto& kv : List) + { + Entries.emplace(std::string(kv.first), std::string(kv.second)); + } + } }; struct Response diff --git a/src/zenremotestore/builds/buildstorageoperations.cpp b/src/zenremotestore/builds/buildstorageoperations.cpp index f106b7b18..ecf5853b8 100644 --- a/src/zenremotestore/builds/buildstorageoperations.cpp +++ b/src/zenremotestore/builds/buildstorageoperations.cpp @@ -180,7 +180,7 @@ namespace { return SB.ToString(); } - void DownloadLargeBlob(BuildStorage& Storage, + void DownloadLargeBlob(BuildStorageBase& Storage, const std::filesystem::path& DownloadFolder, const Oid& BuildId, const IoHash& ChunkHash, @@ -6804,7 +6804,7 @@ BuildsOperationUploadFolder::CompressChunk(const ChunkedFolderContent& Content, } BuildsOperationValidateBuildPart::BuildsOperationValidateBuildPart(BuildOpLogOutput& LogOutput, - BuildStorage& Storage, + BuildStorageBase& Storage, std::atomic<bool>& AbortFlag, std::atomic<bool>& PauseFlag, WorkerThreadPool& IOWorkerPool, @@ -6883,15 +6883,23 @@ BuildsOperationValidateBuildPart::Execute() ZEN_CONSOLE("Validating build part {}/{} ({})", m_BuildId, m_BuildPartId, NiceBytes(BuildPart.GetSize())); } std::vector<IoHash> ChunkAttachments; - for (CbFieldView LooseFileView : BuildPart["chunkAttachments"sv].AsObjectView()["rawHashes"sv]) + if (const CbObjectView ChunkAttachmentsView = BuildPart["chunkAttachments"sv].AsObjectView()) { - ChunkAttachments.push_back(LooseFileView.AsBinaryAttachment()); + for (CbFieldView LooseFileView : ChunkAttachmentsView["rawHashes"sv]) + { + ChunkAttachments.push_back(LooseFileView.AsBinaryAttachment()); + } } m_ValidateStats.ChunkAttachmentCount = ChunkAttachments.size(); std::vector<IoHash> BlockAttachments; - for (CbFieldView BlocksView : BuildPart["blockAttachments"sv].AsObjectView()["rawHashes"sv]) + if (const CbObjectView BlockAttachmentsView = BuildPart["blockAttachments"sv].AsObjectView()) { - BlockAttachments.push_back(BlocksView.AsBinaryAttachment()); + { + for (CbFieldView BlocksView : BlockAttachmentsView["rawHashes"sv]) + { + BlockAttachments.push_back(BlocksView.AsBinaryAttachment()); + } + } } m_ValidateStats.BlockAttachmentCount = BlockAttachments.size(); @@ -7375,7 +7383,7 @@ BuildsOperationPrimeCache::Execute() CompositeBuffer ValidateBlob(std::atomic<bool>& AbortFlag, - BuildStorage& Storage, + BuildStorageBase& Storage, const Oid& BuildId, const IoHash& BlobHash, uint64_t& OutCompressedSize, diff --git a/src/zenremotestore/builds/filebuildstorage.cpp b/src/zenremotestore/builds/filebuildstorage.cpp index 3cda5f00f..96d81b281 100644 --- a/src/zenremotestore/builds/filebuildstorage.cpp +++ b/src/zenremotestore/builds/filebuildstorage.cpp @@ -14,14 +14,14 @@ namespace zen { using namespace std::literals; -class FileBuildStorage : public BuildStorage +class FileBuildStorage : public BuildStorageBase { public: - explicit FileBuildStorage(const std::filesystem::path& StoragePath, - BuildStorage::Statistics& Stats, - bool EnableJsonOutput, - double LatencySec, - double DelayPerKBSec) + explicit FileBuildStorage(const std::filesystem::path& StoragePath, + BuildStorageBase::Statistics& Stats, + bool EnableJsonOutput, + double LatencySec, + double DelayPerKBSec) : m_StoragePath(StoragePath) , m_Stats(Stats) , m_EnableJsonOutput(EnableJsonOutput) @@ -788,21 +788,21 @@ private: } } - const std::filesystem::path m_StoragePath; - BuildStorage::Statistics& m_Stats; - const bool m_EnableJsonOutput = false; - std::atomic<uint64_t> m_WrittenBytes; + const std::filesystem::path m_StoragePath; + BuildStorageBase::Statistics& m_Stats; + const bool m_EnableJsonOutput = false; + std::atomic<uint64_t> m_WrittenBytes; const double m_LatencySec = 0.0; const double m_DelayPerKBSec = 0.0; }; -std::unique_ptr<BuildStorage> -CreateFileBuildStorage(const std::filesystem::path& StoragePath, - BuildStorage::Statistics& Stats, - bool EnableJsonOutput, - double LatencySec, - double DelayPerKBSec) +std::unique_ptr<BuildStorageBase> +CreateFileBuildStorage(const std::filesystem::path& StoragePath, + BuildStorageBase::Statistics& Stats, + bool EnableJsonOutput, + double LatencySec, + double DelayPerKBSec) { return std::make_unique<FileBuildStorage>(StoragePath, Stats, EnableJsonOutput, LatencySec, DelayPerKBSec); } diff --git a/src/zenremotestore/builds/jupiterbuildstorage.cpp b/src/zenremotestore/builds/jupiterbuildstorage.cpp index 14a5ecc85..fe8067905 100644 --- a/src/zenremotestore/builds/jupiterbuildstorage.cpp +++ b/src/zenremotestore/builds/jupiterbuildstorage.cpp @@ -30,7 +30,7 @@ namespace { } } // namespace -class JupiterBuildStorage : public BuildStorage +class JupiterBuildStorage : public BuildStorageBase { public: JupiterBuildStorage(LoggerRef InLog, @@ -499,14 +499,14 @@ private: const std::filesystem::path m_TempFolderPath; }; -std::unique_ptr<BuildStorage> -CreateJupiterBuildStorage(LoggerRef InLog, - HttpClient& InHttpClient, - BuildStorage::Statistics& Stats, - std::string_view Namespace, - std::string_view Bucket, - bool AllowRedirect, - const std::filesystem::path& TempFolderPath) +std::unique_ptr<BuildStorageBase> +CreateJupiterBuildStorage(LoggerRef InLog, + HttpClient& InHttpClient, + BuildStorageBase::Statistics& Stats, + std::string_view Namespace, + std::string_view Bucket, + bool AllowRedirect, + const std::filesystem::path& TempFolderPath) { ZEN_TRACE_CPU("CreateJupiterBuildStorage"); diff --git a/src/zenremotestore/chunking/chunking.cpp b/src/zenremotestore/chunking/chunking.cpp index 71f0a06e4..91d54f111 100644 --- a/src/zenremotestore/chunking/chunking.cpp +++ b/src/zenremotestore/chunking/chunking.cpp @@ -37,7 +37,7 @@ static const uint32_t BuzhashTable[] = { }; // ROL operation (compiler turns this into a ROL when optimizing) -ZEN_FORCEINLINE static uint32_t +ZEN_FORCEINLINE static inline uint32_t Rotate32(uint32_t Value, size_t RotateCount) { RotateCount &= 31; diff --git a/src/zenremotestore/include/zenremotestore/builds/buildstorage.h b/src/zenremotestore/include/zenremotestore/builds/buildstorage.h index ee0ddcaa4..d4df979e2 100644 --- a/src/zenremotestore/include/zenremotestore/builds/buildstorage.h +++ b/src/zenremotestore/include/zenremotestore/builds/buildstorage.h @@ -11,7 +11,7 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { -class BuildStorage +class BuildStorageBase { public: struct Statistics @@ -26,7 +26,7 @@ public: std::atomic<uint64_t> PeakBytesPerSec = 0; }; - virtual ~BuildStorage() {} + virtual ~BuildStorageBase() {} virtual CbObject ListNamespaces(bool bRecursive = false) = 0; virtual CbObject ListBuilds(CbObject Query) = 0; diff --git a/src/zenremotestore/include/zenremotestore/builds/buildstorageoperations.h b/src/zenremotestore/include/zenremotestore/builds/buildstorageoperations.h index 157435971..351f4b522 100644 --- a/src/zenremotestore/include/zenremotestore/builds/buildstorageoperations.h +++ b/src/zenremotestore/include/zenremotestore/builds/buildstorageoperations.h @@ -21,7 +21,7 @@ namespace zen { class CloneQueryInterface; -class BuildStorage; +class BuildStorageBase; class BuildStorageCache; class HttpClient; class ParallelWork; @@ -109,7 +109,7 @@ struct RebuildFolderStateStatistics struct StorageInstance { std::unique_ptr<HttpClient> BuildStorageHttp; - std::unique_ptr<BuildStorage> BuildStorage; + std::unique_ptr<BuildStorageBase> BuildStorage; std::string StorageName; std::unique_ptr<HttpClient> CacheHttp; std::unique_ptr<BuildStorageCache> BuildCacheStorage; @@ -723,7 +723,7 @@ public: bool IsVerbose = false; }; BuildsOperationValidateBuildPart(BuildOpLogOutput& LogOutput, - BuildStorage& Storage, + BuildStorageBase& Storage, std::atomic<bool>& AbortFlag, std::atomic<bool>& PauseFlag, WorkerThreadPool& IOWorkerPool, @@ -745,7 +745,7 @@ private: uint64_t& OutDecompressedSize); BuildOpLogOutput& m_LogOutput; - BuildStorage& m_Storage; + BuildStorageBase& m_Storage; std::atomic<bool>& m_AbortFlag; std::atomic<bool>& m_PauseFlag; WorkerThreadPool& m_IOWorkerPool; @@ -798,7 +798,7 @@ private: }; CompositeBuffer ValidateBlob(std::atomic<bool>& AbortFlag, - BuildStorage& Storage, + BuildStorageBase& Storage, const Oid& BuildId, const IoHash& BlobHash, uint64_t& OutCompressedSize, diff --git a/src/zenremotestore/include/zenremotestore/builds/filebuildstorage.h b/src/zenremotestore/include/zenremotestore/builds/filebuildstorage.h index 8c1e3c5df..9743a8608 100644 --- a/src/zenremotestore/include/zenremotestore/builds/filebuildstorage.h +++ b/src/zenremotestore/include/zenremotestore/builds/filebuildstorage.h @@ -8,9 +8,9 @@ namespace zen { class HttpClient; -std::unique_ptr<BuildStorage> CreateFileBuildStorage(const std::filesystem::path& StoragePath, - BuildStorage::Statistics& Stats, - bool EnableJsonOutput, - double LatencySec = 0.0, - double DelayPerKBSec = 0.0); +std::unique_ptr<BuildStorageBase> CreateFileBuildStorage(const std::filesystem::path& StoragePath, + BuildStorageBase::Statistics& Stats, + bool EnableJsonOutput, + double LatencySec = 0.0, + double DelayPerKBSec = 0.0); } // namespace zen diff --git a/src/zenremotestore/include/zenremotestore/builds/jupiterbuildstorage.h b/src/zenremotestore/include/zenremotestore/builds/jupiterbuildstorage.h index 9e25ead7a..888ec8ead 100644 --- a/src/zenremotestore/include/zenremotestore/builds/jupiterbuildstorage.h +++ b/src/zenremotestore/include/zenremotestore/builds/jupiterbuildstorage.h @@ -8,13 +8,13 @@ namespace zen { class HttpClient; -std::unique_ptr<BuildStorage> CreateJupiterBuildStorage(LoggerRef InLog, - HttpClient& InHttpClient, - BuildStorage::Statistics& Stats, - std::string_view Namespace, - std::string_view Bucket, - bool AllowRedirect, - const std::filesystem::path& TempFolderPath); +std::unique_ptr<BuildStorageBase> CreateJupiterBuildStorage(LoggerRef InLog, + HttpClient& InHttpClient, + BuildStorageBase::Statistics& Stats, + std::string_view Namespace, + std::string_view Bucket, + bool AllowRedirect, + const std::filesystem::path& TempFolderPath); bool ParseBuildStorageUrl(std::string_view InUrl, std::string& OutHost, diff --git a/src/zenremotestore/projectstore/buildsremoteprojectstore.cpp b/src/zenremotestore/projectstore/buildsremoteprojectstore.cpp index 1d749a17d..09ffc5d71 100644 --- a/src/zenremotestore/projectstore/buildsremoteprojectstore.cpp +++ b/src/zenremotestore/projectstore/buildsremoteprojectstore.cpp @@ -579,9 +579,9 @@ private: LoggerRef m_Log; - BuildStorage::Statistics m_BuildStorageStats; - HttpClient m_BuildStorageHttp; - std::unique_ptr<BuildStorage> m_BuildStorage; + BuildStorageBase::Statistics m_BuildStorageStats; + HttpClient m_BuildStorageHttp; + std::unique_ptr<BuildStorageBase> m_BuildStorage; BuildStorageCache::Statistics m_StorageCacheStats; std::unique_ptr<HttpClient> m_BuildCacheStorageHttp; diff --git a/src/zenremotestore/projectstore/remoteprojectstore.cpp b/src/zenremotestore/projectstore/remoteprojectstore.cpp index d316f67e5..7e02e5d69 100644 --- a/src/zenremotestore/projectstore/remoteprojectstore.cpp +++ b/src/zenremotestore/projectstore/remoteprojectstore.cpp @@ -740,6 +740,7 @@ namespace remotestore_impl { ChunkBlockDescription Block; CompressedBuffer CompressedBlock = GenerateChunkBlock(std::move(Chunks), Block); IoHash BlockHash = CompressedBlock.DecodeRawHash(); + ZEN_UNUSED(BlockHash); { // We can share the lock as we are not resizing the vector and only touch BlockHash at our own index RwLock::SharedLockScope __(SectionsLock); diff --git a/src/zenserver/config/config.cpp b/src/zenserver/config/config.cpp index e7cfd490a..18187711b 100644 --- a/src/zenserver/config/config.cpp +++ b/src/zenserver/config/config.cpp @@ -138,28 +138,28 @@ ZenServerConfiguratorBase::AddCommonConfigOptions(LuaConfig::Options& LuaOptions LuaOptions.AddOption("server.noconsole"sv, ServerOptions.NoConsoleOutput, "noconsole"sv); ////// network - LuaOptions.AddOption("network.httpserverclass"sv, ServerOptions.HttpServerConfig.ServerClass, "http"sv); - LuaOptions.AddOption("network.httpserverthreads"sv, ServerOptions.HttpServerConfig.ThreadCount, "http-threads"sv); + LuaOptions.AddOption("network.httpserverclass"sv, ServerOptions.HttpConfig.ServerClass, "http"sv); + LuaOptions.AddOption("network.httpserverthreads"sv, ServerOptions.HttpConfig.ThreadCount, "http-threads"sv); LuaOptions.AddOption("network.port"sv, ServerOptions.BasePort, "port"sv); - LuaOptions.AddOption("network.forceloopback"sv, ServerOptions.HttpServerConfig.ForceLoopback, "http-forceloopback"sv); + LuaOptions.AddOption("network.forceloopback"sv, ServerOptions.HttpConfig.ForceLoopback, "http-forceloopback"sv); #if ZEN_WITH_HTTPSYS LuaOptions.AddOption("network.httpsys.async.workthreads"sv, - ServerOptions.HttpServerConfig.HttpSys.AsyncWorkThreadCount, + ServerOptions.HttpConfig.HttpSys.AsyncWorkThreadCount, "httpsys-async-work-threads"sv); LuaOptions.AddOption("network.httpsys.async.response"sv, - ServerOptions.HttpServerConfig.HttpSys.IsAsyncResponseEnabled, + ServerOptions.HttpConfig.HttpSys.IsAsyncResponseEnabled, "httpsys-enable-async-response"sv); LuaOptions.AddOption("network.httpsys.requestlogging"sv, - ServerOptions.HttpServerConfig.HttpSys.IsRequestLoggingEnabled, + ServerOptions.HttpConfig.HttpSys.IsRequestLoggingEnabled, "httpsys-enable-request-logging"sv); #endif #if ZEN_WITH_TRACE ////// trace - LuaOptions.AddOption("trace.channels"sv, ServerOptions.TraceOptions.Channels, "trace"sv); - LuaOptions.AddOption("trace.host"sv, ServerOptions.TraceOptions.Host, "tracehost"sv); - LuaOptions.AddOption("trace.file"sv, ServerOptions.TraceOptions.File, "tracefile"sv); + LuaOptions.AddOption("trace.channels"sv, ServerOptions.TraceCmdLineOptions.Channels, "trace"sv); + LuaOptions.AddOption("trace.host"sv, ServerOptions.TraceCmdLineOptions.Host, "tracehost"sv); + LuaOptions.AddOption("trace.file"sv, ServerOptions.TraceCmdLineOptions.File, "tracefile"sv); #endif ////// stats @@ -291,7 +291,7 @@ ZenServerCmdLineOptions::AddCliOptions(cxxopts::Options& options, ZenServerConfi "", "http-threads", "Number of http server connection threads", - cxxopts::value<unsigned int>(ServerOptions.HttpServerConfig.ThreadCount), + cxxopts::value<unsigned int>(ServerOptions.HttpConfig.ThreadCount), "<http threads>"); options.add_option("network", @@ -305,7 +305,7 @@ ZenServerCmdLineOptions::AddCliOptions(cxxopts::Options& options, ZenServerConfi "", "http-forceloopback", "Force using local loopback interface", - cxxopts::value<bool>(ServerOptions.HttpServerConfig.ForceLoopback)->default_value("false"), + cxxopts::value<bool>(ServerOptions.HttpConfig.ForceLoopback)->default_value("false"), "<http forceloopback>"); #if ZEN_WITH_HTTPSYS @@ -313,21 +313,21 @@ ZenServerCmdLineOptions::AddCliOptions(cxxopts::Options& options, ZenServerConfi "", "httpsys-async-work-threads", "Number of HttpSys async worker threads", - cxxopts::value<unsigned int>(ServerOptions.HttpServerConfig.HttpSys.AsyncWorkThreadCount), + cxxopts::value<unsigned int>(ServerOptions.HttpConfig.HttpSys.AsyncWorkThreadCount), "<httpsys workthreads>"); options.add_option("httpsys", "", "httpsys-enable-async-response", "Enables Httpsys async response", - cxxopts::value<bool>(ServerOptions.HttpServerConfig.HttpSys.IsAsyncResponseEnabled)->default_value("true"), + cxxopts::value<bool>(ServerOptions.HttpConfig.HttpSys.IsAsyncResponseEnabled)->default_value("true"), "<httpsys async response>"); options.add_option("httpsys", "", "httpsys-enable-request-logging", "Enables Httpsys request logging", - cxxopts::value<bool>(ServerOptions.HttpServerConfig.HttpSys.IsRequestLoggingEnabled), + cxxopts::value<bool>(ServerOptions.HttpConfig.HttpSys.IsRequestLoggingEnabled), "<httpsys request logging>"); #endif @@ -339,7 +339,7 @@ ZenServerCmdLineOptions::AddCliOptions(cxxopts::Options& options, ZenServerConfi "httpsys|" #endif "null)", - cxxopts::value<std::string>(ServerOptions.HttpServerConfig.ServerClass)->default_value(DefaultHttp), + cxxopts::value<std::string>(ServerOptions.HttpConfig.ServerClass)->default_value(DefaultHttp), "<http class>"); #if ZEN_WITH_TRACE @@ -350,21 +350,21 @@ ZenServerCmdLineOptions::AddCliOptions(cxxopts::Options& options, ZenServerConfi "", "trace", "Specify which trace channels should be enabled", - cxxopts::value<std::string>(ServerOptions.TraceOptions.Channels)->default_value(""), + cxxopts::value<std::string>(ServerOptions.TraceCmdLineOptions.Channels)->default_value(""), ""); options.add_option("ue-trace", "", "tracehost", "Hostname to send the trace to", - cxxopts::value<std::string>(ServerOptions.TraceOptions.Host)->default_value(""), + cxxopts::value<std::string>(ServerOptions.TraceCmdLineOptions.Host)->default_value(""), ""); options.add_option("ue-trace", "", "tracefile", "Path to write a trace to", - cxxopts::value<std::string>(ServerOptions.TraceOptions.File)->default_value(""), + cxxopts::value<std::string>(ServerOptions.TraceCmdLineOptions.File)->default_value(""), ""); #endif // ZEN_WITH_TRACE @@ -459,7 +459,7 @@ ZenServerConfiguratorBase::Configure(int argc, char* argv[]) if (!m_ServerOptions.HasTraceCommandlineOptions) { // Apply any Lua settings if we don't have them set from the command line - TraceConfigure(m_ServerOptions.TraceOptions); + TraceConfigure(m_ServerOptions.TraceCmdLineOptions); } #endif @@ -534,7 +534,7 @@ ZenServerConfiguratorBase::Configure(int argc, char* argv[]) m_ServerOptions.AbsLogFile = m_ServerOptions.DataDir / "logs" / "zenserver.log"; } - m_ServerOptions.HttpServerConfig.IsDedicatedServer = m_ServerOptions.IsDedicated; + m_ServerOptions.HttpConfig.IsDedicatedServer = m_ServerOptions.IsDedicated; } void diff --git a/src/zenserver/config/config.h b/src/zenserver/config/config.h index 467f26ee7..40639da13 100644 --- a/src/zenserver/config/config.h +++ b/src/zenserver/config/config.h @@ -39,7 +39,7 @@ struct ZenSentryConfig struct ZenServerConfig { - HttpServerConfig HttpServerConfig; + HttpServerConfig HttpConfig; ZenSentryConfig SentryConfig; ZenStatsConfig StatsConfig; int BasePort = 8558; // Service listen port (used for both UDP and TCP) @@ -66,7 +66,7 @@ struct ZenServerConfig std::string Loggers[zen::logging::level::LogLevelCount]; #if ZEN_WITH_TRACE bool HasTraceCommandlineOptions = false; - TraceOptions TraceOptions; + TraceOptions TraceCmdLineOptions; #endif std::string MemoryOptions; // Memory allocation options std::string CommandLine; diff --git a/src/zenserver/config/luaconfig.cpp b/src/zenserver/config/luaconfig.cpp index 2c54de29e..61969019c 100644 --- a/src/zenserver/config/luaconfig.cpp +++ b/src/zenserver/config/luaconfig.cpp @@ -330,7 +330,6 @@ Options::Print(zen::StringBuilderBase& SB, const cxxopts::ParseResult& CmdLineRe }; std::vector<std::string> CurrentTablePath; std::string Indent; - auto It = SortedKeys.begin(); for (const std::string& Key : SortedKeys) { std::vector<std::string> KeyPath = GetTablePath(Key); diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp index 43ddc14c9..6bab33d92 100644 --- a/src/zenserver/main.cpp +++ b/src/zenserver/main.cpp @@ -94,10 +94,10 @@ AppMain(int argc, char* argv[]) #if ZEN_WITH_TRACE TraceInit("zenserver"); - ServerOptions.HasTraceCommandlineOptions = GetTraceOptionsFromCommandline(/* out */ ServerOptions.TraceOptions); + ServerOptions.HasTraceCommandlineOptions = GetTraceOptionsFromCommandline(/* out */ ServerOptions.TraceCmdLineOptions); if (ServerOptions.HasTraceCommandlineOptions) { - TraceConfigure(ServerOptions.TraceOptions); + TraceConfigure(ServerOptions.TraceCmdLineOptions); } #endif // ZEN_WITH_TRACE diff --git a/src/zenserver/storage/admin/admin.cpp b/src/zenserver/storage/admin/admin.cpp index 68b91825d..04f43d33a 100644 --- a/src/zenserver/storage/admin/admin.cpp +++ b/src/zenserver/storage/admin/admin.cpp @@ -164,7 +164,7 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler, return Req.ServerRequest().WriteResponse(HttpResponseCode::NotFound); } - auto WriteState = [](CbObjectWriter& Obj, const JobQueue::State& State) { + auto WriteState = [](CbObjectWriter& Obj, const JobQueue::JobState& State) { if (!State.CurrentOp.empty()) { Obj.AddString( @@ -207,7 +207,7 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler, switch (CurrentState->Status) { - case JobQueue::Status::Queued: + case JobQueue::JobStatus::Queued: { CbObjectWriter Obj; Obj.AddString("Name"sv, CurrentState->Name); @@ -217,7 +217,7 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler, Req.ServerRequest().WriteResponse(HttpResponseCode::OK, Obj.Save()); } break; - case JobQueue::Status::Running: + case JobQueue::JobStatus::Running: { CbObjectWriter Obj; Obj.AddString("Name"sv, CurrentState->Name); @@ -229,7 +229,7 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler, Req.ServerRequest().WriteResponse(HttpResponseCode::OK, Obj.Save()); } break; - case JobQueue::Status::Aborted: + case JobQueue::JobStatus::Aborted: { CbObjectWriter Obj; Obj.AddString("Name"sv, CurrentState->Name); @@ -243,7 +243,7 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler, Req.ServerRequest().WriteResponse(HttpResponseCode::OK, Obj.Save()); } break; - case JobQueue::Status::Completed: + case JobQueue::JobStatus::Completed: { CbObjectWriter Obj; Obj.AddString("Name"sv, CurrentState->Name); diff --git a/src/zenserver/storage/buildstore/httpbuildstore.cpp b/src/zenserver/storage/buildstore/httpbuildstore.cpp index e5ea23acc..18fae7027 100644 --- a/src/zenserver/storage/buildstore/httpbuildstore.cpp +++ b/src/zenserver/storage/buildstore/httpbuildstore.cpp @@ -199,6 +199,8 @@ HttpBuildStoreService::PutMetadataRequest(HttpRouterRequest& Req) std::string_view Bucket = Req.GetCapture(2); std::string_view BuildId = Req.GetCapture(3); + ZEN_UNUSED(Namespace, Bucket, BuildId); + IoBuffer MetaPayload = ServerRequest.ReadPayload(); if (MetaPayload.GetContentType() != ZenContentType::kCbPackage) { diff --git a/src/zenserver/storage/storageconfig.cpp b/src/zenserver/storage/storageconfig.cpp index 61844140e..3a41ad003 100644 --- a/src/zenserver/storage/storageconfig.cpp +++ b/src/zenserver/storage/storageconfig.cpp @@ -41,7 +41,7 @@ ZenStorageServerConfigurator::ValidateOptions() throw OptionParseException(fmt::format("'--encryption-aes-iv' ('{}') is malformed", ServerOptions.EncryptionIV), {}); } } - if (ServerOptions.HttpServerConfig.ForceLoopback && ServerOptions.IsDedicated) + if (ServerOptions.HttpConfig.ForceLoopback && ServerOptions.IsDedicated) { throw OptionParseException("'--dedicated' conflicts with '--http-forceloopback'", {}); } @@ -602,7 +602,7 @@ ZenStorageServerConfigurator::ParsePluginsConfigFile(const std::filesystem::path Config.PluginOptions.push_back({"port", std::to_string(m_ServerOptions.BasePort)}); } - m_ServerOptions.HttpServerConfig.PluginConfigs.push_back(Config); + m_ServerOptions.HttpConfig.PluginConfigs.push_back(Config); } } diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp index 2dd51d243..787f28693 100644 --- a/src/zenserver/zenserver.cpp +++ b/src/zenserver/zenserver.cpp @@ -124,12 +124,12 @@ ZenServerBase::Initialize(const ZenServerConfig& ServerOptions, ZenServerState:: EnqueueSigIntTimer(); - m_Http = CreateHttpServer(ServerOptions.HttpServerConfig); + m_Http = CreateHttpServer(ServerOptions.HttpConfig); int EffectiveBasePort = m_Http->Initialize(ServerOptions.BasePort, ServerOptions.DataDir); if (EffectiveBasePort == 0) { ZEN_WARN("Failed to initialize http service '{}' using base port {} and data dir '{}'", - ServerOptions.HttpServerConfig.ServerClass, + ServerOptions.HttpConfig.ServerClass, ServerOptions.BasePort, ServerOptions.DataDir); return -1; diff --git a/src/zenstore/buildstore/buildstore.cpp b/src/zenstore/buildstore/buildstore.cpp index aa28d8900..99cf7f16e 100644 --- a/src/zenstore/buildstore/buildstore.cpp +++ b/src/zenstore/buildstore/buildstore.cpp @@ -231,7 +231,7 @@ BuildStore::PutBlob(const IoHash& BlobHash, const IoBuffer& Payload) uint64_t PayloadSize = Payload.GetSize(); CidStore::InsertResult Result = m_BlobStore.AddChunk(Payload, BlobHash); PayloadEntry Entry = PayloadEntry(0, PayloadSize); - ; + ZEN_UNUSED(Result); IoHash MetadataHash; { @@ -1095,8 +1095,6 @@ public: ZEN_TRACE_CPU("Builds::UpdateLockedState"); ZEN_MEMSCOPE(GetBuildstoreTag()); - auto Log = [&Ctx]() { return Ctx.Logger; }; - ZEN_ASSERT(m_Store.m_TrackedBlobKeys); m_AddedReferences = std::move(*m_Store.m_TrackedBlobKeys); diff --git a/src/zenstore/cache/structuredcachestore.cpp b/src/zenstore/cache/structuredcachestore.cpp index 07e72ebb5..a164f66c3 100644 --- a/src/zenstore/cache/structuredcachestore.cpp +++ b/src/zenstore/cache/structuredcachestore.cpp @@ -1073,6 +1073,7 @@ ZenCacheStore::LockState(GcCtx& Ctx) ZEN_TRACE_CPU("CacheStore::LockState"); auto Log = [&Ctx]() { return Ctx.Logger; }; + ZEN_UNUSED(Log); std::vector<RwLock::SharedLockScope> Locks; Locks.emplace_back(RwLock::SharedLockScope(m_NamespacesLock)); diff --git a/src/zenstore/filecas.cpp b/src/zenstore/filecas.cpp index a895b81e0..13d881e0c 100644 --- a/src/zenstore/filecas.cpp +++ b/src/zenstore/filecas.cpp @@ -449,7 +449,7 @@ FileCasStrategy::InsertChunk(IoBuffer Chunk, const IoHash& ChunkHash, CasStore:: ChunkRemain -= ByteCount; } } - catch (const std::exception Ex) + catch (const std::exception&) { PayloadFile.Close(); std::error_code DummyEc; diff --git a/src/zenstore/projectstore.cpp b/src/zenstore/projectstore.cpp index 8ae74c8cf..7570b8513 100644 --- a/src/zenstore/projectstore.cpp +++ b/src/zenstore/projectstore.cpp @@ -4709,6 +4709,7 @@ ProjectStore::GetChunkInfo(LoggerRef InLog, Project& Project, Oplog& Oplog, cons using namespace std::literals; auto Log = [&InLog]() { return InLog; }; + ZEN_UNUSED(Log); IoBuffer Chunk = Oplog.FindChunk(Project.RootDir, ChunkId, nullptr); if (!Chunk) @@ -4869,6 +4870,7 @@ ProjectStore::GetChunkRange(LoggerRef InLog, ZEN_TRACE_CPU("ProjectStore::GetChunkRange"); auto Log = [&InLog]() { return InLog; }; + ZEN_UNUSED(Log); uint64_t OldTag = OptionalInOutModificationTag == nullptr ? 0 : *OptionalInOutModificationTag; IoBuffer Chunk = Oplog.FindChunk(Project.RootDir, ChunkId, OptionalInOutModificationTag); @@ -6066,6 +6068,7 @@ ProjectStore::LockState(GcCtx& Ctx) ZEN_TRACE_CPU("Store::LockState"); auto Log = [&Ctx]() { return Ctx.Logger; }; + ZEN_UNUSED(Log); std::vector<RwLock::SharedLockScope> Locks; Locks.emplace_back(RwLock::SharedLockScope(m_ProjectsLock)); @@ -6198,6 +6201,7 @@ ProjectStore::CreateReferenceValidators(GcCtx& Ctx) } auto Log = [&Ctx]() { return Ctx.Logger; }; + ZEN_UNUSED(Log); DiscoverProjects(); @@ -6408,6 +6412,7 @@ TEST_CASE("project.opkeys") Cbo << "key"sv << LongKey.substr(0, i); const Oid KeyId = ComputeOpKey(Cbo.Save()); + ZEN_UNUSED(KeyId); } { diff --git a/src/zenstore/workspaces.cpp b/src/zenstore/workspaces.cpp index c2391588c..f0f975af4 100644 --- a/src/zenstore/workspaces.cpp +++ b/src/zenstore/workspaces.cpp @@ -332,6 +332,7 @@ ScanFolder(LoggerRef InLog, const std::filesystem::path& Path, WorkerThreadPool& ZEN_TRACE_CPU("workspaces::ScanFolderImpl"); auto Log = [&InLog]() { return InLog; }; + ZEN_UNUSED(Log); FolderScanner Data(InLog, WorkerPool, Path); Data.Traverse(); @@ -353,6 +354,7 @@ WorkspaceShare::GetAbsolutePath(const std::filesystem::path& RootPath, const Oid const FolderStructure::FileEntry* Entry = m_FolderStructure->FindEntry(Id); if (Entry == nullptr) { + OutSize = 0; return {}; } OutSize = Entry->Size; @@ -589,7 +591,7 @@ Workspaces::GetWorkspaceShareChunks(const Oid& WorkspaceId, auto GetOne = [this](const std::filesystem::path& RootPath, WorkspaceShare& Share, const ChunkRequest& Request) -> IoBuffer { uint64_t Size; - std::filesystem::path Path = Share.GetAbsolutePath(RootPath, Request.ChunkId, Size); + std::filesystem::path Path = Share.GetAbsolutePath(RootPath, Request.ChunkId, /* out */ Size); if (!Path.empty()) { uint64_t RequestedOffset = Request.Offset; @@ -1042,6 +1044,7 @@ Workspaces::WorkspaceConfiguration Workspaces::FindWorkspace(const LoggerRef& InLog, const std::filesystem::path& WorkspaceStatePath, const Oid& WorkspaceId) { auto Log = [&InLog]() { return InLog; }; + ZEN_UNUSED(Log); std::string Error; std::vector<WorkspaceConfiguration> Workspaces = ReadConfig(InLog, WorkspaceStatePath, Error); @@ -1067,6 +1070,7 @@ Workspaces::FindWorkspace(const LoggerRef& InLog, const std::filesystem::path& WorkspaceRoot) { auto Log = [&InLog]() { return InLog; }; + ZEN_UNUSED(Log); std::string Error; std::vector<WorkspaceConfiguration> Workspaces = ReadConfig(InLog, WorkspaceStatePath, Error); diff --git a/src/zenutil/environmentoptions.cpp b/src/zenutil/environmentoptions.cpp index 1b7ce8029..ee40086c1 100644 --- a/src/zenutil/environmentoptions.cpp +++ b/src/zenutil/environmentoptions.cpp @@ -72,7 +72,7 @@ EnvironmentOptions::Parse(const cxxopts::ParseResult& CmdLineResult) const Option& Opt = It.second; if (CmdLineResult.count(Opt.CommandLineOptionName) == 0) { - std::string EnvValue = GetEnvVariable(It.first); + std::string EnvValue = GetEnvVariable(EnvName); if (!EnvValue.empty()) { Opt.Value->Parse(EnvValue); |