Merge pull request #6445 from degasus/fix_ubsn

Fix GCC undefined behavior sanitizer.
This commit is contained in:
bunnei 2021-06-10 22:17:33 -07:00 committed by GitHub
commit 46ec0ee55b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -150,7 +150,9 @@ void ProgramMetadata::Print() const {
LOG_DEBUG(Service_FS, " > Is Retail: {}", acid_header.is_retail ? "YES" : "NO"); LOG_DEBUG(Service_FS, " > Is Retail: {}", acid_header.is_retail ? "YES" : "NO");
LOG_DEBUG(Service_FS, "Title ID Min: 0x{:016X}", acid_header.title_id_min); LOG_DEBUG(Service_FS, "Title ID Min: 0x{:016X}", acid_header.title_id_min);
LOG_DEBUG(Service_FS, "Title ID Max: 0x{:016X}", acid_header.title_id_max); LOG_DEBUG(Service_FS, "Title ID Max: 0x{:016X}", acid_header.title_id_max);
LOG_DEBUG(Service_FS, "Filesystem Access: 0x{:016X}\n", acid_file_access.permissions); u64_le permissions_l; // local copy to fix alignment error
std::memcpy(&permissions_l, &acid_file_access.permissions, sizeof(permissions_l));
LOG_DEBUG(Service_FS, "Filesystem Access: 0x{:016X}\n", permissions_l);
// Begin ACI0 printing (actual perms, unsigned) // Begin ACI0 printing (actual perms, unsigned)
LOG_DEBUG(Service_FS, "Magic: {:.4}", aci_header.magic.data()); LOG_DEBUG(Service_FS, "Magic: {:.4}", aci_header.magic.data());

View File

@ -476,6 +476,9 @@ private:
current_size = 0; current_size = 0;
on_going = false; on_going = false;
} }
if (empty_bits == PAGES_PER_WORD) {
break;
}
page += empty_bits; page += empty_bits;
const int continuous_bits = std::countr_one(word >> page); const int continuous_bits = std::countr_one(word >> page);

View File

@ -647,6 +647,9 @@ u32 CalculateLayerSize(const ImageInfo& info) noexcept {
} }
LevelArray CalculateMipLevelOffsets(const ImageInfo& info) noexcept { LevelArray CalculateMipLevelOffsets(const ImageInfo& info) noexcept {
if (info.type == ImageType::Linear) {
return {};
}
ASSERT(info.resources.levels <= static_cast<s32>(MAX_MIP_LEVELS)); ASSERT(info.resources.levels <= static_cast<s32>(MAX_MIP_LEVELS));
const LevelInfo level_info = MakeLevelInfo(info); const LevelInfo level_info = MakeLevelInfo(info);
LevelArray offsets{}; LevelArray offsets{};