mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-10-30 15:39:02 -05:00 
			
		
		
		
	patch_manager: Resolve implicit truncations in FormatTitleVersion()
We make it explicit that we're truncating arithmetic here to resolve compiler warnings (even if the sizes weren't u32/u64 arithmetic generally promotes to int :<)
This commit is contained in:
		| @@ -45,14 +45,15 @@ enum class TitleVersionFormat : u8 { | |||||||
| std::string FormatTitleVersion(u32 version, | std::string FormatTitleVersion(u32 version, | ||||||
|                                TitleVersionFormat format = TitleVersionFormat::ThreeElements) { |                                TitleVersionFormat format = TitleVersionFormat::ThreeElements) { | ||||||
|     std::array<u8, sizeof(u32)> bytes{}; |     std::array<u8, sizeof(u32)> bytes{}; | ||||||
|     bytes[0] = version % SINGLE_BYTE_MODULUS; |     bytes[0] = static_cast<u8>(version % SINGLE_BYTE_MODULUS); | ||||||
|     for (std::size_t i = 1; i < bytes.size(); ++i) { |     for (std::size_t i = 1; i < bytes.size(); ++i) { | ||||||
|         version /= SINGLE_BYTE_MODULUS; |         version /= SINGLE_BYTE_MODULUS; | ||||||
|         bytes[i] = version % SINGLE_BYTE_MODULUS; |         bytes[i] = static_cast<u8>(version % SINGLE_BYTE_MODULUS); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (format == TitleVersionFormat::FourElements) |     if (format == TitleVersionFormat::FourElements) { | ||||||
|         return fmt::format("v{}.{}.{}.{}", bytes[3], bytes[2], bytes[1], bytes[0]); |         return fmt::format("v{}.{}.{}.{}", bytes[3], bytes[2], bytes[1], bytes[0]); | ||||||
|  |     } | ||||||
|     return fmt::format("v{}.{}.{}", bytes[3], bytes[2], bytes[1]); |     return fmt::format("v{}.{}.{}", bytes[3], bytes[2], bytes[1]); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Lioncash
					Lioncash