Fix build issues
* Fix casting issues that are causing the build to fail.
* Fix gtest warnings by updating the source revision
Change-Id: Id6eb6b1fef335f88e7e12074f712b82ecd1a233a
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/CMakeLists.txt.in b/CMakeLists.txt.in
index c24d360..21a1041 100644
--- a/CMakeLists.txt.in
+++ b/CMakeLists.txt.in
@@ -55,7 +55,7 @@
externalproject_add (gtest GIT_REPOSITORY
"https://github.com/google/googletest.git" GIT_TAG
- dfa853b63d17c787914b663b50c2095a0c5b706e CMAKE_ARGS
+ 7153098229e88295f9655ff1d3b0e2fa9eada5f8 CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/googletest-build
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" BINARY_DIR
"${CMAKE_BINARY_DIR}/googletest-build" CMAKE_ARGS
diff --git a/include/types.hpp b/include/types.hpp
index 2f65646..373835c 100644
--- a/include/types.hpp
+++ b/include/types.hpp
@@ -38,4 +38,32 @@
using SensorMap = std::map<std::string, std::map<std::string, DbusVariant>>;
+namespace types
+{
+namespace details
+{
+
+template <typename U>
+using underlying_t =
+ typename std::conditional_t<std::is_enum_v<U>, std::underlying_type<U>,
+ std::enable_if<true, U>>::type;
+} // namespace details
+
+/**
+ * @brief Converts a number or enum class to another
+ * @tparam R - The output type
+ * @tparam T - The input type
+ * @param t - An enum or integer value to cast
+ * @return The value in R form
+ */
+template <typename R, typename T>
+inline R enum_cast(T t)
+{
+ auto tu = static_cast<details::underlying_t<T>>(t);
+ auto ru = static_cast<details::underlying_t<R>>(tu);
+ return static_cast<R>(ru);
+}
+
+} // namespace types
+
} // namespace ipmi
diff --git a/src/chassiscommands.cpp b/src/chassiscommands.cpp
index 1ff29c2..360e787 100644
--- a/src/chassiscommands.cpp
+++ b/src/chassiscommands.cpp
@@ -512,7 +512,7 @@
constexpr bool coolingFanFault = false;
// chassisIdentifySupport set because this command is implemented
constexpr bool chassisIdentifySupport = true;
- uint2_t chassisIdentifyState = chassisIDState;
+ uint2_t chassisIdentifyState = types::enum_cast<uint2_t>(chassisIDState);
constexpr bool sleepButtonDisabled = false;
constexpr bool sleepButtonDisableAllow = false;
diff --git a/src/oemcommands.cpp b/src/oemcommands.cpp
index 46566a3..fe589de 100644
--- a/src/oemcommands.cpp
+++ b/src/oemcommands.cpp
@@ -741,14 +741,18 @@
uint6_t cpu3CATERRCount = 0;
uint6_t cpu4CATERRCount = 0;
uint8_t crashdumpCount = 0;
- uint2_t cpu1Status =
- cpuPresent("CPU_1") ? CPUStatus::enabled : CPUStatus::notPresent;
- uint2_t cpu2Status =
- cpuPresent("CPU_2") ? CPUStatus::enabled : CPUStatus::notPresent;
- uint2_t cpu3Status =
- cpuPresent("CPU_3") ? CPUStatus::enabled : CPUStatus::notPresent;
- uint2_t cpu4Status =
- cpuPresent("CPU_4") ? CPUStatus::enabled : CPUStatus::notPresent;
+ uint2_t cpu1Status = cpuPresent("CPU_1")
+ ? types::enum_cast<uint8_t>(CPUStatus::enabled)
+ : types::enum_cast<uint8_t>(CPUStatus::notPresent);
+ uint2_t cpu2Status = cpuPresent("CPU_2")
+ ? types::enum_cast<uint8_t>(CPUStatus::enabled)
+ : types::enum_cast<uint8_t>(CPUStatus::notPresent);
+ uint2_t cpu3Status = cpuPresent("CPU_3")
+ ? types::enum_cast<uint8_t>(CPUStatus::enabled)
+ : types::enum_cast<uint8_t>(CPUStatus::notPresent);
+ uint2_t cpu4Status = cpuPresent("CPU_4")
+ ? types::enum_cast<uint8_t>(CPUStatus::enabled)
+ : types::enum_cast<uint8_t>(CPUStatus::notPresent);
std::shared_ptr<sdbusplus::asio::connection> busp = getSdBus();
try