hex_units: Fix Werror=conversion
Convert all types to uint8_t to not hit the conversion warning.
Change-Id: Ia535ca0a2f4045cbde06a2f8f8eaad9570a0f4a5
Signed-off-by: Willy Tu <wltu@google.com>
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/redfish-core/include/utils/hex_utils.hpp b/redfish-core/include/utils/hex_utils.hpp
index f3728ea..07ef4c8 100644
--- a/redfish-core/include/utils/hex_utils.hpp
+++ b/redfish-core/include/utils/hex_utils.hpp
@@ -43,11 +43,11 @@
}
else if (ch >= 'A' && ch <= 'F')
{
- rc = static_cast<uint8_t>(ch) - 'A' + 10;
+ rc = static_cast<uint8_t>(ch - 'A') + 10U;
}
else if (ch >= 'a' && ch <= 'f')
{
- rc = static_cast<uint8_t>(ch) - 'a' + 10;
+ rc = static_cast<uint8_t>(ch - 'a') + 10U;
}
return rc;
diff --git a/test/redfish-core/include/utils/hex_utils_test.cpp b/test/redfish-core/include/utils/hex_utils_test.cpp
index d96e4d4..c80158a 100644
--- a/test/redfish-core/include/utils/hex_utils_test.cpp
+++ b/test/redfish-core/include/utils/hex_utils_test.cpp
@@ -54,11 +54,11 @@
}
else if (c >= 'A' && c <= 'F')
{
- expected = static_cast<uint8_t>(c) - 'A' + 10;
+ expected = static_cast<uint8_t>(c - 'A') + 10U;
}
else if (c >= 'a' && c <= 'f')
{
- expected = static_cast<uint8_t>(c) - 'a' + 10;
+ expected = static_cast<uint8_t>(c - 'a') + 10U;
}
EXPECT_EQ(hexCharToNibble(c), expected);