summaryrefslogtreecommitdiff
path: root/src/common/hex_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/hex_util.h')
-rw-r--r--src/common/hex_util.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/common/hex_util.h b/src/common/hex_util.h
index 120f1a5e6..a8d414fb8 100644
--- a/src/common/hex_util.h
+++ b/src/common/hex_util.h
@@ -16,14 +16,14 @@ namespace Common {
16 16
17[[nodiscard]] constexpr u8 ToHexNibble(char c) { 17[[nodiscard]] constexpr u8 ToHexNibble(char c) {
18 if (c >= 65 && c <= 70) { 18 if (c >= 65 && c <= 70) {
19 return c - 55; 19 return static_cast<u8>(c - 55);
20 } 20 }
21 21
22 if (c >= 97 && c <= 102) { 22 if (c >= 97 && c <= 102) {
23 return c - 87; 23 return static_cast<u8>(c - 87);
24 } 24 }
25 25
26 return c - 48; 26 return static_cast<u8>(c - 48);
27} 27}
28 28
29[[nodiscard]] std::vector<u8> HexStringToVector(std::string_view str, bool little_endian); 29[[nodiscard]] std::vector<u8> HexStringToVector(std::string_view str, bool little_endian);
@@ -33,11 +33,11 @@ template <std::size_t Size, bool le = false>
33 std::array<u8, Size> out{}; 33 std::array<u8, Size> out{};
34 if constexpr (le) { 34 if constexpr (le) {
35 for (std::size_t i = 2 * Size - 2; i <= 2 * Size; i -= 2) { 35 for (std::size_t i = 2 * Size - 2; i <= 2 * Size; i -= 2) {
36 out[i / 2] = (ToHexNibble(str[i]) << 4) | ToHexNibble(str[i + 1]); 36 out[i / 2] = static_cast<u8>((ToHexNibble(str[i]) << 4) | ToHexNibble(str[i + 1]));
37 } 37 }
38 } else { 38 } else {
39 for (std::size_t i = 0; i < 2 * Size; i += 2) { 39 for (std::size_t i = 0; i < 2 * Size; i += 2) {
40 out[i / 2] = (ToHexNibble(str[i]) << 4) | ToHexNibble(str[i + 1]); 40 out[i / 2] = static_cast<u8>((ToHexNibble(str[i]) << 4) | ToHexNibble(str[i + 1]));
41 } 41 }
42 } 42 }
43 return out; 43 return out;