diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/functional_interface.inl b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/functional_interface.inl index eed508f15d..81630fc550 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/functional_interface.inl +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/cxx/functional_interface.inl @@ -39,7 +39,8 @@ inline void Expect::expect(const StringType& msg) const noexcept { // it is possible that expect is called inside a signal handler therefore we // use write - IOX_DISCARD_RESULT(write(STDERR_FILENO, &msg[0], strlen(&msg[0]))); + auto result = write(STDERR_FILENO, &msg[0], strlen(&msg[0])); + IOX_DISCARD_RESULT(result); Ensures(false); } } @@ -57,7 +58,8 @@ inline ValueType& ExpectWithValue::expect(const StringType& { // it is possible that expect is called inside a signal handler therefore we // use write - IOX_DISCARD_RESULT(write(STDERR_FILENO, &msg[0], strlen(&msg[0]))); + auto result = write(STDERR_FILENO, &msg[0], strlen(&msg[0])); + IOX_DISCARD_RESULT(result); Ensures(false); } diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/semaphore_interface.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/semaphore_interface.hpp index 5b7b5310ea..acc0bac828 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/semaphore_interface.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/internal/posix_wrapper/semaphore_interface.hpp @@ -26,6 +26,7 @@ namespace posix { enum class SemaphoreError { + INVALID_NAME, INVALID_SEMAPHORE_HANDLE, SEMAPHORE_OVERFLOW, INTERRUPTED_BY_SIGNAL_HANDLER, diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_pipe.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_pipe.hpp index 9f4e189a51..b8a7dd6b0c 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_pipe.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/named_pipe.hpp @@ -39,7 +39,7 @@ class NamedPipe : public DesignPattern::Creation static constexpr uint64_t MAX_MESSAGE_SIZE = 4U * 1024U; static constexpr uint32_t MAX_NUMBER_OF_MESSAGES = 10U; static_assert( - MAX_NUMBER_OF_MESSAGES < 51, + MAX_NUMBER_OF_MESSAGES < IOX_SEM_VALUE_MAX, "The maximum number of supported messages must be less or equal to the maximum allowed semaphore value"); static constexpr uint64_t NULL_TERMINATOR_SIZE = 0U; diff --git a/iceoryx_hoofs/platform/linux/include/iceoryx_hoofs/platform/semaphore.hpp b/iceoryx_hoofs/platform/linux/include/iceoryx_hoofs/platform/semaphore.hpp index cbb0790932..2f3abeb5f2 100644 --- a/iceoryx_hoofs/platform/linux/include/iceoryx_hoofs/platform/semaphore.hpp +++ b/iceoryx_hoofs/platform/linux/include/iceoryx_hoofs/platform/semaphore.hpp @@ -17,12 +17,14 @@ #ifndef IOX_HOOFS_LINUX_PLATFORM_SEMAPHORE_HPP #define IOX_HOOFS_LINUX_PLATFORM_SEMAPHORE_HPP +#include +#include #include using iox_sem_t = sem_t; #define IOX_SEM_FAILED SEM_FAILED -#define IOX_SEM_VALUE_MAX SEM_VALUE_MAX +constexpr uint32_t IOX_SEM_VALUE_MAX = SEM_VALUE_MAX; inline int iox_sem_getvalue(iox_sem_t* sem, int* sval) { diff --git a/iceoryx_hoofs/platform/mac/include/iceoryx_hoofs/platform/semaphore.hpp b/iceoryx_hoofs/platform/mac/include/iceoryx_hoofs/platform/semaphore.hpp index 13677af2ca..899c886279 100644 --- a/iceoryx_hoofs/platform/mac/include/iceoryx_hoofs/platform/semaphore.hpp +++ b/iceoryx_hoofs/platform/mac/include/iceoryx_hoofs/platform/semaphore.hpp @@ -18,11 +18,12 @@ #define IOX_HOOFS_MAC_PLATFORM_SEMAPHORE_HPP #include +#include #include #include #define IOX_SEM_FAILED static_cast(nullptr) -#define IOX_SEM_VALUE_MAX SEM_VALUE_MAX +constexpr uint32_t IOX_SEM_VALUE_MAX = SEM_VALUE_MAX; struct iox_sem_t { diff --git a/iceoryx_hoofs/platform/qnx/include/iceoryx_hoofs/platform/semaphore.hpp b/iceoryx_hoofs/platform/qnx/include/iceoryx_hoofs/platform/semaphore.hpp index 27331fdf02..341e025541 100644 --- a/iceoryx_hoofs/platform/qnx/include/iceoryx_hoofs/platform/semaphore.hpp +++ b/iceoryx_hoofs/platform/qnx/include/iceoryx_hoofs/platform/semaphore.hpp @@ -17,12 +17,13 @@ #ifndef IOX_HOOFS_QNX_PLATFORM_SEMAPHORE_HPP #define IOX_HOOFS_QNX_PLATFORM_SEMAPHORE_HPP +#include #include using iox_sem_t = sem_t; #define IOX_SEM_FAILED SEM_FAILED -#define IOX_SEM_VALUE_MAX SEM_VALUE_MAX +constexpr uint32_t IOX_SEM_VALUE_MAX = SEM_VALUE_MAX; inline int iox_sem_getvalue(iox_sem_t* sem, int* sval) { diff --git a/iceoryx_hoofs/platform/unix/include/iceoryx_hoofs/platform/semaphore.hpp b/iceoryx_hoofs/platform/unix/include/iceoryx_hoofs/platform/semaphore.hpp index 10f2e17c3a..34a2031025 100644 --- a/iceoryx_hoofs/platform/unix/include/iceoryx_hoofs/platform/semaphore.hpp +++ b/iceoryx_hoofs/platform/unix/include/iceoryx_hoofs/platform/semaphore.hpp @@ -17,12 +17,13 @@ #ifndef IOX_HOOFS_UNIX_PLATFORM_SEMAPHORE_HPP #define IOX_HOOFS_UNIX_PLATFORM_SEMAPHORE_HPP +#include #include using iox_sem_t = sem_t; #define IOX_SEM_FAILED SEM_FAILED -#define IOX_SEM_VALUE_MAX SEM_VALUE_MAX +constexpr uint32_t IOX_SEM_VALUE_MAX = SEM_VALUE_MAX; inline int iox_sem_getvalue(iox_sem_t* sem, int* sval) { diff --git a/iceoryx_hoofs/platform/win/include/iceoryx_hoofs/platform/semaphore.hpp b/iceoryx_hoofs/platform/win/include/iceoryx_hoofs/platform/semaphore.hpp index c7616bb589..2d9020b5d0 100644 --- a/iceoryx_hoofs/platform/win/include/iceoryx_hoofs/platform/semaphore.hpp +++ b/iceoryx_hoofs/platform/win/include/iceoryx_hoofs/platform/semaphore.hpp @@ -24,6 +24,7 @@ #include "iceoryx_hoofs/platform/win32_errorHandling.hpp" #include "iceoryx_hoofs/platform/windows.hpp" +#include #include #include #include @@ -34,7 +35,7 @@ #define IOX_SEM_FAILED static_cast(nullptr) // win32 API page talks about maximum allowed value without defining it or how to obtain. // We use the IOX_SEM_VALUE_MAX from linux which is INT_MAX -#define IOX_SEM_VALUE_MAX INT_MAX +constexpr uint32_t IOX_SEM_VALUE_MAX = INT_MAX; struct iox_sem_t {