Merge pull request #8125 from lioncash/verify

DiscIO/VolumeVerifier: Make use of unused variable (+ minor other changes)
This commit is contained in:
Léo Lam 2019-05-27 19:03:13 +02:00 committed by GitHub
commit 525c65dd19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 41 deletions

View file

@ -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_volume(volume), m_hashes_to_calculate(hashes_to_calculate),
m_calculating_any_hash(hashes_to_calculate.crc32 || hashes_to_calculate.md5 || m_calculating_any_hash(hashes_to_calculate.crc32 || hashes_to_calculate.md5 ||
hashes_to_calculate.sha1), 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() void VolumeVerifier::Start()
{ {
ASSERT(!m_started); ASSERT(!m_started);
@ -191,9 +193,9 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
if (m_volume.SupportsIntegrityCheck() && !m_volume.CheckH3TableIntegrity(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()); 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; 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 // 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 Masterpiece partitions in Super Smash Bros. Brawl without removing them from
// the partition table. https://bugs.dolphin-emu.org/issues/8733 // 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()); 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; return false;
} }
const DiscIO::FileSystem* filesystem = m_volume.GetFileSystem(partition); const DiscIO::FileSystem* filesystem = m_volume.GetFileSystem(partition);
if (!filesystem) 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()); 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; return false;
} }
@ -306,7 +308,7 @@ std::string VolumeVerifier::GetPartitionName(std::optional<u32> type) const
return name; 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; IOS::HLE::Kernel ios;
const auto es = ios.GetES(); const auto es = ios.GetES();
@ -321,7 +323,7 @@ void VolumeVerifier::CheckCorrectlySigned(const Partition& partition, const std:
IOS::HLE::Device::ES::VerifyMode::DoNotUpdateCertStore, IOS::HLE::Device::ES::VerifyMode::DoNotUpdateCertStore,
m_volume.GetTMD(partition), cert_chain)) m_volume.GetTMD(partition), cert_chain))
{ {
AddProblem(Severity::Low, error_text); AddProblem(Severity::Low, std::move(error_text));
} }
} }
@ -377,7 +379,7 @@ void VolumeVerifier::CheckDiscSize()
{ {
const bool second_layer_missing = const bool second_layer_missing =
biggest_offset > SL_DVD_SIZE && m_volume.GetSize() >= SL_DVD_SIZE; biggest_offset > SL_DVD_SIZE && m_volume.GetSize() >= SL_DVD_SIZE;
const std::string text = std::string text =
second_layer_missing ? second_layer_missing ?
GetStringT( GetStringT(
"This disc image is too small and lacks some data. The problem is most likely that " "This disc image is too small and lacks some data. The problem is most likely that "
@ -385,7 +387,7 @@ void VolumeVerifier::CheckDiscSize()
GetStringT( GetStringT(
"This disc image is too small and lacks some data. If your dumping program saved " "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."); "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; return;
} }
@ -444,7 +446,7 @@ void VolumeVerifier::CheckDiscSize()
} }
} }
u64 VolumeVerifier::GetBiggestUsedOffset() u64 VolumeVerifier::GetBiggestUsedOffset() const
{ {
std::vector<Partition> partitions = m_volume.GetPartitions(); std::vector<Partition> partitions = m_volume.GetPartitions();
if (partitions.empty()) if (partitions.empty())
@ -601,7 +603,7 @@ void VolumeVerifier::CheckMisc()
const Severity severity = const Severity severity =
m_volume.GetVolumeType() == Platform::WiiWAD ? Severity::Low : Severity::High; m_volume.GetVolumeType() == Platform::WiiWAD ? Severity::Low : Severity::High;
// i18n: This is "common" as in "shared", not the opposite of "uncommon" // 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) 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 name = GetPartitionName(m_volume.GetPartitionType(partition));
const std::string text = StringFromFormat( std::string text = StringFromFormat(
GetStringT("Errors were found in %zu blocks in the %s partition.").c_str(), pair.second, GetStringT("Errors were found in %zu blocks in the %s partition.").c_str(), blocks,
name.c_str()); 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 name = GetPartitionName(m_volume.GetPartitionType(partition));
const std::string text = StringFromFormat( std::string text = StringFromFormat(
GetStringT("Errors were found in %zu unused blocks in the %s partition.").c_str(), GetStringT("Errors were found in %zu unused blocks in the %s partition.").c_str(), blocks,
pair.second, name.c_str()); name.c_str());
AddProblem(Severity::Low, text); AddProblem(Severity::Low, std::move(text));
} }
} }
@ -904,9 +906,9 @@ const VolumeVerifier::Result& VolumeVerifier::GetResult() const
return m_result; 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 } // namespace DiscIO

View file

@ -72,6 +72,8 @@ public:
}; };
VolumeVerifier(const Volume& volume, Hashes<bool> hashes_to_calculate); VolumeVerifier(const Volume& volume, Hashes<bool> hashes_to_calculate);
~VolumeVerifier();
void Start(); void Start();
void Process(); void Process();
u64 GetBytesProcessed() const; u64 GetBytesProcessed() const;
@ -90,30 +92,30 @@ private:
void CheckPartitions(); void CheckPartitions();
bool CheckPartition(const Partition& partition); // Returns false if partition should be ignored bool CheckPartition(const Partition& partition); // Returns false if partition should be ignored
std::string GetPartitionName(std::optional<u32> type) const; 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 IsDebugSigned() const;
bool ShouldHaveChannelPartition() const; bool ShouldHaveChannelPartition() const;
bool ShouldHaveInstallPartition() const; bool ShouldHaveInstallPartition() const;
bool ShouldHaveMasterpiecePartitions() const; bool ShouldHaveMasterpiecePartitions() const;
bool ShouldBeDualLayer() const; bool ShouldBeDualLayer() const;
void CheckDiscSize(); void CheckDiscSize();
u64 GetBiggestUsedOffset(); u64 GetBiggestUsedOffset() const;
u64 GetBiggestUsedOffset(const FileInfo& file_info) const; u64 GetBiggestUsedOffset(const FileInfo& file_info) const;
void CheckMisc(); void CheckMisc();
void SetUpHashing(); void SetUpHashing();
bool CheckContentIntegrity(const IOS::ES::Content& content); 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; const Volume& m_volume;
Result m_result; Result m_result;
bool m_is_tgc; bool m_is_tgc = false;
bool m_is_datel; bool m_is_datel = false;
bool m_is_not_retail; bool m_is_not_retail = false;
Hashes<bool> m_hashes_to_calculate; Hashes<bool> m_hashes_to_calculate{};
bool m_calculating_any_hash; bool m_calculating_any_hash = false;
unsigned long m_crc32_context; unsigned long m_crc32_context = 0;
mbedtls_md5_context m_md5_context; mbedtls_md5_context m_md5_context;
mbedtls_sha1_context m_sha1_context; mbedtls_sha1_context m_sha1_context;
@ -125,10 +127,10 @@ private:
std::map<Partition, size_t> m_block_errors; std::map<Partition, size_t> m_block_errors;
std::map<Partition, size_t> m_unused_block_errors; std::map<Partition, size_t> m_unused_block_errors;
bool m_started; bool m_started = false;
bool m_done; bool m_done = false;
u64 m_progress; u64 m_progress = 0;
u64 m_max_progress; u64 m_max_progress = 0;
}; };
} // namespace DiscIO } // namespace DiscIO