diff options
| author | 2018-09-25 18:25:10 -0400 | |
|---|---|---|
| committer | 2018-09-25 20:06:21 -0400 | |
| commit | 4654f896184fa1b97df5920ef775f033c2b2fcbb (patch) | |
| tree | ec4de57719d35ff3350f2a82ce67649e3444d134 /src | |
| parent | fsmitm_romfsbuild: Remove unnecessary constructors and initializers for RomFS... (diff) | |
| download | yuzu-4654f896184fa1b97df5920ef775f033c2b2fcbb.tar.gz yuzu-4654f896184fa1b97df5920ef775f033c2b2fcbb.tar.xz yuzu-4654f896184fa1b97df5920ef775f033c2b2fcbb.zip | |
fsmitm_romfsbuild: Avoid type truncation warnings
Cast where explicitly necessary and in other cases we can simply modify
the algorithm to accomodate larger data.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/file_sys/fsmitm_romfsbuild.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/core/file_sys/fsmitm_romfsbuild.cpp b/src/core/file_sys/fsmitm_romfsbuild.cpp index 20dd69570..07b074817 100644 --- a/src/core/file_sys/fsmitm_romfsbuild.cpp +++ b/src/core/file_sys/fsmitm_romfsbuild.cpp | |||
| @@ -105,13 +105,16 @@ static u32 romfs_calc_path_hash(u32 parent, std::string path, u32 start, std::si | |||
| 105 | return hash; | 105 | return hash; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | static u32 romfs_get_hash_table_count(u32 num_entries) { | 108 | static u64 romfs_get_hash_table_count(u64 num_entries) { |
| 109 | if (num_entries < 3) { | 109 | if (num_entries < 3) { |
| 110 | return 3; | 110 | return 3; |
| 111 | } else if (num_entries < 19) { | 111 | } |
| 112 | |||
| 113 | if (num_entries < 19) { | ||
| 112 | return num_entries | 1; | 114 | return num_entries | 1; |
| 113 | } | 115 | } |
| 114 | u32 count = num_entries; | 116 | |
| 117 | u64 count = num_entries; | ||
| 115 | while (count % 2 == 0 || count % 3 == 0 || count % 5 == 0 || count % 7 == 0 || | 118 | while (count % 2 == 0 || count % 3 == 0 || count % 5 == 0 || count % 7 == 0 || |
| 116 | count % 11 == 0 || count % 13 == 0 || count % 17 == 0) { | 119 | count % 11 == 0 || count % 13 == 0 || count % 17 == 0) { |
| 117 | count++; | 120 | count++; |
| @@ -137,7 +140,7 @@ void RomFSBuildContext::VisitDirectory(VirtualDir root_romfs, | |||
| 137 | const auto child = std::make_shared<RomFSBuildDirectoryContext>(); | 140 | const auto child = std::make_shared<RomFSBuildDirectoryContext>(); |
| 138 | // Set child's path. | 141 | // Set child's path. |
| 139 | child->cur_path_ofs = parent->path_len + 1; | 142 | child->cur_path_ofs = parent->path_len + 1; |
| 140 | child->path_len = child->cur_path_ofs + kv.first.size(); | 143 | child->path_len = child->cur_path_ofs + static_cast<u32>(kv.first.size()); |
| 141 | child->path = parent->path + "/" + kv.first; | 144 | child->path = parent->path + "/" + kv.first; |
| 142 | 145 | ||
| 143 | // Sanity check on path_len | 146 | // Sanity check on path_len |
| @@ -150,7 +153,7 @@ void RomFSBuildContext::VisitDirectory(VirtualDir root_romfs, | |||
| 150 | const auto child = std::make_shared<RomFSBuildFileContext>(); | 153 | const auto child = std::make_shared<RomFSBuildFileContext>(); |
| 151 | // Set child's path. | 154 | // Set child's path. |
| 152 | child->cur_path_ofs = parent->path_len + 1; | 155 | child->cur_path_ofs = parent->path_len + 1; |
| 153 | child->path_len = child->cur_path_ofs + kv.first.size(); | 156 | child->path_len = child->cur_path_ofs + static_cast<u32>(kv.first.size()); |
| 154 | child->path = parent->path + "/" + kv.first; | 157 | child->path = parent->path + "/" + kv.first; |
| 155 | 158 | ||
| 156 | // Sanity check on path_len | 159 | // Sanity check on path_len |
| @@ -217,8 +220,8 @@ RomFSBuildContext::RomFSBuildContext(VirtualDir base_) : base(std::move(base_)) | |||
| 217 | RomFSBuildContext::~RomFSBuildContext() = default; | 220 | RomFSBuildContext::~RomFSBuildContext() = default; |
| 218 | 221 | ||
| 219 | std::map<u64, VirtualFile> RomFSBuildContext::Build() { | 222 | std::map<u64, VirtualFile> RomFSBuildContext::Build() { |
| 220 | const auto dir_hash_table_entry_count = romfs_get_hash_table_count(num_dirs); | 223 | const u64 dir_hash_table_entry_count = romfs_get_hash_table_count(num_dirs); |
| 221 | const auto file_hash_table_entry_count = romfs_get_hash_table_count(num_files); | 224 | const u64 file_hash_table_entry_count = romfs_get_hash_table_count(num_files); |
| 222 | dir_hash_table_size = 4 * dir_hash_table_entry_count; | 225 | dir_hash_table_size = 4 * dir_hash_table_entry_count; |
| 223 | file_hash_table_size = 4 * file_hash_table_entry_count; | 226 | file_hash_table_size = 4 * file_hash_table_entry_count; |
| 224 | 227 | ||