From b1a2dec78af6e2bc99ebbc8c0ade50dbf8ac6f0e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 4 Jan 2017 19:53:31 -0500 Subject: [PATCH 1/4] DiscScrubber: Convert a #define into a typed constant --- Source/Core/DiscIO/DiscScrubber.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index 2f7ab75f78..f3f8c6075f 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -20,7 +20,7 @@ namespace DiscIO { -#define CLUSTER_SIZE 0x8000 +constexpr size_t CLUSTER_SIZE = 0x8000; DiscScrubber::DiscScrubber() = default; DiscScrubber::~DiscScrubber() = default; @@ -43,17 +43,17 @@ bool DiscScrubber::SetupScrub(const std::string& filename, int block_size) m_file_size = m_disc->GetSize(); - u32 numClusters = (u32)(m_file_size / CLUSTER_SIZE); + const size_t num_clusters = static_cast(m_file_size / CLUSTER_SIZE); // Warn if not DVD5 or DVD9 size - if (numClusters != 0x23048 && numClusters != 0x46090) + if (num_clusters != 0x23048 && num_clusters != 0x46090) { - WARN_LOG(DISCIO, "%s is not a standard sized Wii disc! (%x blocks)", filename.c_str(), - numClusters); + WARN_LOG(DISCIO, "%s is not a standard sized Wii disc! (%zx blocks)", filename.c_str(), + num_clusters); } // Table of free blocks - m_free_table.resize(numClusters, 1); + m_free_table.resize(num_clusters, 1); // Fill out table of free blocks const bool success = ParseDisc(); From 6ff21c48cba204b6392eb622ede213e4389cb3a9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 4 Jan 2017 19:56:39 -0500 Subject: [PATCH 2/4] DiscScrubber: Correct printf specifiers --- Source/Core/DiscIO/DiscScrubber.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index f3f8c6075f..c41e402b28 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -32,7 +32,7 @@ bool DiscScrubber::SetupScrub(const std::string& filename, int block_size) if (CLUSTER_SIZE % m_block_size != 0) { - ERROR_LOG(DISCIO, "Block size %i is not a factor of 0x8000, scrubbing not possible", + ERROR_LOG(DISCIO, "Block size %u is not a factor of 0x8000, scrubbing not possible", m_block_size); return false; } @@ -219,7 +219,7 @@ bool DiscScrubber::ParsePartitionData(Partition& partition) std::unique_ptr filesystem(CreateFileSystem(m_disc.get())); if (!filesystem) { - ERROR_LOG(DISCIO, "Failed to create filesystem for group %d partition %u", + ERROR_LOG(DISCIO, "Failed to create filesystem for group %u partition %u", partition.group_number, partition.number); parsed_ok = false; } From c52d1e735ab1a083cfdf0c087f70a1c7aef9b72f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 4 Jan 2017 20:03:09 -0500 Subject: [PATCH 3/4] DiscScrubber: Use an unsigned loop index in ParseDisc Prevents an implicit signed to unsigned conversion when assigning a partition's group number. --- Source/Core/DiscIO/DiscScrubber.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index c41e402b28..bceda5c484 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -142,7 +142,7 @@ bool DiscScrubber::ParseDisc() // Mark the header as used - it's mostly 0s anyways MarkAsUsed(0, 0x50000); - for (int x = 0; x < 4; x++) + for (u32 x = 0; x < 4; x++) { if (!ReadFromVolume(0x40000 + (x * 8) + 0, m_partition_group[x].num_partitions, false) || !ReadFromVolume(0x40000 + (x * 8) + 4, m_partition_group[x].partitions_offset, false)) From a93861ab497bdbab42b4ebbe69f5322140275021 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 4 Jan 2017 20:12:47 -0500 Subject: [PATCH 4/4] DiscScrubber: Don't take SFileInfo instances by value Avoids unnecessary copies. --- Source/Core/DiscIO/DiscScrubber.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/DiscIO/DiscScrubber.cpp b/Source/Core/DiscIO/DiscScrubber.cpp index bceda5c484..e00311e86f 100644 --- a/Source/Core/DiscIO/DiscScrubber.cpp +++ b/Source/Core/DiscIO/DiscScrubber.cpp @@ -247,7 +247,7 @@ bool DiscScrubber::ParsePartitionData(Partition& partition) partition.header.fst_size); // Go through the filesystem and mark entries as used - for (SFileInfo file : filesystem->GetFileList()) + for (const SFileInfo& file : filesystem->GetFileList()) { DEBUG_LOG(DISCIO, "%s", file.m_FullPath.empty() ? "/" : file.m_FullPath.c_str()); if ((file.m_NameOffset & 0x1000000) == 0)