@@ -2,7 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <cinttypes>
#include "DiscIO/VolumeGC.h"

#include <cstddef>
#include <map>
#include <memory>
@@ -26,7 +27,6 @@
#include "DiscIO/FileSystemGCWii.h"
#include "DiscIO/Filesystem.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeGC.h"

namespace DiscIO
{
@@ -159,7 +159,7 @@ VolumeGC::ConvertedGCBanner VolumeGC::LoadBannerFile() const
reinterpret_cast<u8*>(&banner_file), sizeof(GCBanner));
if (file_size < 4)
{
WARN_LOG(DISCIO, "Could not read opening.bnr.");
WARN_LOG_FMT(DISCIO, "Could not read opening.bnr.");
return {}; // Return early so that we don't access the uninitialized banner_file.id
}

@@ -176,7 +176,8 @@ VolumeGC::ConvertedGCBanner VolumeGC::LoadBannerFile() const
}
else
{
WARN_LOG(DISCIO, "Invalid opening.bnr. Type: %0x Size: %0" PRIx64, banner_file.id, file_size);
WARN_LOG_FMT(DISCIO, "Invalid opening.bnr. Type: {:#0x} Size: {:#0x}", banner_file.id,
file_size);
return {};
}

@@ -6,7 +6,6 @@

#include <algorithm>
#include <cassert>
#include <cinttypes>
#include <future>
#include <limits>
#include <memory>
@@ -97,7 +96,7 @@ void RedumpVerifier::Start(const Volume& volume)
switch (download_state->status)
{
case DownloadStatus::FailButOldCacheAvailable:
ERROR_LOG(DISCIO, "Failed to fetch data from Redump.org, using old cached data instead");
ERROR_LOG_FMT(DISCIO, "Failed to fetch data from Redump.org, using old cached data instead");
[[fallthrough]];
case DownloadStatus::Success:
return ScanDatfile(ReadDatfile(system), system);
@@ -156,7 +155,7 @@ RedumpVerifier::DownloadStatus RedumpVerifier::DownloadDatfile(const std::string

File::CreateFullPath(output_path);
if (!File::IOFile(output_path, "wb").WriteBytes(result->data(), result->size()))
ERROR_LOG(DISCIO, "Failed to write downloaded datfile to %s", output_path.c_str());
ERROR_LOG_FMT(DISCIO, "Failed to write downloaded datfile to {}", output_path);
return DownloadStatus::Success;
}

@@ -275,7 +274,7 @@ std::vector<RedumpVerifier::PotentialMatch> RedumpVerifier::ScanDatfile(const st

if (game_id_start == std::string::npos || serial.size() < game_id_start + 4)
{
ERROR_LOG(DISCIO, "Invalid serial in redump datfile: %s", serial_str.c_str());
ERROR_LOG_FMT(DISCIO, "Invalid serial in redump datfile: {}", serial_str);
continue;
}

@@ -1167,8 +1166,7 @@ void VolumeVerifier::Process()

if (!read_succeeded)
{
ERROR_LOG(DISCIO, "Read failed at 0x%" PRIx64 " to 0x%" PRIx64, m_progress,
m_progress + bytes_to_read);
ERROR_LOG_FMT(DISCIO, "Read failed at {:#x} to {:#x}", m_progress, m_progress + bytes_to_read);

m_read_errors_occurred = true;
m_calculating_any_hash = false;
@@ -1245,12 +1243,12 @@ void VolumeVerifier::Process()
{
if (m_scrubber.CanBlockBeScrubbed(offset))
{
WARN_LOG(DISCIO, "Integrity check failed for unused block at 0x%" PRIx64, offset);
WARN_LOG_FMT(DISCIO, "Integrity check failed for unused block at {:#x}", offset);
m_unused_block_errors[m_blocks[block_index].partition]++;
}
else
{
WARN_LOG(DISCIO, "Integrity check failed for block at 0x%" PRIx64, offset);
WARN_LOG_FMT(DISCIO, "Integrity check failed for block at {:#x}", offset);
m_block_errors[m_blocks[block_index].partition]++;
}
}
@@ -54,7 +54,7 @@ VolumeWAD::VolumeWAD(std::unique_ptr<BlobReader> reader) : m_reader(std::move(re

if (!IOS::ES::IsValidTMDSize(m_tmd_size))
{
ERROR_LOG(DISCIO, "TMD is too large: %u bytes", m_tmd_size);
ERROR_LOG_FMT(DISCIO, "TMD is too large: {} bytes", m_tmd_size);
return;
}

@@ -240,7 +240,8 @@ IOS::ES::TicketReader VolumeWAD::GetTicketWithFixedCommonKey() const
}
}

ERROR_LOG(DISCIO, "Couldn't find valid common key for WAD file (%u specified)", specified_index);
ERROR_LOG_FMT(DISCIO, "Couldn't find valid common key for WAD file ({} specified)",
specified_index);
return m_ticket;
}

@@ -6,7 +6,6 @@

#include <algorithm>
#include <array>
#include <cinttypes>
#include <cstring>
#include <limits>
#include <map>
@@ -104,8 +103,7 @@ bool WIARVZFileReader<RVZ>::Initialize(const std::string& path)

if (version < file_version_compatible || version_read_compatible > file_version)
{
ERROR_LOG(DISCIO, "Unsupported version %s in %s", VersionToString(file_version).c_str(),
path.c_str());
ERROR_LOG_FMT(DISCIO, "Unsupported version {} in {}", VersionToString(file_version), path);
return false;
}

@@ -117,7 +115,7 @@ bool WIARVZFileReader<RVZ>::Initialize(const std::string& path)

if (Common::swap64(m_header_1.wia_file_size) != m_file.GetSize())
{
ERROR_LOG(DISCIO, "File size is incorrect for %s", path.c_str());
ERROR_LOG_FMT(DISCIO, "File size is incorrect for {}", path);
return false;
}

@@ -156,7 +154,7 @@ bool WIARVZFileReader<RVZ>::Initialize(const std::string& path)
if (m_compression_type > (RVZ ? WIARVZCompressionType::Zstd : WIARVZCompressionType::LZMA2) ||
(RVZ && m_compression_type == WIARVZCompressionType::Purge))
{
ERROR_LOG(DISCIO, "Unsupported compression type %u in %s", compression_type, path.c_str());
ERROR_LOG_FMT(DISCIO, "Unsupported compression type {} in {}", compression_type, path);
return false;
}

@@ -785,7 +783,7 @@ bool WIARVZFileReader<RVZ>::Chunk::HandleExceptions(const u8* data, size_t bytes
{
if (sizeof(u16) + *bytes_used > bytes_allocated)
{
ERROR_LOG(DISCIO, "More hash exceptions than expected");
ERROR_LOG_FMT(DISCIO, "More hash exceptions than expected");
return false;
}
if (sizeof(u16) + *bytes_used > bytes_written)
@@ -799,7 +797,7 @@ bool WIARVZFileReader<RVZ>::Chunk::HandleExceptions(const u8* data, size_t bytes

if (exception_list_size + *bytes_used > bytes_allocated)
{
ERROR_LOG(DISCIO, "More hash exceptions than expected");
ERROR_LOG_FMT(DISCIO, "More hash exceptions than expected");
return false;
}
if (exception_list_size + *bytes_used > bytes_written)
@@ -950,17 +948,17 @@ ConversionResultCode WIARVZFileReader<RVZ>::SetUpDataEntriesForWriting(

if (partition.offset < last_partition_end_offset)
{
WARN_LOG(DISCIO, "Overlapping partitions at %" PRIx64, partition.offset);
WARN_LOG_FMT(DISCIO, "Overlapping partitions at {:x}", partition.offset);
continue;
}

if (volume->ReadSwapped<u32>(partition.offset, PARTITION_NONE) != u32(0x10001))
if (volume->ReadSwapped<u32>(partition.offset, PARTITION_NONE) != 0x10001U)
{
// This looks more like garbage data than an actual partition.
// The values of data_offset and data_size will very likely also be garbage.
// Some WBFS writing programs scrub the SSBB Masterpiece partitions without
// removing them from the partition table, causing this problem.
WARN_LOG(DISCIO, "Invalid partition at %" PRIx64, partition.offset);
WARN_LOG_FMT(DISCIO, "Invalid partition at {:x}", partition.offset);
continue;
}

@@ -977,19 +975,19 @@ ConversionResultCode WIARVZFileReader<RVZ>::SetUpDataEntriesForWriting(

if (data_start % VolumeWii::BLOCK_TOTAL_SIZE != 0)
{
WARN_LOG(DISCIO, "Misaligned partition at %" PRIx64, partition.offset);
WARN_LOG_FMT(DISCIO, "Misaligned partition at {:x}", partition.offset);
continue;
}

if (*data_size < VolumeWii::BLOCK_TOTAL_SIZE)
{
WARN_LOG(DISCIO, "Very small partition at %" PRIx64, partition.offset);
WARN_LOG_FMT(DISCIO, "Very small partition at {:x}", partition.offset);
continue;
}

if (data_end > iso_size)
{
WARN_LOG(DISCIO, "Too large partition at %" PRIx64, partition.offset);
WARN_LOG_FMT(DISCIO, "Too large partition at {:x}", partition.offset);
*data_size = iso_size - *data_offset - partition.offset;
}

@@ -1711,7 +1709,8 @@ bool WIARVZFileReader<RVZ>::WriteHeader(File::IOFile* file, const u8* data, size
// is past the upper bound, we are already at the end of the file, so we don't need to do anything
if (*bytes_written <= upper_bound && *bytes_written + size > upper_bound)
{
WARN_LOG(DISCIO, "Headers did not fit in the allocated space. Writing to end of file instead");
WARN_LOG_FMT(DISCIO,
"Headers did not fit in the allocated space. Writing to end of file instead");
if (!file->Seek(0, SEEK_END))
return false;
*bytes_written = file->Tell();