From 3fdfee33a9845c75d0e0fd01b799dd9d26b7d83e Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 6 Jun 2023 23:32:23 -0500 Subject: [PATCH] [ox] Fix remaining implicit conversion issues --- deps/ox/src/ox/clargs/CMakeLists.txt | 5 ++ deps/ox/src/ox/clargs/clargs.cpp | 8 +-- deps/ox/src/ox/clargs/clargs.hpp | 6 +- deps/ox/src/ox/claw/CMakeLists.txt | 5 ++ deps/ox/src/ox/claw/read.cpp | 8 +-- deps/ox/src/ox/claw/test/tests.cpp | 4 +- deps/ox/src/ox/claw/write.hpp | 4 +- deps/ox/src/ox/event/CMakeLists.txt | 1 + deps/ox/src/ox/fs/CMakeLists.txt | 4 ++ .../src/ox/fs/filestore/filestoretemplate.hpp | 8 +-- deps/ox/src/ox/fs/filesystem/directory.hpp | 4 +- deps/ox/src/ox/fs/filesystem/filesystem.cpp | 6 +- deps/ox/src/ox/fs/filesystem/filesystem.hpp | 18 +++--- .../ox/src/ox/fs/filesystem/passthroughfs.cpp | 16 +++--- .../ox/src/ox/fs/filesystem/passthroughfs.hpp | 4 +- deps/ox/src/ox/fs/filesystem/pathiterator.cpp | 26 ++++----- deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp | 6 +- deps/ox/src/ox/fs/ptrarith/ptr.hpp | 2 +- deps/ox/src/ox/fs/tool.cpp | 4 +- deps/ox/src/ox/logconn/CMakeLists.txt | 4 ++ deps/ox/src/ox/logconn/logconn.cpp | 4 +- deps/ox/src/ox/mc/CMakeLists.txt | 1 + deps/ox/src/ox/mc/presenceindicator.hpp | 8 ++- deps/ox/src/ox/mc/read.hpp | 46 +++++++-------- deps/ox/src/ox/mc/write.hpp | 12 ++-- deps/ox/src/ox/model/CMakeLists.txt | 5 ++ deps/ox/src/ox/model/descwrite.hpp | 6 +- deps/ox/src/ox/model/fieldcounter.hpp | 4 +- deps/ox/src/ox/model/modelhandleradaptor.hpp | 9 ++- deps/ox/src/ox/model/modelops.hpp | 6 +- deps/ox/src/ox/model/modelvalue.hpp | 6 +- deps/ox/src/ox/model/typenamecatcher.hpp | 6 +- deps/ox/src/ox/model/types.hpp | 2 +- deps/ox/src/ox/model/walk.hpp | 2 +- deps/ox/src/ox/oc/CMakeLists.txt | 1 + deps/ox/src/ox/oc/read.hpp | 4 +- deps/ox/src/ox/oc/test/tests.cpp | 6 +- deps/ox/src/ox/oc/write.hpp | 6 +- deps/ox/src/ox/preloader/CMakeLists.txt | 5 ++ deps/ox/src/ox/preloader/alignmentcatcher.hpp | 4 +- deps/ox/src/ox/preloader/preloader.hpp | 29 ++++++---- deps/ox/src/ox/preloader/sizecatcher.hpp | 4 +- deps/ox/src/ox/preloader/unionsizecatcher.hpp | 4 +- deps/ox/src/ox/std/CMakeLists.txt | 1 + deps/ox/src/ox/std/byteswap.hpp | 57 +++++++------------ deps/ox/src/ox/std/error.hpp | 6 +- deps/ox/src/ox/std/hashmap.hpp | 9 +-- deps/ox/src/ox/std/stringview.hpp | 2 +- deps/ox/src/ox/std/strops.hpp | 9 +-- deps/ox/src/ox/std/uuid.hpp | 2 +- 50 files changed, 218 insertions(+), 191 deletions(-) diff --git a/deps/ox/src/ox/clargs/CMakeLists.txt b/deps/ox/src/ox/clargs/CMakeLists.txt index a8c4d66f..e2899f95 100644 --- a/deps/ox/src/ox/clargs/CMakeLists.txt +++ b/deps/ox/src/ox/clargs/CMakeLists.txt @@ -12,6 +12,11 @@ set_property( POSITION_INDEPENDENT_CODE ON ) +if(NOT MSVC) + target_compile_options(OxClArgs PRIVATE -Wsign-conversion) + target_compile_options(OxClArgs PRIVATE -Wconversion) +endif() + target_link_libraries( OxClArgs PUBLIC OxStd diff --git a/deps/ox/src/ox/clargs/clargs.cpp b/deps/ox/src/ox/clargs/clargs.cpp index 0cbb8405..348a9897 100644 --- a/deps/ox/src/ox/clargs/clargs.cpp +++ b/deps/ox/src/ox/clargs/clargs.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -12,7 +12,7 @@ namespace ox { ClArgs::ClArgs(int argc, const char **args) noexcept { - for (int i = 0; i < argc; i++) { + for (auto i = 0u; i < static_cast(argc); ++i) { String arg = args[i]; if (arg[0] == '-') { while (arg[0] == '-' && arg.len()) { @@ -20,7 +20,7 @@ ClArgs::ClArgs(int argc, const char **args) noexcept { } m_bools[arg] = true; // parse additional arguments - if (i < argc && args[i + 1]) { + if (i < static_cast(argc) && args[i + 1]) { String val = args[i + 1]; if (val.len() && val[i] != '-') { if (val == "false") { @@ -30,7 +30,7 @@ ClArgs::ClArgs(int argc, const char **args) noexcept { if (auto r = ox_atoi(val.c_str()); r.error == 0) { m_ints[arg] = r.value; } - i++; + ++i; } } } diff --git a/deps/ox/src/ox/clargs/clargs.hpp b/deps/ox/src/ox/clargs/clargs.hpp index 23e43e15..02943564 100644 --- a/deps/ox/src/ox/clargs/clargs.hpp +++ b/deps/ox/src/ox/clargs/clargs.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -26,13 +26,15 @@ class ClArgs { bool getBool(ox::CRStringView arg, bool defaultValue) const noexcept; [[nodiscard]] - String getString(ox::CRStringView argName, const char *defaultArg) const noexcept; + String getString(ox::CRStringView argName, const char *defaultValue) const noexcept; [[nodiscard]] int getInt(ox::CRStringView arg, int defaultValue) const noexcept; + [[nodiscard]] Result getBool(ox::CRStringView arg) const noexcept; + [[nodiscard]] Result getString(ox::CRStringView argName) const noexcept; Result getInt(ox::CRStringView arg) const noexcept; diff --git a/deps/ox/src/ox/claw/CMakeLists.txt b/deps/ox/src/ox/claw/CMakeLists.txt index 8d6c261b..099971d5 100644 --- a/deps/ox/src/ox/claw/CMakeLists.txt +++ b/deps/ox/src/ox/claw/CMakeLists.txt @@ -6,6 +6,11 @@ add_library( ) +if(NOT MSVC) + target_compile_options(OxClaw PRIVATE -Wsign-conversion) + target_compile_options(OxClaw PRIVATE -Wconversion) +endif() + target_link_libraries( OxClaw PUBLIC OxMetalClaw diff --git a/deps/ox/src/ox/claw/read.cpp b/deps/ox/src/ox/claw/read.cpp index 21cf09b1..1542fc2c 100644 --- a/deps/ox/src/ox/claw/read.cpp +++ b/deps/ox/src/ox/claw/read.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -17,7 +17,7 @@ Result readClawHeader(const char *buff, std::size_t buffLen) noexcep if (!s1End) { return OxError(1, "Could not read Claw header"); } - const auto s1Size = s1End - buff; + const auto s1Size = static_cast(s1End - buff); const String fmt(buff, s1Size); buff += s1Size + 1; buffLen -= s1Size + 1; @@ -26,7 +26,7 @@ Result readClawHeader(const char *buff, std::size_t buffLen) noexcep if (!s2End) { return OxError(2, "Could not read Claw header"); } - const auto s2Size = s2End - buff; + const auto s2Size = static_cast(s2End - buff); const String typeName(buff, s2Size); buff += s2Size + 1; buffLen -= s2Size + 1; @@ -35,7 +35,7 @@ Result readClawHeader(const char *buff, std::size_t buffLen) noexcep if (!s3End) { return OxError(3, "Could not read Claw header"); } - const auto s3Size = s3End - buff; + const auto s3Size = static_cast(s3End - buff); const String versionStr(buff, s3Size); buff += s3Size + 1; buffLen -= s3Size + 1; diff --git a/deps/ox/src/ox/claw/test/tests.cpp b/deps/ox/src/ox/claw/test/tests.cpp index a3739140..af5b1151 100644 --- a/deps/ox/src/ox/claw/test/tests.cpp +++ b/deps/ox/src/ox/claw/test/tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -198,7 +198,7 @@ int main(int argc, const char **args) { if (argc > 0) { auto testName = args[1]; if (tests.find(testName) != tests.end()) { - retval = tests[testName](); + retval = static_cast(tests[testName]()); } else { retval = 1; } diff --git a/deps/ox/src/ox/claw/write.hpp b/deps/ox/src/ox/claw/write.hpp index 85eab300..a1dca232 100644 --- a/deps/ox/src/ox/claw/write.hpp +++ b/deps/ox/src/ox/claw/write.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -27,7 +27,7 @@ struct TypeInfoCatcher { int version = 0; template - constexpr void setTypeInfo(const char *name = T::TypeName, int v = T::TypeVersion, const Vector& = {}, int = 0) noexcept { + constexpr void setTypeInfo(const char *name = T::TypeName, int v = T::TypeVersion, const Vector& = {}, std::size_t = 0) noexcept { this->name = name; this->version = v; } diff --git a/deps/ox/src/ox/event/CMakeLists.txt b/deps/ox/src/ox/event/CMakeLists.txt index c7c3c69d..8f1933a2 100644 --- a/deps/ox/src/ox/event/CMakeLists.txt +++ b/deps/ox/src/ox/event/CMakeLists.txt @@ -5,6 +5,7 @@ add_library( if(NOT MSVC) target_compile_options(OxEvent PRIVATE -Wsign-conversion) + target_compile_options(OxEvent PRIVATE -Wconversion) endif() if(NOT OX_BARE_METAL) diff --git a/deps/ox/src/ox/fs/CMakeLists.txt b/deps/ox/src/ox/fs/CMakeLists.txt index cf9a1673..dae9621e 100644 --- a/deps/ox/src/ox/fs/CMakeLists.txt +++ b/deps/ox/src/ox/fs/CMakeLists.txt @@ -11,6 +11,10 @@ add_library( filesystem/passthroughfs.cpp ) +if(NOT MSVC) + target_compile_options(OxFS PRIVATE -Wsign-conversion) +endif() + if(NOT OX_BARE_METAL) if(NOT APPLE AND NOT MSVC) target_link_libraries( diff --git a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp index 398f3af4..0aa4d49b 100644 --- a/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp +++ b/deps/ox/src/ox/fs/filestore/filestoretemplate.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -227,14 +227,14 @@ Error FileStoreTemplate::setSize(std::size_t size) { template Error FileStoreTemplate::incLinks(uint64_t id) { oxRequireM(item, find(static_cast(id)).validate()); - item->links++; + ++item->links; return OxError(0); } template Error FileStoreTemplate::decLinks(uint64_t id) { oxRequireM(item, find(static_cast(id)).validate()); - item->links--; + --item->links; if (item->links == 0) { oxReturnError(remove(item)); } @@ -421,7 +421,7 @@ ptrarith::Ptr FileStoreTemplate::read(uint64_t id) template Error FileStoreTemplate::resize() { oxReturnError(compact()); - const auto newSize = size() - available(); + const auto newSize = static_cast(size() - available()); oxTracef("ox::fs::FileStoreTemplate::resize", "resize to: {}", newSize); oxReturnError(m_buffer->setSize(newSize)); oxTracef("ox::fs::FileStoreTemplate::resize", "resized to: {}", m_buffer->size()); diff --git a/deps/ox/src/ox/fs/filesystem/directory.hpp b/deps/ox/src/ox/fs/filesystem/directory.hpp index 2ff3c823..1e5aa185 100644 --- a/deps/ox/src/ox/fs/filesystem/directory.hpp +++ b/deps/ox/src/ox/fs/filesystem/directory.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -69,7 +69,7 @@ struct OX_PACKED DirectoryEntry { [[nodiscard]] InodeId_t size() const { - return fullSize() - sizeof(*this); + return fullSize() - static_cast(sizeof(*this)); } void setSize(std::size_t) { diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.cpp b/deps/ox/src/ox/fs/filesystem/filesystem.cpp index 7772b1c5..3558ad42 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.cpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -39,14 +39,14 @@ Error FileSystem::read(const FileAddress &addr, void *buffer, std::size_t size) Result FileSystem::read(const FileAddress &addr) noexcept { oxRequire(s, stat(addr)); - Buffer buff(s.size); + Buffer buff(static_cast(s.size)); oxReturnError(read(addr, buff.data(), buff.size())); return buff; } Result FileSystem::read(CRStringView path) noexcept { oxRequire(s, statPath(path)); - Buffer buff(s.size); + Buffer buff(static_cast(s.size)); oxReturnError(readFilePath(path, buff.data(), buff.size())); return buff; } diff --git a/deps/ox/src/ox/fs/filesystem/filesystem.hpp b/deps/ox/src/ox/fs/filesystem/filesystem.hpp index a9dbeb82..868a8aeb 100644 --- a/deps/ox/src/ox/fs/filesystem/filesystem.hpp +++ b/deps/ox/src/ox/fs/filesystem/filesystem.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -240,7 +240,7 @@ FileSystemTemplate::FileSystemTemplate(FileStore fs) noexc template FileSystemTemplate::FileSystemTemplate(void *buffer, uint64_t bufferSize, void(*freeBuffer)(char*)) noexcept: - m_fs(buffer, bufferSize), + m_fs(buffer, static_cast(bufferSize)), m_freeBuffer(freeBuffer) { } @@ -253,8 +253,8 @@ FileSystemTemplate::~FileSystemTemplate() noexcept { template Error FileSystemTemplate::format(void *buff, uint64_t buffSize) noexcept { - oxReturnError(FileStore::format(buff, buffSize)); - FileStore fs(buff, buffSize); + oxReturnError(FileStore::format(buff, static_cast(buffSize))); + FileStore fs(buff, static_cast(buffSize)); constexpr auto rootDirInode = MaxValue / 2; Directory rootDir(fs, rootDirInode); @@ -298,7 +298,7 @@ Error FileSystemTemplate::readFilePath(CRStringView path, if (s.size > buffSize) { return OxError(1, "Buffer to small to load file"); } - return readFileInodeRange(s.inode, 0, s.size, buffer, &buffSize); + return readFileInodeRange(s.inode, 0, static_cast(s.size), buffer, &buffSize); } template @@ -315,7 +315,7 @@ Error FileSystemTemplate::readFileInode(uint64_t inode, vo if (s.size > buffSize) { return OxError(1, "Buffer to small to load file"); } - return readFileInodeRange(inode, 0, s.size, buffer, &buffSize); + return readFileInodeRange(inode, 0, static_cast(s.size), buffer, &buffSize); } template @@ -377,7 +377,7 @@ Error FileSystemTemplate::resize() noexcept { template Error FileSystemTemplate::resize(uint64_t size, void *buffer) noexcept { - oxReturnError(m_fs.resize(size, buffer)); + oxReturnError(m_fs.resize(static_cast(size), buffer)); return OxError(0); } @@ -396,7 +396,7 @@ Error FileSystemTemplate::writeFilePath(CRStringView path, template Error FileSystemTemplate::writeFileInode(uint64_t inode, const void *buffer, uint64_t size, FileType fileType) noexcept { - return m_fs.write(inode, buffer, size, static_cast(fileType)); + return m_fs.write(inode, buffer, static_cast(size), static_cast(fileType)); } template @@ -418,7 +418,7 @@ Result FileSystemTemplate::statPath(CRStringView template uint64_t FileSystemTemplate::spaceNeeded(uint64_t size) const noexcept { - return m_fs.spaceNeeded(size); + return m_fs.spaceNeeded(static_cast(size)); } template diff --git a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp index be04f6d6..bd088481 100644 --- a/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp +++ b/deps/ox/src/ox/fs/filesystem/passthroughfs.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -39,7 +39,7 @@ Error PassThroughFS::mkdir(CRStringView path, bool recursive) noexcept { success = true; } else { success = std::filesystem::create_directories(p, ec); - oxReturnError(OxError(ec.value(), "PassThroughFS: mkdir failed")); + oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: mkdir failed")); } } else { std::error_code ec; @@ -48,7 +48,7 @@ Error PassThroughFS::mkdir(CRStringView path, bool recursive) noexcept { success = true; } else { success = std::filesystem::create_directory(p, ec); - oxReturnError(OxError(ec.value(), "PassThroughFS: mkdir failed")); + oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: mkdir failed")); } } return OxError(success ? 0 : 1); @@ -67,7 +67,7 @@ Result> PassThroughFS::ls(CRStringView dir) const noexcept { Vector out; std::error_code ec; const auto di = std::filesystem::directory_iterator(m_path / stripSlash(dir), ec); - oxReturnError(OxError(ec.value(), "PassThroughFS: ls failed")); + oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: ls failed")); for (const auto &p : di) { const auto u8p = p.path().filename().u8string(); out.emplace_back(reinterpret_cast(u8p.c_str())); @@ -102,7 +102,7 @@ Result PassThroughFS::statPath(CRStringView path) const noexcept { const uint64_t size = type == FileType::Directory ? 0 : std::filesystem::file_size(p, ec); oxTracef("ox::fs::PassThroughFS::statInode", "{} {}", ec.message(), path); oxTracef("ox::fs::PassThroughFS::statInode::size", "{} {}", path, size); - oxReturnError(OxError(ec.value(), "PassThroughFS: stat failed")); + oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: stat failed")); return FileStat{0, 0, size, type}; } @@ -113,14 +113,14 @@ uint64_t PassThroughFS::spaceNeeded(uint64_t size) const noexcept { Result PassThroughFS::available() const noexcept { std::error_code ec; const auto s = std::filesystem::space(m_path, ec); - oxReturnError(OxError(ec.value(), "PassThroughFS: could not get FS size")); + oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: could not get FS size")); return s.available; } Result PassThroughFS::size() const noexcept { std::error_code ec; const auto s = std::filesystem::space(m_path, ec); - oxReturnError(OxError(ec.value(), "PassThroughFS: could not get FS size")); + oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: could not get FS size")); return s.capacity; } @@ -144,7 +144,7 @@ bool PassThroughFS::valid() const noexcept { Error PassThroughFS::readFilePath(CRStringView path, void *buffer, std::size_t buffSize) noexcept { try { std::ifstream file((m_path / stripSlash(path)), std::ios::binary | std::ios::ate); - const std::size_t size = file.tellg(); + const std::size_t size = static_cast(file.tellg()); file.seekg(0, std::ios::beg); if (size > buffSize) { oxTracef("ox::fs::PassThroughFS::read::error", "Read failed: Buffer too small: {}", path); diff --git a/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp b/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp index f46a2178..c7d2a17a 100644 --- a/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp +++ b/deps/ox/src/ox/fs/filesystem/passthroughfs.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -92,7 +92,7 @@ template Error PassThroughFS::ls(CRStringView dir, F cb) const noexcept { std::error_code ec; const auto di = std::filesystem::directory_iterator(m_path / stripSlash(dir), ec); - oxReturnError(OxError(ec.value(), "PassThroughFS: ls failed")); + oxReturnError(OxError(static_cast(ec.value()), "PassThroughFS: ls failed")); for (auto &p : di) { oxReturnError(cb(p.path().filename().c_str(), 0)); } diff --git a/deps/ox/src/ox/fs/filesystem/pathiterator.cpp b/deps/ox/src/ox/fs/filesystem/pathiterator.cpp index e3b5a39d..1e40f815 100644 --- a/deps/ox/src/ox/fs/filesystem/pathiterator.cpp +++ b/deps/ox/src/ox/fs/filesystem/pathiterator.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -29,8 +29,8 @@ PathIterator::PathIterator(CRStringView path): PathIterator(path.data(), path.by * @return 0 if no error */ Error PathIterator::dirPath(char *out, std::size_t outSize) { - int idx = ox_lastIndexOf(m_path, '/', m_maxSize); - std::size_t size = idx + 1; + const auto idx = ox_lastIndexOf(m_path, '/', m_maxSize); + const auto size = static_cast(idx + 1); if (idx >= 0 && size < outSize) { ox_memcpy(out, m_path, size); out[size] = 0; @@ -47,7 +47,7 @@ Error PathIterator::fileName(char *out, std::size_t outSize) { auto idx = ox_lastIndexOf(m_path, '/', m_maxSize); if (idx >= 0) { idx++; // pass up the preceding / - std::size_t fileNameSize = ox_strlen(&m_path[idx]); + std::size_t fileNameSize = static_cast(ox_strlen(&m_path[idx])); if (fileNameSize < outSize) { ox_memcpy(out, &m_path[idx], fileNameSize); out[fileNameSize] = 0; @@ -81,7 +81,7 @@ Error PathIterator::get(char *pathOut, std::size_t pathOutSize) { if (!substr) { substr = ox_strchr(&m_path[start], 0, m_maxSize - start); } - std::size_t end = substr - m_path; + const auto end = static_cast(substr - m_path); size = end - start; // cannot fit the output in the output parameter if (size >= pathOutSize || size == 0) { @@ -105,14 +105,14 @@ Error PathIterator::next(char *pathOut, std::size_t pathOutSize) { if (m_path[m_iterator] == '/') { m_iterator++; } - std::size_t start = m_iterator; + const auto start = m_iterator; // end is at the next / const char *substr = ox_strchr(&m_path[start], '/', m_maxSize - start); // correct end if it is invalid, which happens if there is no next / if (!substr) { substr = ox_strchr(&m_path[start], 0, m_maxSize - start); } - std::size_t end = substr - m_path; + const auto end = static_cast(substr - m_path); size = end - start; // cannot fit the output in the output parameter if (size >= pathOutSize) { @@ -152,14 +152,14 @@ Result PathIterator::nextSize() const { if (m_path[it] == '/') { it++; } - std::size_t start = it; + const auto start = it; // end is at the next / const char *substr = ox_strchr(&m_path[start], '/', m_maxSize - start); // correct end if it is invalid, which happens if there is no next / if (!substr) { substr = ox_strchr(&m_path[start], 0, m_maxSize - start); } - std::size_t end = substr - m_path; + const auto end = static_cast(substr - m_path); size = end - start; } it += size; @@ -179,7 +179,7 @@ bool PathIterator::hasNext() const { if (!substr) { substr = ox_strchr(&m_path[start], 0, m_maxSize - start); } - std::size_t end = substr - m_path; + const auto end = static_cast(substr - m_path); size = end - start; } return size > 0; @@ -196,18 +196,18 @@ PathIterator PathIterator::next() const { if (m_path[iterator] == '/') { iterator++; } - std::size_t start = iterator; + const auto start = iterator; // end is at the next / const char *substr = ox_strchr(&m_path[start], '/', m_maxSize - start); // correct end if it is invalid, which happens if there is no next / if (!substr) { substr = ox_strchr(&m_path[start], 0, m_maxSize - start); } - std::size_t end = substr - m_path; + const auto end = static_cast(substr - m_path); size = end - start; } iterator += size; - return PathIterator(m_path, m_maxSize, iterator + 1); + return {m_path, m_maxSize, iterator + 1}; } const char *PathIterator::fullPath() const { diff --git a/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp b/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp index 92989249..1379ebab 100644 --- a/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp +++ b/deps/ox/src/ox/fs/ptrarith/nodebuffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -174,7 +174,7 @@ template NodeBuffer::NodeBuffer(std::size_t size) noexcept { m_header.size = static_cast(size); ox_memset(this + 1, 0, size - sizeof(*this)); - oxTrace("ox::NodeBuffer::constructor") << m_header.firstItem; + oxTracef("ox::NodeBuffer::constructor", "{}", m_header.firstItem.get()); } template @@ -191,7 +191,7 @@ const typename NodeBuffer::Iterator NodeBuffer::iter template typename NodeBuffer::Iterator NodeBuffer::iterator() noexcept { - oxTrace("ox::ptrarith::NodeBuffer::iterator::size") << m_header.size; + oxTracef("ox::ptrarith::NodeBuffer::iterator::size", "{}", m_header.size.get()); return Iterator(this, firstItem()); } diff --git a/deps/ox/src/ox/fs/ptrarith/ptr.hpp b/deps/ox/src/ox/fs/ptrarith/ptr.hpp index 8bbb0008..cb09d9e1 100644 --- a/deps/ox/src/ox/fs/ptrarith/ptr.hpp +++ b/deps/ox/src/ox/fs/ptrarith/ptr.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/deps/ox/src/ox/fs/tool.cpp b/deps/ox/src/ox/fs/tool.cpp index 108f1d00..61c45f45 100644 --- a/deps/ox/src/ox/fs/tool.cpp +++ b/deps/ox/src/ox/fs/tool.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -26,7 +26,7 @@ static ox::Result loadFsBuff(const char *path) noexcept { const auto size = static_cast(file.tellg()); file.seekg(0, std::ios::beg); const auto buff = new char[size]; - file.read(buff, size); + file.read(buff, static_cast(size)); return Buff{buff, size}; } catch (const std::ios_base::failure &e) { oxErrorf("Could not read OxFS file: {}", e.what()); diff --git a/deps/ox/src/ox/logconn/CMakeLists.txt b/deps/ox/src/ox/logconn/CMakeLists.txt index 9dfa49d9..a416a00d 100644 --- a/deps/ox/src/ox/logconn/CMakeLists.txt +++ b/deps/ox/src/ox/logconn/CMakeLists.txt @@ -12,6 +12,10 @@ set_property( POSITION_INDEPENDENT_CODE ON ) +if(NOT MSVC) + target_compile_options(OxLogConn PRIVATE -Wsign-conversion) +endif() + target_link_libraries( OxLogConn PUBLIC OxStd diff --git a/deps/ox/src/ox/logconn/logconn.cpp b/deps/ox/src/ox/logconn/logconn.cpp index 0ff86b0d..78390dc5 100644 --- a/deps/ox/src/ox/logconn/logconn.cpp +++ b/deps/ox/src/ox/logconn/logconn.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -40,7 +40,7 @@ ox::Error LoggerConn::initConn(const char *appName) noexcept { addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); addr.sin_port = htons(5590); m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - oxReturnError(OxError(connect(m_socket, reinterpret_cast(&addr), sizeof(addr)))); + oxReturnError(OxError(static_cast(connect(m_socket, reinterpret_cast(&addr), sizeof(addr))))); return sendInit({.appName = appName}); } diff --git a/deps/ox/src/ox/mc/CMakeLists.txt b/deps/ox/src/ox/mc/CMakeLists.txt index 6a67be54..578028a2 100644 --- a/deps/ox/src/ox/mc/CMakeLists.txt +++ b/deps/ox/src/ox/mc/CMakeLists.txt @@ -7,6 +7,7 @@ add_library( if(NOT MSVC) target_compile_options(OxMetalClaw PRIVATE -Wsign-conversion) + target_compile_options(OxMetalClaw PRIVATE -Wconversion) endif() target_link_libraries( diff --git a/deps/ox/src/ox/mc/presenceindicator.hpp b/deps/ox/src/ox/mc/presenceindicator.hpp index 5702a9a7..e64e8fe0 100644 --- a/deps/ox/src/ox/mc/presenceindicator.hpp +++ b/deps/ox/src/ox/mc/presenceindicator.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -11,6 +11,8 @@ #include #include +#include "err.hpp" + namespace ox { template @@ -83,9 +85,9 @@ constexpr Error FieldBitmap::set(std::size_t i, bool on) noexcept { if (on) { m_map[i / 8] |= 1 << (i % 8); } else { - m_map[i / 8] &= ~(1 << (i % 8)); + m_map[i / 8] &= ~static_cast(1 << (i % 8)); } - return OxError(0); + return {}; } else { return OxError(MC_PRESENCEMASKOUTBOUNDS); } diff --git a/deps/ox/src/ox/mc/read.hpp b/deps/ox/src/ox/mc/read.hpp index 3b223477..27165cfb 100644 --- a/deps/ox/src/ox/mc/read.hpp +++ b/deps/ox/src/ox/mc/read.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -31,8 +31,8 @@ class MetalClawReaderTemplate { private: FieldBitmapReader m_fieldPresence; - int m_fields = 0; - int m_field = 0; + std::size_t m_fields = 0; + std::size_t m_field = 0; int m_unionIdx = -1; std::size_t m_buffIt = 0; std::size_t m_buffLen = 0; @@ -100,7 +100,7 @@ class MetalClawReaderTemplate { template constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion, - const Vector& = {}, int fields = ModelFieldCount_v) noexcept; + const Vector& = {}, std::size_t fields = ModelFieldCount_v) noexcept; /** * Returns a MetalClawReader to parse a child object. @@ -200,7 +200,7 @@ constexpr Error MetalClawReaderTemplate::field(const char*, uint64 template constexpr Error MetalClawReaderTemplate::field(const char*, bool *val) noexcept { - if (m_unionIdx == -1 || m_unionIdx == m_field) { + if (m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) { auto valErr = m_fieldPresence.get(static_cast(m_field)); *val = valErr.value; oxReturnError(valErr.error); @@ -212,7 +212,7 @@ constexpr Error MetalClawReaderTemplate::field(const char*, bool * // array handler template constexpr Error MetalClawReaderTemplate::field(const char *name, auto *val, std::size_t valLen) noexcept { - if (m_unionIdx == -1 || m_unionIdx == m_field) { + if (m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) { if (m_fieldPresence.get(static_cast(m_field))) { // read the length if (m_buffIt >= m_buffLen) { @@ -225,7 +225,7 @@ constexpr Error MetalClawReaderTemplate::field(const char *name, a if (valLen >= len) { auto reader = child(""); auto handler = HandlerMaker(&reader); - handler.setTypeInfo("List", 0, {}, static_cast(len)); + handler.setTypeInfo("List", 0, {}, static_cast(len)); for (std::size_t i = 0; i < len; ++i) { oxReturnError(handler.field("", &val[i])); } @@ -242,7 +242,7 @@ constexpr Error MetalClawReaderTemplate::field(const char *name, a template template constexpr Error MetalClawReaderTemplate::field(const char*, HashMap *val) noexcept { - if (m_unionIdx == -1 || m_unionIdx == m_field) { + if (m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) { if (m_fieldPresence.get(static_cast(m_field))) { // read the length if (m_buffIt >= m_buffLen) { @@ -254,12 +254,12 @@ constexpr Error MetalClawReaderTemplate::field(const char*, HashMa // read the list auto reader = child(""); auto handler = HandlerMaker(&reader); - handler.setTypeInfo("List", 0, {}, static_cast(len)); + handler.setTypeInfo("List", 0, {}, static_cast(len)); for (std::size_t i = 0; i < len; ++i) { const auto keyLen = handler.stringLength(nullptr); auto wkey = ox_malloca(keyLen + 1, char, 0); auto wkeyPtr = wkey.get(); - oxReturnError(handler.fieldCString("", &wkeyPtr, static_cast(keyLen + 1))); + oxReturnError(handler.fieldCString("", &wkeyPtr, keyLen + 1)); oxReturnError(handler.field("", &val->operator[](wkey.get()))); } } @@ -272,7 +272,7 @@ template template constexpr Error MetalClawReaderTemplate::field(const char *name, T *val) noexcept { if constexpr(isVector_v) { - if (m_unionIdx == -1 || m_unionIdx == m_field) { + if (m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) { // set size of val if the field is present, don't worry about it if not if (m_fieldPresence.get(static_cast(m_field))) { oxRequire(len, arrayLength(name, false)); @@ -283,7 +283,7 @@ constexpr Error MetalClawReaderTemplate::field(const char *name, T ++m_field; return {}; } else if constexpr(isArray_v) { - if (m_unionIdx == -1 || m_unionIdx == m_field) { + if (m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) { // set size of val if the field is present, don't worry about it if not if (m_fieldPresence.get(static_cast(m_field))) { oxRequire(len, arrayLength(name, false)); @@ -296,7 +296,7 @@ constexpr Error MetalClawReaderTemplate::field(const char *name, T ++m_field; return {}; } else { - if ((m_unionIdx == -1 || m_unionIdx == m_field) && val) { + if ((m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) && val) { if (m_fieldPresence.get(static_cast(m_field))) { auto reader = child(""); auto handler = HandlerMaker(&reader); @@ -311,7 +311,7 @@ constexpr Error MetalClawReaderTemplate::field(const char *name, T template template constexpr Error MetalClawReaderTemplate::field(const char*, UnionView val) noexcept { - if ((m_unionIdx == -1 || m_unionIdx == m_field) && val.get()) { + if ((m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) && val.get()) { if (m_fieldPresence.get(static_cast(m_field))) { auto reader = child("", val.idx()); auto handler = HandlerMaker(&reader); @@ -325,7 +325,7 @@ constexpr Error MetalClawReaderTemplate::field(const char*, UnionV template template constexpr Error MetalClawReaderTemplate::field(const char*, BasicString *val) noexcept { - if (m_unionIdx == -1 || m_unionIdx == m_field) { + if (m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) { if (m_fieldPresence.get(static_cast(m_field))) { // read the length if (m_buffIt >= m_buffLen) { @@ -419,7 +419,7 @@ constexpr Error MetalClawReaderTemplate::fieldCString(const char*, template constexpr Error MetalClawReaderTemplate::fieldCString(const char*, char **val, std::size_t buffLen) noexcept { - if (m_unionIdx == -1 || m_unionIdx == m_field) { + if (m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) { if (m_fieldPresence.get(static_cast(m_field))) { // read the length if (m_buffIt >= m_buffLen) { @@ -457,7 +457,7 @@ constexpr Error MetalClawReaderTemplate::fieldCString(const char*, template constexpr Result MetalClawReaderTemplate::arrayLength(const char*, bool pass) noexcept { - if ((m_unionIdx == -1 || m_unionIdx == m_field)) { + if (m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) { if (m_fieldPresence.get(static_cast(m_field))) { // read the length if (m_buffIt >= m_buffLen) { @@ -477,7 +477,7 @@ constexpr Result MetalClawReaderTemplate::arrayLength template template constexpr Error MetalClawReaderTemplate::readInteger(I *val) noexcept { - if (m_unionIdx == -1 || m_unionIdx == m_field) { + if (m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) { if (m_fieldPresence.get(static_cast(m_field))) { std::size_t bytesRead = 0; if (m_buffIt >= m_buffLen) { @@ -499,7 +499,7 @@ constexpr Error MetalClawReaderTemplate::readInteger(I *val) noexc template template constexpr Error MetalClawReaderTemplate::field(const char*, CB cb) noexcept { - if (m_unionIdx == -1 || m_unionIdx == m_field) { + if (m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) { if (m_fieldPresence.get(static_cast(m_field))) { // read the length if (m_buffIt >= m_buffLen) { @@ -512,7 +512,7 @@ constexpr Error MetalClawReaderTemplate::field(const char*, CB cb) // read the list auto reader = child(""); auto handler = HandlerMaker(&reader); - handler.setTypeInfo("List", 0, {}, static_cast(len)); + handler.setTypeInfo("List", 0, {}, static_cast(len)); for (std::size_t i = 0; i < len; ++i) { T val; oxReturnError(handler.field("", &val)); @@ -526,7 +526,7 @@ constexpr Error MetalClawReaderTemplate::field(const char*, CB cb) template constexpr StringLength MetalClawReaderTemplate::stringLength(const char*) noexcept { - if ((m_unionIdx == -1 || m_unionIdx == m_field)) { + if (m_unionIdx == -1 || static_cast(m_unionIdx) == m_field) { if (m_fieldPresence.get(static_cast(m_field))) { // read the length std::size_t bytesRead = 0; @@ -539,10 +539,10 @@ constexpr StringLength MetalClawReaderTemplate::stringLength(const template template -constexpr void MetalClawReaderTemplate::setTypeInfo(const char*, int, const Vector&, int fields) noexcept { +constexpr void MetalClawReaderTemplate::setTypeInfo(const char*, int, const Vector&, std::size_t fields) noexcept { m_fields = fields; m_buffIt = static_cast((fields / 8 + 1) - (fields % 8 == 0)); - m_fieldPresence.setFields(fields); + m_fieldPresence.setFields(static_cast(fields)); m_fieldPresence.setMaxLen(static_cast(m_buffIt)); } diff --git a/deps/ox/src/ox/mc/write.hpp b/deps/ox/src/ox/mc/write.hpp index 6e344f10..bd90a661 100644 --- a/deps/ox/src/ox/mc/write.hpp +++ b/deps/ox/src/ox/mc/write.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -104,7 +104,7 @@ class MetalClawWriter { template constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion, - const Vector& = {}, int fields = ModelFieldCount_v) noexcept; + const Vector& = {}, std::size_t fields = ModelFieldCount_v) noexcept; /** * stringLength is not implemented in MetalClawWriter @@ -342,7 +342,7 @@ constexpr Error MetalClawWriter::field(const char*, T *val, std::size_t len) noe MetalClawWriter writer(m_buff + m_buffIt, m_buffLen - m_buffIt); ModelHandlerInterface handler{&writer}; - handler.setTypeInfo("List", 0, {}, static_cast(len)); + handler.setTypeInfo("List", 0, {}, static_cast(len)); // write the array for (std::size_t i = 0; i < len; i++) { @@ -400,9 +400,9 @@ constexpr Error MetalClawWriter::field(const char *name, HashMap *val } template -constexpr void MetalClawWriter::setTypeInfo(const char*, int, const Vector&, int fields) noexcept { - m_fields = fields; - m_fieldPresence.setFields(fields); +constexpr void MetalClawWriter::setTypeInfo(const char*, int, const Vector&, std::size_t fields) noexcept { + m_fields = static_cast(fields); + m_fieldPresence.setFields(static_cast(fields)); m_buffIt = static_cast(m_fieldPresence.getMaxLen()); ox_memset(m_buff, 0, m_buffIt); } diff --git a/deps/ox/src/ox/model/CMakeLists.txt b/deps/ox/src/ox/model/CMakeLists.txt index 5973a98d..19687d18 100644 --- a/deps/ox/src/ox/model/CMakeLists.txt +++ b/deps/ox/src/ox/model/CMakeLists.txt @@ -5,6 +5,11 @@ add_library( modelvalue.cpp ) +if(NOT MSVC) + target_compile_options(OxModel PRIVATE -Wconversion) + target_compile_options(OxModel PRIVATE -Wsign-conversion) +endif() + target_link_libraries( OxModel PUBLIC OxStd diff --git a/deps/ox/src/ox/model/descwrite.hpp b/deps/ox/src/ox/model/descwrite.hpp index f4a8470a..60618f3c 100644 --- a/deps/ox/src/ox/model/descwrite.hpp +++ b/deps/ox/src/ox/model/descwrite.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -94,7 +94,7 @@ class TypeDescWriter { constexpr void setTypeInfo(CRStringView name = T::TypeName, int version = T::TypeVersion, const TypeParamPack &typeParams = {}, - int fields = ModelFieldCount_v) noexcept; + std::size_t fields = ModelFieldCount_v) noexcept; template constexpr Error field(CRStringView name, const T *val, std::size_t valLen, @@ -179,7 +179,7 @@ constexpr TypeDescWriter::TypeDescWriter(TypeStore *typeStore) noexcept: m_typeS template constexpr void TypeDescWriter::setTypeInfo(CRStringView typeName, int typeVersion, - const TypeParamPack &typeParams, int) noexcept { + const TypeParamPack &typeParams, std::size_t) noexcept { PrimitiveType pt; if constexpr(is_union_v) { pt = PrimitiveType::Union; diff --git a/deps/ox/src/ox/model/fieldcounter.hpp b/deps/ox/src/ox/model/fieldcounter.hpp index 4b5d7314..12006821 100644 --- a/deps/ox/src/ox/model/fieldcounter.hpp +++ b/deps/ox/src/ox/model/fieldcounter.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -24,7 +24,7 @@ class FieldCounter { int fields = 0; template - constexpr void setTypeInfo(CRStringView = "", int = 0, const Vector& = {}, int = 0) { + constexpr void setTypeInfo(CRStringView = "", int = 0, const Vector& = {}, std::size_t = 0) { } template diff --git a/deps/ox/src/ox/model/modelhandleradaptor.hpp b/deps/ox/src/ox/model/modelhandleradaptor.hpp index 2e9a17da..881a7810 100644 --- a/deps/ox/src/ox/model/modelhandleradaptor.hpp +++ b/deps/ox/src/ox/model/modelhandleradaptor.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -24,8 +24,11 @@ class ModelHandlerInterface { } template - constexpr void setTypeInfo(const char *name = T::TypeName, int version = T::TypeVersion, - const Vector &typeParams = {}, int fields = ModelFieldCount_v) noexcept { + constexpr void setTypeInfo( + const char *name = T::TypeName, + int version = T::TypeVersion, + const Vector &typeParams = {}, + std::size_t fields = ModelFieldCount_v) noexcept { m_handler->template setTypeInfo(name, version, typeParams, fields); } diff --git a/deps/ox/src/ox/model/modelops.hpp b/deps/ox/src/ox/model/modelops.hpp index 092ae275..2c0e1ed1 100644 --- a/deps/ox/src/ox/model/modelops.hpp +++ b/deps/ox/src/ox/model/modelops.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -272,10 +272,6 @@ class Equals { } } - template - constexpr void setTypeInfo(const char* = T::TypeName, const Vector& = {}, int = T::Fields) noexcept { - } - [[nodiscard]] static constexpr auto opType() noexcept { return OpType::Read; diff --git a/deps/ox/src/ox/model/modelvalue.hpp b/deps/ox/src/ox/model/modelvalue.hpp index fb202ead..b81f74a9 100644 --- a/deps/ox/src/ox/model/modelvalue.hpp +++ b/deps/ox/src/ox/model/modelvalue.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -769,7 +769,7 @@ constexpr std::size_t alignOf(const ModelValue &t) noexcept { } constexpr Error model(auto *h, CommonPtrWith auto *obj) noexcept { - h->template setTypeInfo(obj->typeName().c_str(), obj->typeVersion(), {}, static_cast(obj->m_fieldsOrder.size())); + h->template setTypeInfo(obj->typeName().c_str(), obj->typeVersion(), {}, obj->m_fieldsOrder.size()); for (auto &f : obj->m_fieldsOrder) { oxReturnError(h->field(f->name.c_str(), &f->value)); } @@ -777,7 +777,7 @@ constexpr Error model(auto *h, CommonPtrWith auto *obj) noexcept { } constexpr Error model(auto *h, CommonPtrWith auto *obj) noexcept { - h->template setTypeInfo(obj->typeName().c_str(), obj->typeVersion(), {}, static_cast(obj->m_fieldsOrder.size())); + h->template setTypeInfo(obj->typeName().c_str(), obj->typeVersion(), {}, obj->m_fieldsOrder.size()); for (auto &f : obj->m_fieldsOrder) { oxReturnError(h->field(f->name.c_str(), &f->value)); } diff --git a/deps/ox/src/ox/model/typenamecatcher.hpp b/deps/ox/src/ox/model/typenamecatcher.hpp index a545c697..cf918a58 100644 --- a/deps/ox/src/ox/model/typenamecatcher.hpp +++ b/deps/ox/src/ox/model/typenamecatcher.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -25,7 +25,7 @@ struct TypeNameCatcher { constexpr TypeNameCatcher() noexcept = default; template - constexpr void setTypeInfo(const char *n = T::TypeName, int v = T::TypeVersion, const Vector& = {}, int = 0) noexcept { + constexpr void setTypeInfo(const char *n = T::TypeName, int v = T::TypeVersion, const Vector& = {}, std::size_t = 0) noexcept { this->name = n; this->version = v; } @@ -59,7 +59,7 @@ struct TypeInfoCatcher { constexpr TypeInfoCatcher() noexcept = default; template - constexpr void setTypeInfo(const char *n = T::TypeName, int v = T::TypeVersion, const Vector& = {}, int = 0) noexcept { + constexpr void setTypeInfo(const char *n = T::TypeName, int v = T::TypeVersion, const Vector& = {}, std::size_t = 0) noexcept { this->name = n; this->version = v; } diff --git a/deps/ox/src/ox/model/types.hpp b/deps/ox/src/ox/model/types.hpp index 9f51e52c..02b4140f 100644 --- a/deps/ox/src/ox/model/types.hpp +++ b/deps/ox/src/ox/model/types.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/deps/ox/src/ox/model/walk.hpp b/deps/ox/src/ox/model/walk.hpp index 745d04fb..5175d01f 100644 --- a/deps/ox/src/ox/model/walk.hpp +++ b/deps/ox/src/ox/model/walk.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this diff --git a/deps/ox/src/ox/oc/CMakeLists.txt b/deps/ox/src/ox/oc/CMakeLists.txt index eda8de09..96d3d99b 100644 --- a/deps/ox/src/ox/oc/CMakeLists.txt +++ b/deps/ox/src/ox/oc/CMakeLists.txt @@ -6,6 +6,7 @@ add_library( if(NOT MSVC) target_compile_options(OxOrganicClaw PRIVATE -Wsign-conversion) + target_compile_options(OxOrganicClaw PRIVATE -Wconversion) endif() target_link_libraries( diff --git a/deps/ox/src/ox/oc/read.hpp b/deps/ox/src/ox/oc/read.hpp index cb7d823c..e722d17f 100644 --- a/deps/ox/src/ox/oc/read.hpp +++ b/deps/ox/src/ox/oc/read.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -107,7 +107,7 @@ class OrganicClawReader { } template - constexpr void setTypeInfo(const char*, int, const Vector& = {}, int = {}) noexcept { + constexpr void setTypeInfo(const char*, int, const Vector& = {}, std::size_t = {}) noexcept { } /** diff --git a/deps/ox/src/ox/oc/test/tests.cpp b/deps/ox/src/ox/oc/test/tests.cpp index e4914b47..5bf209f4 100644 --- a/deps/ox/src/ox/oc/test/tests.cpp +++ b/deps/ox/src/ox/oc/test/tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -332,7 +332,7 @@ const std::map tests = { } case ox::PrimitiveType::String: { ox::Vector v(rdr->stringLength(fieldName) + 1); - oxAssert(rdr->field(fieldName, ox::SerStr(v.data(), v.size())), "Walking model failed."); + oxAssert(rdr->field(fieldName, ox::SerStr(v.data(), static_cast(v.size()))), "Walking model failed."); oxOutf("{}:\tstring:\t{}\n", fieldName, v.data()); break; } @@ -362,5 +362,5 @@ int main(int argc, const char **args) { oxErrorf("Test {} not found", testName); return 1; } - return test(); + return static_cast(test()); } diff --git a/deps/ox/src/ox/oc/write.hpp b/deps/ox/src/ox/oc/write.hpp index d5f7be3a..3e461bdb 100644 --- a/deps/ox/src/ox/oc/write.hpp +++ b/deps/ox/src/ox/oc/write.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -146,7 +146,7 @@ class OrganicClawWriter { template Error field(const char *key, BString *val) noexcept { - return field(key, SerStr(val->data(), val->cap())); + return field(key, SerStr(val->data(), static_cast(val->cap()))); } template @@ -180,7 +180,7 @@ class OrganicClawWriter { template constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion, - const Vector& = {}, int = ModelFieldCount_v) noexcept { + const Vector& = {}, std::size_t = ModelFieldCount_v) noexcept { } static constexpr auto opType() noexcept { diff --git a/deps/ox/src/ox/preloader/CMakeLists.txt b/deps/ox/src/ox/preloader/CMakeLists.txt index fb76f4b4..133aaab3 100644 --- a/deps/ox/src/ox/preloader/CMakeLists.txt +++ b/deps/ox/src/ox/preloader/CMakeLists.txt @@ -4,6 +4,11 @@ add_library( preloader.cpp ) +if(NOT MSVC) + target_compile_options(OxPreloader PRIVATE -Wsign-conversion) + target_compile_options(OxPreloader PRIVATE -Wconversion) +endif() + target_link_libraries( OxPreloader PUBLIC OxClaw diff --git a/deps/ox/src/ox/preloader/alignmentcatcher.hpp b/deps/ox/src/ox/preloader/alignmentcatcher.hpp index cd9369bf..c3de252a 100644 --- a/deps/ox/src/ox/preloader/alignmentcatcher.hpp +++ b/deps/ox/src/ox/preloader/alignmentcatcher.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -27,7 +27,7 @@ struct AlignmentCatcher: public ModelHandlerBase> { template constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion, - const Vector& = {}, int = ModelFieldCount_v) noexcept {} + const Vector& = {}, std::size_t = ModelFieldCount_v) noexcept {} template constexpr ox::Error field(CRStringView name, const UnionView val) noexcept { diff --git a/deps/ox/src/ox/preloader/preloader.hpp b/deps/ox/src/ox/preloader/preloader.hpp index d38bf63e..f4d982a2 100644 --- a/deps/ox/src/ox/preloader/preloader.hpp +++ b/deps/ox/src/ox/preloader/preloader.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -78,8 +78,11 @@ class Preloader: public ModelHandlerBase> { std::size_t sz = 0) noexcept; template - constexpr void setTypeInfo(ox::CRStringView = T::TypeName, int = T::TypeVersion, - const Vector& = {}, int = ModelFieldCount_v) noexcept {} + constexpr void setTypeInfo( + ox::CRStringView = T::TypeName, + int = T::TypeVersion, + const Vector& = {}, + std::size_t = ModelFieldCount_v) noexcept {} template constexpr ox::Error field(CRStringView, const ox::UnionView val) noexcept; @@ -276,7 +279,7 @@ template constexpr ox::Error Preloader::offsetPtrs(std::size_t offset) noexcept { for (const auto &p : m_ptrs) { oxReturnError(m_writer.seekp(p.loc)); - const auto val = PlatSpec::template correctEndianness(p.value + offset); + const auto val = PlatSpec::template correctEndianness(static_cast(p.value + offset)); oxReturnError(ox::serialize(&m_writer, val)); } oxReturnError(m_writer.seekp(0, ox::ios_base::end)); @@ -307,18 +310,22 @@ constexpr ox::Error Preloader::fieldVector(CRStringView name, const ox template template -constexpr ox::Error Preloader::fieldVector(CRStringView name, const ox::Vector *val) noexcept { +constexpr ox::Error Preloader::fieldVector( + CRStringView name, const ox::Vector *val) noexcept { // serialize the Vector ox::VectorMemMap vecVal{ .smallVecSize = SmallVectorSize * sizeOf(static_cast(nullptr)), - .size = PlatSpec::correctEndianness(static_cast(val->size())), - .cap = PlatSpec::correctEndianness(static_cast(val->size())), + .size = PlatSpec::correctEndianness( + static_cast(val->size())), + .cap = PlatSpec::correctEndianness( + static_cast(val->size())), }; return fieldVector(name, val, vecVal); } template -constexpr ox::Error Preloader::fieldVector(CRStringView, const auto *val, ox::VectorMemMap vecVal) noexcept { +constexpr ox::Error Preloader::fieldVector( + CRStringView, const auto *val, ox::VectorMemMap vecVal) noexcept { oxReturnError(pad(&vecVal)); const auto vecValPt = m_writer.tellp(); // serialize the Vector elements @@ -331,7 +338,8 @@ constexpr ox::Error Preloader::fieldVector(CRStringView, const auto *v oxReturnError(this->interface()->field(nullptr, &val->operator[](i))); } m_unionIdx.pop_back(); - vecVal.items = PlatSpec::correctEndianness(p + PlatSpec::RomStart); + vecVal.items = PlatSpec::correctEndianness( + static_cast(p + PlatSpec::RomStart)); oxReturnError(m_writer.seekp(vecValPt)); } else { vecVal.items = 0; @@ -349,7 +357,8 @@ constexpr bool Preloader::unionCheckAndIt() noexcept { } template -constexpr ox::Error preload(Preloader *pl, ox::CommonPtrWith auto *obj) noexcept { +constexpr ox::Error preload( + Preloader *pl, ox::CommonPtrWith auto *obj) noexcept { oxReturnError(model(pl->interface(), obj)); return pl->pad(obj); } diff --git a/deps/ox/src/ox/preloader/sizecatcher.hpp b/deps/ox/src/ox/preloader/sizecatcher.hpp index 077d6871..7b872e8b 100644 --- a/deps/ox/src/ox/preloader/sizecatcher.hpp +++ b/deps/ox/src/ox/preloader/sizecatcher.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -33,7 +33,7 @@ class SizeCatcher: public ModelHandlerBase> { template constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion, - const Vector& = {}, int = ModelFieldCount_v) noexcept {} + const Vector& = {}, std::size_t = ModelFieldCount_v) noexcept {} template constexpr ox::Error field(const char*, UnionView) noexcept; diff --git a/deps/ox/src/ox/preloader/unionsizecatcher.hpp b/deps/ox/src/ox/preloader/unionsizecatcher.hpp index a3c00439..110e645f 100644 --- a/deps/ox/src/ox/preloader/unionsizecatcher.hpp +++ b/deps/ox/src/ox/preloader/unionsizecatcher.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2016 - 2022 Gary Talent (gary@drinkingtea.net). All rights reserved. + * Copyright 2016 - 2023 Gary Talent (gary@drinkingtea.net). All rights reserved. */ #pragma once @@ -21,7 +21,7 @@ class UnionSizeCatcher: public ModelHandlerBase> { public: template constexpr void setTypeInfo(const char* = T::TypeName, int = T::TypeVersion, - const Vector& = {}, int = ModelFieldCount_v) noexcept {} + const Vector& = {}, std::size_t = ModelFieldCount_v) noexcept {} template constexpr ox::Error field(CRStringView, const UnionView val) noexcept { diff --git a/deps/ox/src/ox/std/CMakeLists.txt b/deps/ox/src/ox/std/CMakeLists.txt index 181ca125..00158a11 100644 --- a/deps/ox/src/ox/std/CMakeLists.txt +++ b/deps/ox/src/ox/std/CMakeLists.txt @@ -43,6 +43,7 @@ add_library( if(NOT MSVC) target_compile_options(OxStd PRIVATE -Wsign-conversion) + target_compile_options(OxStd PRIVATE -Wconversion) if(UNIX AND NOT APPLE) target_compile_options(OxStd PUBLIC -export-dynamic) #target_link_options(OxStd PUBLIC -W1,-E) diff --git a/deps/ox/src/ox/std/byteswap.hpp b/deps/ox/src/ox/std/byteswap.hpp index 68365d44..980eb1fb 100644 --- a/deps/ox/src/ox/std/byteswap.hpp +++ b/deps/ox/src/ox/std/byteswap.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -24,7 +24,7 @@ constexpr T byteSwap(typename enable_if::type i) noexcept { template [[nodiscard]] constexpr T byteSwap(typename enable_if::type i) noexcept { - return (i << 8) | (i >> 8); + return static_cast(i << 8) | static_cast(i >> 8); } template @@ -102,73 +102,54 @@ class OX_PACKED ByteSwapInteger { constexpr ByteSwapInteger(T value) noexcept: m_value(conditionalByteSwap(value)) { } - constexpr const ByteSwapInteger &operator=(const ByteSwapInteger &other) noexcept { + constexpr ByteSwapInteger &operator=(const ByteSwapInteger &other) noexcept { m_value = other.m_value; return *this; } - template - constexpr T operator=(I value) noexcept { + constexpr ByteSwapInteger &operator=(T value) noexcept { m_value = conditionalByteSwap(value); - return value; + return *this; } constexpr operator T() const noexcept { return conditionalByteSwap(m_value); } - template - constexpr T operator+=(I other) noexcept { - auto newVal = *this + other; + constexpr ByteSwapInteger operator+=(T other) noexcept { + const auto newVal = static_cast(*this + other); m_value = conditionalByteSwap(newVal); - return newVal; + return *this; } - template - constexpr T operator-=(I other) noexcept { - auto newVal = *this - other; + constexpr ByteSwapInteger operator-=(T other) noexcept { + const auto newVal = static_cast(*this - other); m_value = conditionalByteSwap(newVal); - return newVal; + return *this; } - template - constexpr T operator*=(I other) noexcept { - auto newVal = *this * other; + constexpr ByteSwapInteger operator*=(T other) noexcept { + const auto newVal = static_cast(*this * other); m_value = conditionalByteSwap(newVal); - return newVal; + return *this; } - template - constexpr T operator/=(I other) noexcept { - auto newVal = *this / other; + constexpr ByteSwapInteger operator/=(T other) noexcept { + const auto newVal = static_cast(*this / other); m_value = conditionalByteSwap(newVal); - return newVal; + return *this; } // Prefix increment - constexpr T operator++() noexcept { + constexpr ByteSwapInteger operator++() noexcept { return operator+=(1); } - // Postfix increment - constexpr T operator++(int) noexcept { - auto old = *this; - ++*this; - return old; - } - // Prefix decrement - constexpr T operator--() noexcept { + constexpr ByteSwapInteger operator--() noexcept { return operator-=(1); } - // Postfix decrement - constexpr T operator--(int) noexcept { - auto old = *this; - --*this; - return old; - } - template constexpr T operator&=(I other) noexcept { auto newVal = *this & other; diff --git a/deps/ox/src/ox/std/error.hpp b/deps/ox/src/ox/std/error.hpp index 12d217ed..e0d5fa16 100644 --- a/deps/ox/src/ox/std/error.hpp +++ b/deps/ox/src/ox/std/error.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -51,7 +51,7 @@ struct [[nodiscard]] Error { explicit constexpr Error(const char *file, uint32_t line, ErrorCode errCode, const char *msg = nullptr) noexcept { this->file = file; - this->line = line; + this->line = static_cast(line); this->msg = msg; this->errCode = errCode; } @@ -96,7 +96,7 @@ struct Exception: public std::exception { explicit inline Exception(const char *file, uint32_t line, ErrorCode errCode, const char *msg = "") noexcept { this->file = file; - this->line = line; + this->line = static_cast(line); this->msg = msg; this->errCode = errCode; } diff --git a/deps/ox/src/ox/std/hashmap.hpp b/deps/ox/src/ox/std/hashmap.hpp index 469f0efe..18332f42 100644 --- a/deps/ox/src/ox/std/hashmap.hpp +++ b/deps/ox/src/ox/std/hashmap.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -148,7 +148,8 @@ template constexpr T &HashMap::operator[](const K &k) { auto &p = access(m_pairs, k); if (p == nullptr) { - if (m_pairs.size() * 0.7 < m_keys.size()) { + if (static_cast(m_pairs.size()) * 0.7 < + static_cast(m_keys.size())) { expand(); } p = new Pair; @@ -247,7 +248,7 @@ constexpr uint64_t HashMap::hash(auto k) noexcept { template constexpr typename HashMap::Pair *const&HashMap::access(const Vector &pairs, const K &k) const { - auto h = hash(k) % pairs.size(); + auto h = static_cast(hash(k) % pairs.size()); while (true) { const auto &p = pairs[h]; if (p == nullptr || ox_strcmp(p->key, k) == 0) { @@ -260,7 +261,7 @@ constexpr typename HashMap::Pair *const&HashMap::access(const Vector template constexpr typename HashMap::Pair *&HashMap::access(Vector &pairs, const K &k) { - auto h = hash(k) % pairs.size(); + auto h = static_cast(hash(k) % pairs.size()); while (true) { auto &p = pairs[h]; bool matches = [&] { diff --git a/deps/ox/src/ox/std/stringview.hpp b/deps/ox/src/ox/std/stringview.hpp index 369a61d0..c61d6f27 100644 --- a/deps/ox/src/ox/std/stringview.hpp +++ b/deps/ox/src/ox/std/stringview.hpp @@ -357,7 +357,7 @@ constexpr ox::Result ox_atoi(ox::CRStringView str) noexcept { int total = 0; int multiplier = 1; for (auto i = static_cast(str.len()) - 1; i != -1; --i) { - auto s = static_cast(i); + auto s = static_cast(i); if (str[s] >= '0' && str[s] <= '9') { total += (str[s] - '0') * multiplier; multiplier *= 10; diff --git a/deps/ox/src/ox/std/strops.hpp b/deps/ox/src/ox/std/strops.hpp index b3e8fbb9..bb3f969f 100644 --- a/deps/ox/src/ox/std/strops.hpp +++ b/deps/ox/src/ox/std/strops.hpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2022 gary@drinkingtea.net + * Copyright 2015 - 2023 gary@drinkingtea.net * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this @@ -129,15 +129,16 @@ template constexpr T ox_itoa(Integer v, T str) noexcept { if (v) { ox::ResizedInt_t mod = 1000000000000000000; + ox::ResizedInt_t val = v; constexpr auto base = 10; auto it = 0; - if (v < 0) { + if (val < 0) { str[it] = '-'; it++; } while (mod) { - auto digit = v / mod; - v %= mod; + auto digit = val / mod; + val %= mod; mod /= base; if (it || digit) { ox::ResizedInt_t start = '0'; diff --git a/deps/ox/src/ox/std/uuid.hpp b/deps/ox/src/ox/std/uuid.hpp index e4bafcb9..9cc3c3b2 100644 --- a/deps/ox/src/ox/std/uuid.hpp +++ b/deps/ox/src/ox/std/uuid.hpp @@ -57,7 +57,7 @@ constexpr ox::Result fromHex(ox::CRStringView v) noexcept { return OxError(2); } uint8_t out = 0; - out += valMap[static_cast(v[0])] * 16u; + out += static_cast(valMap[static_cast(v[0])] * 16); out += valMap[static_cast(v[1])]; return out; }