Skip to content
Permalink
Browse files

Merge pull request #8125 from lioncash/verify

DiscIO/VolumeVerifier: Make use of unused variable (+ minor other changes)
  • Loading branch information...
leoetlino committed May 27, 2019
2 parents e3be168 + d220e33 commit 525c65dd1955e279dc2109d1c67c2029371e5c3b
Showing with 45 additions and 41 deletions.
  1. +30 −28 Source/Core/DiscIO/VolumeVerifier.cpp
  2. +15 −13 Source/Core/DiscIO/VolumeVerifier.h
@@ -50,10 +50,12 @@ VolumeVerifier::VolumeVerifier(const Volume& volume, Hashes<bool> hashes_to_calc
: m_volume(volume), m_hashes_to_calculate(hashes_to_calculate),
m_calculating_any_hash(hashes_to_calculate.crc32 || hashes_to_calculate.md5 ||
hashes_to_calculate.sha1),
m_started(false), m_done(false), m_progress(0), m_max_progress(volume.GetSize())
m_max_progress(volume.GetSize())
{
}

VolumeVerifier::~VolumeVerifier() = default;

void VolumeVerifier::Start()
{
ASSERT(!m_started);
@@ -191,9 +193,9 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)

if (m_volume.SupportsIntegrityCheck() && !m_volume.CheckH3TableIntegrity(partition))
{
const std::string text = StringFromFormat(
std::string text = StringFromFormat(
GetStringT("The H3 hash table for the %s partition is not correct.").c_str(), name.c_str());
AddProblem(Severity::Low, text);
AddProblem(Severity::Low, std::move(text));
}

bool invalid_disc_header = false;
@@ -224,18 +226,18 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
// This can happen when certain programs that create WBFS files scrub the entirety of
// the Masterpiece partitions in Super Smash Bros. Brawl without removing them from
// the partition table. https://bugs.dolphin-emu.org/issues/8733
const std::string text = StringFromFormat(
std::string text = StringFromFormat(
GetStringT("The %s partition does not seem to contain valid data.").c_str(), name.c_str());
AddProblem(severity, text);
AddProblem(severity, std::move(text));
return false;
}

const DiscIO::FileSystem* filesystem = m_volume.GetFileSystem(partition);
if (!filesystem)
{
const std::string text = StringFromFormat(
std::string text = StringFromFormat(
GetStringT("The %s partition does not have a valid file system.").c_str(), name.c_str());
AddProblem(severity, text);
AddProblem(severity, std::move(text));
return false;
}

@@ -306,7 +308,7 @@ std::string VolumeVerifier::GetPartitionName(std::optional<u32> type) const
return name;
}

void VolumeVerifier::CheckCorrectlySigned(const Partition& partition, const std::string& error_text)
void VolumeVerifier::CheckCorrectlySigned(const Partition& partition, std::string error_text)
{
IOS::HLE::Kernel ios;
const auto es = ios.GetES();
@@ -321,7 +323,7 @@ void VolumeVerifier::CheckCorrectlySigned(const Partition& partition, const std:
IOS::HLE::Device::ES::VerifyMode::DoNotUpdateCertStore,
m_volume.GetTMD(partition), cert_chain))
{
AddProblem(Severity::Low, error_text);
AddProblem(Severity::Low, std::move(error_text));
}
}

@@ -377,15 +379,15 @@ void VolumeVerifier::CheckDiscSize()
{
const bool second_layer_missing =
biggest_offset > SL_DVD_SIZE && m_volume.GetSize() >= SL_DVD_SIZE;
const std::string text =
std::string text =
second_layer_missing ?
GetStringT(
"This disc image is too small and lacks some data. The problem is most likely that "
"this is a dual-layer disc that has been dumped as a single-layer disc.") :
GetStringT(
"This disc image is too small and lacks some data. If your dumping program saved "
"the disc image as several parts, you need to merge them into one file.");
AddProblem(Severity::High, text);
AddProblem(Severity::High, std::move(text));
return;
}

@@ -444,7 +446,7 @@ void VolumeVerifier::CheckDiscSize()
}
}

u64 VolumeVerifier::GetBiggestUsedOffset()
u64 VolumeVerifier::GetBiggestUsedOffset() const
{
std::vector<Partition> partitions = m_volume.GetPartitions();
if (partitions.empty())
@@ -601,7 +603,7 @@ void VolumeVerifier::CheckMisc()
const Severity severity =
m_volume.GetVolumeType() == Platform::WiiWAD ? Severity::Low : Severity::High;
// i18n: This is "common" as in "shared", not the opposite of "uncommon"
AddProblem(Severity::Low, GetStringT("This title is set to use an invalid common key."));
AddProblem(severity, GetStringT("This title is set to use an invalid common key."));
}

if (common_key == 1 && region != Region::NTSC_K)
@@ -814,27 +816,27 @@ void VolumeVerifier::Finish()
}
}

for (auto pair : m_block_errors)
for (auto [partition, blocks] : m_block_errors)
{
if (pair.second > 0)
if (blocks > 0)
{
const std::string name = GetPartitionName(m_volume.GetPartitionType(pair.first));
const std::string text = StringFromFormat(
GetStringT("Errors were found in %zu blocks in the %s partition.").c_str(), pair.second,
const std::string name = GetPartitionName(m_volume.GetPartitionType(partition));
std::string text = StringFromFormat(
GetStringT("Errors were found in %zu blocks in the %s partition.").c_str(), blocks,
name.c_str());
AddProblem(Severity::Medium, text);
AddProblem(Severity::Medium, std::move(text));
}
}

for (auto pair : m_unused_block_errors)
for (auto [partition, blocks] : m_unused_block_errors)
{
if (pair.second > 0)
if (blocks > 0)
{
const std::string name = GetPartitionName(m_volume.GetPartitionType(pair.first));
const std::string text = StringFromFormat(
GetStringT("Errors were found in %zu unused blocks in the %s partition.").c_str(),
pair.second, name.c_str());
AddProblem(Severity::Low, text);
const std::string name = GetPartitionName(m_volume.GetPartitionType(partition));
std::string text = StringFromFormat(
GetStringT("Errors were found in %zu unused blocks in the %s partition.").c_str(), blocks,
name.c_str());
AddProblem(Severity::Low, std::move(text));
}
}

@@ -904,9 +906,9 @@ const VolumeVerifier::Result& VolumeVerifier::GetResult() const
return m_result;
}

void VolumeVerifier::AddProblem(Severity severity, const std::string& text)
void VolumeVerifier::AddProblem(Severity severity, std::string text)
{
m_result.problems.emplace_back(Problem{severity, text});
m_result.problems.emplace_back(Problem{severity, std::move(text)});
}

} // namespace DiscIO
@@ -72,6 +72,8 @@ class VolumeVerifier final
};

VolumeVerifier(const Volume& volume, Hashes<bool> hashes_to_calculate);
~VolumeVerifier();

void Start();
void Process();
u64 GetBytesProcessed() const;
@@ -90,30 +92,30 @@ class VolumeVerifier final
void CheckPartitions();
bool CheckPartition(const Partition& partition); // Returns false if partition should be ignored
std::string GetPartitionName(std::optional<u32> type) const;
void CheckCorrectlySigned(const Partition& partition, const std::string& error_text);
void CheckCorrectlySigned(const Partition& partition, std::string error_text);
bool IsDebugSigned() const;
bool ShouldHaveChannelPartition() const;
bool ShouldHaveInstallPartition() const;
bool ShouldHaveMasterpiecePartitions() const;
bool ShouldBeDualLayer() const;
void CheckDiscSize();
u64 GetBiggestUsedOffset();
u64 GetBiggestUsedOffset() const;
u64 GetBiggestUsedOffset(const FileInfo& file_info) const;
void CheckMisc();
void SetUpHashing();
bool CheckContentIntegrity(const IOS::ES::Content& content);

void AddProblem(Severity severity, const std::string& text);
void AddProblem(Severity severity, std::string text);

const Volume& m_volume;
Result m_result;
bool m_is_tgc;
bool m_is_datel;
bool m_is_not_retail;
bool m_is_tgc = false;
bool m_is_datel = false;
bool m_is_not_retail = false;

Hashes<bool> m_hashes_to_calculate;
bool m_calculating_any_hash;
unsigned long m_crc32_context;
Hashes<bool> m_hashes_to_calculate{};
bool m_calculating_any_hash = false;
unsigned long m_crc32_context = 0;
mbedtls_md5_context m_md5_context;
mbedtls_sha1_context m_sha1_context;

@@ -125,10 +127,10 @@ class VolumeVerifier final
std::map<Partition, size_t> m_block_errors;
std::map<Partition, size_t> m_unused_block_errors;

bool m_started;
bool m_done;
u64 m_progress;
u64 m_max_progress;
bool m_started = false;
bool m_done = false;
u64 m_progress = 0;
u64 m_max_progress = 0;
};

} // namespace DiscIO

0 comments on commit 525c65d

Please sign in to comment.
You can’t perform that action at this time.