summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Markus Wick2021-06-10 21:07:27 +0200
committerGravatar Markus Wick2021-06-10 21:07:27 +0200
commit6755025310335abdb655c11fc65801fee99bb3d9 (patch)
tree6e4dd0bc6f2feb5e10ac6f101883fd9cfaa27be5 /src
parenthle: service: Increase arbitrary max sessions limit. (diff)
downloadyuzu-6755025310335abdb655c11fc65801fee99bb3d9.tar.gz
yuzu-6755025310335abdb655c11fc65801fee99bb3d9.tar.xz
yuzu-6755025310335abdb655c11fc65801fee99bb3d9.zip
Fix GCC undefined behavior sanitizer.
* Wrong alignment in u64 LOG_DEBUG -> memcpy. * Huge shift exponent in stride calculation for linear buffer, unused result -> skipped. * Large shift in buffer cache if word = 0, skip checking for set bits. Non of those were critical, so this should not change any behavior. At least with the assumption, that the last one used masking behavior, which always yield continuous_bits = 0.
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/program_metadata.cpp4
-rw-r--r--src/video_core/buffer_cache/buffer_base.h3
-rw-r--r--src/video_core/texture_cache/util.cpp3
3 files changed, 9 insertions, 1 deletions
diff --git a/src/core/file_sys/program_metadata.cpp b/src/core/file_sys/program_metadata.cpp
index 83b83a044..01ae1a567 100644
--- a/src/core/file_sys/program_metadata.cpp
+++ b/src/core/file_sys/program_metadata.cpp
@@ -150,7 +150,9 @@ void ProgramMetadata::Print() const {
150 LOG_DEBUG(Service_FS, " > Is Retail: {}", acid_header.is_retail ? "YES" : "NO"); 150 LOG_DEBUG(Service_FS, " > Is Retail: {}", acid_header.is_retail ? "YES" : "NO");
151 LOG_DEBUG(Service_FS, "Title ID Min: 0x{:016X}", acid_header.title_id_min); 151 LOG_DEBUG(Service_FS, "Title ID Min: 0x{:016X}", acid_header.title_id_min);
152 LOG_DEBUG(Service_FS, "Title ID Max: 0x{:016X}", acid_header.title_id_max); 152 LOG_DEBUG(Service_FS, "Title ID Max: 0x{:016X}", acid_header.title_id_max);
153 LOG_DEBUG(Service_FS, "Filesystem Access: 0x{:016X}\n", acid_file_access.permissions); 153 u64_le permissions_l; // local copy to fix alignment error
154 std::memcpy(&permissions_l, &acid_file_access.permissions, sizeof(permissions_l));
155 LOG_DEBUG(Service_FS, "Filesystem Access: 0x{:016X}\n", permissions_l);
154 156
155 // Begin ACI0 printing (actual perms, unsigned) 157 // Begin ACI0 printing (actual perms, unsigned)
156 LOG_DEBUG(Service_FS, "Magic: {:.4}", aci_header.magic.data()); 158 LOG_DEBUG(Service_FS, "Magic: {:.4}", aci_header.magic.data());
diff --git a/src/video_core/buffer_cache/buffer_base.h b/src/video_core/buffer_cache/buffer_base.h
index 0c00ae280..a39505903 100644
--- a/src/video_core/buffer_cache/buffer_base.h
+++ b/src/video_core/buffer_cache/buffer_base.h
@@ -476,6 +476,9 @@ private:
476 current_size = 0; 476 current_size = 0;
477 on_going = false; 477 on_going = false;
478 } 478 }
479 if (empty_bits == PAGES_PER_WORD) {
480 break;
481 }
479 page += empty_bits; 482 page += empty_bits;
480 483
481 const int continuous_bits = std::countr_one(word >> page); 484 const int continuous_bits = std::countr_one(word >> page);
diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp
index 8c4a5523b..906604a39 100644
--- a/src/video_core/texture_cache/util.cpp
+++ b/src/video_core/texture_cache/util.cpp
@@ -647,6 +647,9 @@ u32 CalculateLayerSize(const ImageInfo& info) noexcept {
647} 647}
648 648
649LevelArray CalculateMipLevelOffsets(const ImageInfo& info) noexcept { 649LevelArray CalculateMipLevelOffsets(const ImageInfo& info) noexcept {
650 if (info.type == ImageType::Linear) {
651 return {};
652 }
650 ASSERT(info.resources.levels <= static_cast<s32>(MAX_MIP_LEVELS)); 653 ASSERT(info.resources.levels <= static_cast<s32>(MAX_MIP_LEVELS));
651 const LevelInfo level_info = MakeLevelInfo(info); 654 const LevelInfo level_info = MakeLevelInfo(info);
652 LevelArray offsets{}; 655 LevelArray offsets{};