diff --git a/Drv/LinuxGpioDriver/LinuxGpioDriver.cpp b/Drv/LinuxGpioDriver/LinuxGpioDriver.cpp index e0d69a56a1..e2ac6c8a1c 100644 --- a/Drv/LinuxGpioDriver/LinuxGpioDriver.cpp +++ b/Drv/LinuxGpioDriver/LinuxGpioDriver.cpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace Drv { @@ -287,9 +288,13 @@ Drv::GpioStatus LinuxGpioDriver ::gpioWrite_handler(const NATIVE_INT_TYPE portNu } void LinuxGpioDriver ::pollLoop() { - static_assert(GPIO_POLL_TIMEOUT < std::numeric_limits::max(), "Poll timeout would overflow"); + // Ensure size of FwSizeType is large enough to fit the necessary ranges + // NOTE: casts to unsigned types for int and ssize_t are made to avoid sign-compare warning; + // in both cases the cast is safe because max() returns nonnegative value. + static_assert(GPIO_POLL_TIMEOUT < static_cast(std::numeric_limits::max()), "Poll timeout would overflow"); static_assert(sizeof(struct gpioevent_data) < std::numeric_limits::max(), "FwSizeType too small"); - static_assert(std::numeric_limits::max() <= std::numeric_limits::max(), "FwSizeType too small"); + using unsigned_ssize_t = std::make_unsigned::type; + static_assert(static_cast(std::numeric_limits::max()) <= std::numeric_limits::max(), "FwSizeType too small"); // Setup poll information pollfd file_descriptors[1]; // Loop forever