diff --git a/src/apps/acb2hcas/acb2hcas.cpp b/src/apps/acb2hcas/acb2hcas.cpp index bc19914..ccec5a1 100644 --- a/src/apps/acb2hcas/acb2hcas.cpp +++ b/src/apps/acb2hcas/acb2hcas.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "../../lib/cgss_api.h" #include "../common/common.h" @@ -182,14 +183,16 @@ ProcessAllBinaries(CAcbFile *acb, uint32_t formatVersion, const Acb2HcasOptions keyModifier = 0; } - for (auto &entry : archive->GetFiles()) { + const auto &fileList = archive->GetFiles(); + + for (auto &entry : fileList) { auto &record = entry.second; auto fileData = CAcbHelper::ExtractToNewStream(dataStream, record.fileOffsetAligned, (uint32_t)record.fileSize); const auto isHca = CHcaFormatReader::IsPossibleHcaStream(fileData); - fprintf(stdout, "Processing %s AFS: #%u (offset=%u, size=%u)", + fprintf(stdout, "Processing %s AFS: #%" PRIu32 " (offset=%" PRIu32 ", size=%" PRIu32 ")", afsSource, (uint32_t)record.cueId, (uint32_t)record.fileOffsetAligned, (uint32_t)record.fileSize); if (isHca) { diff --git a/src/apps/acb2wavs/acb2wavs.cpp b/src/apps/acb2wavs/acb2wavs.cpp index cf682ae..22850ca 100644 --- a/src/apps/acb2wavs/acb2wavs.cpp +++ b/src/apps/acb2wavs/acb2wavs.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "../cgssh.h" #include "../../lib/cgss_api.h" @@ -179,7 +180,7 @@ ProcessAllBinaries(CAcbFile *acb, uint32_t formatVersion, const Acb2WavsOptions const auto isHca = CHcaFormatReader::IsPossibleHcaStream(fileData); - fprintf(stdout, "Processing %s AFS: #%u (offset=%u, size=%u)", + fprintf(stdout, "Processing %s AFS: #%" PRIu32 " (offset=%" PRIu32 ", size=%" PRIu32 ")", afsSource, (uint32_t)record.cueId, (uint32_t)record.fileOffsetAligned, (uint32_t)record.fileSize); int r; diff --git a/src/apps/acbunpack/acbunpack.cpp b/src/apps/acbunpack/acbunpack.cpp index a4e4ee7..ffc2a51 100644 --- a/src/apps/acbunpack/acbunpack.cpp +++ b/src/apps/acbunpack/acbunpack.cpp @@ -1,6 +1,7 @@ -#include -#include -#include +#include +#include +#include +#include #if defined(_WIN32) || defined(WIN32) @@ -76,7 +77,7 @@ int main(int argc, const char *argv[]) { common_utils::CopyStream(stream, &fs); } else { - fprintf(stderr, "Cue #%u (%s) cannot be retrieved.\n", i + 1, s.c_str()); + fprintf(stderr, "Cue #%" PRIu32 " (%s) cannot be retrieved.\n", i + 1, s.c_str()); } delete stream; diff --git a/src/apps/utftable/utftable.c b/src/apps/utftable/utftable.c index 397dd67..7da3931 100644 --- a/src/apps/utftable/utftable.c +++ b/src/apps/utftable/utftable.c @@ -77,14 +77,14 @@ static void print_table_recursive(UTF_TABLE *table, uint32_t indent) { indent += INDENT_VALUE; PRINT_INDENT(); - printf("@%s (encrypted: %s, field count: %u, row count: %u)\n", table->tableName, + printf("@%s (encrypted: %s, field count: %" PRIu32 ", row count: %" PRIu32 ")\n", table->tableName, BOOL_STR(table->isEncrypted), table->header.fieldCount, table->header.rowCount); for (uint32_t i = 0; i < table->header.rowCount; ++i) { UTF_ROW *currentRow = table->rows + i; PRINT_INDENT(); - printf("@%s [%u] = {\n", table->tableName, i); + printf("@%s [%" PRIu32 "] = {\n", table->tableName, i); indent += INDENT_VALUE; if (table->header.fieldCount == 0) { @@ -139,7 +139,7 @@ static void print_table_recursive(UTF_TABLE *table, uint32_t indent) { } PRINT_INDENT(); - printf("%08x (row+%08x) %2x %s [%s] =", currentField->offset, currentField->offsetInRow, + printf("%08" PRIx32 " (row+%08" PRIx32 ") %2x %s [%s] =", currentField->offset, currentField->offsetInRow, (currentField->storage | currentField->type), currentField->name, columnTypeName); const char *constantTypeStr; @@ -201,7 +201,7 @@ static void print_table_recursive(UTF_TABLE *table, uint32_t indent) { cgssUtfFreeTable(tbl); } else { - printf("%s (size %u = 0x%x)", constantTypeStr, currentField->value.data.size, currentField->value.data.size); + printf("%s (size %" PRIu32 " = 0x%" PRIx32 ")", constantTypeStr, currentField->value.data.size, currentField->value.data.size); } break; default: diff --git a/src/lib/capi/CHandleManager.cpp b/src/lib/capi/CHandleManager.cpp index 1e441ba..4336b34 100644 --- a/src/lib/capi/CHandleManager.cpp +++ b/src/lib/capi/CHandleManager.cpp @@ -2,6 +2,8 @@ #define _CRT_SECURE_NO_WARNINGS #endif +#include + #include "CHandleManager.h" #include "../takamori/exceptions/CArgumentException.h" @@ -9,7 +11,7 @@ CGSS_NS_BEGIN CHandleManager *CHandleManager::_instance = new CHandleManager(); - CHandleManager::CHandleManager() { + CHandleManager::CHandleManager() noexcept { HandleRecord record = {}; record.ptr = nullptr; record.type = HandleType::None; @@ -28,7 +30,7 @@ CGSS_NS_BEGIN const auto iter = _handles.find(handle); if (iter == _handles.cend()) { char buffer[100] = {0}; - sprintf(buffer, "Handle %u is invalid.", handle); + sprintf(buffer, "Handle %" PRIu32 " is invalid.", handle); throw CArgumentException(buffer); } return iter->second.type; @@ -38,7 +40,7 @@ CGSS_NS_BEGIN const auto iter = _handles.find(handle); if (iter == _handles.cend()) { char buffer[100] = {0}; - sprintf(buffer, "Handle %u is invalid.", handle); + sprintf(buffer, "Handle %" PRIu32 " is invalid.", handle); throw CArgumentException(buffer); } return iter->second.ptr; @@ -69,7 +71,7 @@ CGSS_NS_BEGIN const auto iter = _handles.find(handle); if (iter == _handles.cend()) { char buffer[100] = {0}; - sprintf(buffer, "Handle %u is invalid.", handle); + sprintf(buffer, "Handle %" PRIu32 " is invalid.", handle); throw CArgumentException(buffer); } if (dispose) { diff --git a/src/lib/capi/CHandleManager.h b/src/lib/capi/CHandleManager.h index c09be9c..f6b8110 100644 --- a/src/lib/capi/CHandleManager.h +++ b/src/lib/capi/CHandleManager.h @@ -16,6 +16,14 @@ CGSS_NS_BEGIN CHcaReaderBase = 0x03 }; + CHandleManager(const CHandleManager &) = delete; + + CHandleManager(CHandleManager &&) = delete; + + CHandleManager &operator=(const CHandleManager &) = delete; + + CHandleManager &operator=(CHandleManager &&) = delete; + uint32_t alloc(IStream *p, HandleType type); void free(uint32_t handle, bool_t dispose = TRUE); @@ -30,12 +38,10 @@ CGSS_NS_BEGIN private: - CHandleManager(); + CHandleManager() noexcept; ~CHandleManager(); - CHandleManager(CHandleManager &) = delete; - static CHandleManager *_instance; struct HandleRecord { diff --git a/src/lib/ichinose/CAcbFile.cpp b/src/lib/ichinose/CAcbFile.cpp index e6e8d4a..ecb99c8 100644 --- a/src/lib/ichinose/CAcbFile.cpp +++ b/src/lib/ichinose/CAcbFile.cpp @@ -1,4 +1,6 @@ #include +#include + #include "../cgss_cenum.h" #include "CAfs2Archive.h" #include "../cgss_cdata.h" @@ -269,7 +271,7 @@ IStream *CAcbFile::OpenDataStream(const char *fileName) { IStream *CAcbFile::OpenDataStream(uint32_t cueId) { char tempFileName[40] = {0}; - sprintf(tempFileName, "cue #%u", cueId); + sprintf(tempFileName, "cue #%" PRIu32, cueId); IStream *result = nullptr; diff --git a/src/lib/kawashima/hca/CHcaCipherConverter.cpp b/src/lib/kawashima/hca/CHcaCipherConverter.cpp index f836089..054919c 100644 --- a/src/lib/kawashima/hca/CHcaCipherConverter.cpp +++ b/src/lib/kawashima/hca/CHcaCipherConverter.cpp @@ -4,6 +4,8 @@ #include #include +#include + #include "CHcaCipherConverter.h" #include "../../common/quick_utils.h" #include "internal/CHcaCipher.h" @@ -150,7 +152,7 @@ CGSS_NS_BEGIN if (ComputeChecksum(blockBuffer, hcaInfo.blockSize, 0) != 0) { char numberBuffer[20] = {0}; - sprintf(numberBuffer, "%u", blockIndex); + sprintf(numberBuffer, "%" PRIu32, blockIndex); throw CFormatException(std::string("CHcaCipherConverter::ConvertBlock @ Block#") + numberBuffer); } @@ -163,7 +165,7 @@ CGSS_NS_BEGIN const auto magic = data.GetBit(16); if (magic != 0xffff) { char numberBuffer[20] = {0}; - sprintf(numberBuffer, "%u", blockIndex); + sprintf(numberBuffer, "%" PRIu32, blockIndex); throw CFormatException(std::string("CHcaCipherConverter::ConvertBlock @ Block#") + numberBuffer); } diff --git a/src/lib/takamori/exceptions/CException.cpp b/src/lib/takamori/exceptions/CException.cpp index 885d8f9..eb1bba9 100644 --- a/src/lib/takamori/exceptions/CException.cpp +++ b/src/lib/takamori/exceptions/CException.cpp @@ -14,10 +14,6 @@ CGSS_NS_BEGIN : MyClass(std::string(message)) { } - CException::CException(const cgss::CException &exception) noexcept - : MyBase(), _result(exception._result), _message(exception._message) { - } - CException::CException(const std::string &message) noexcept : MyClass(CGSS_OP_GENERIC_FAULT, message) { } @@ -33,7 +29,7 @@ CGSS_NS_BEGIN return *this; } - const std::string CException::GetExceptionMessage() const noexcept { + const std::string &CException::GetExceptionMessage() const noexcept { return _message; } diff --git a/src/lib/takamori/exceptions/CException.h b/src/lib/takamori/exceptions/CException.h index f79a0c6..2a496d3 100644 --- a/src/lib/takamori/exceptions/CException.h +++ b/src/lib/takamori/exceptions/CException.h @@ -14,7 +14,7 @@ CGSS_NS_BEGIN CException() noexcept; - CException(const CException &) noexcept; + CException(const CException &) noexcept = default; CException& operator=(const CException &) noexcept; @@ -28,7 +28,7 @@ CGSS_NS_BEGIN virtual ~CException() noexcept = default; - virtual const std::string GetExceptionMessage() const noexcept; + virtual const std::string &GetExceptionMessage() const noexcept; virtual CGSS_OP_RESULT GetOpResult() const noexcept;