From 239da808599602fd3d286ea868a85d23f3479a5e Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Fri, 7 Jun 2024 15:48:49 +0200 Subject: [PATCH 01/10] iox-#2301 Remove flag to prevent 32 bit builds iox-#2301 Squash me --- doc/website/release-notes/iceoryx-unreleased.md | 3 +-- iceoryx_hoofs/BUILD.bazel | 1 - iceoryx_hoofs/cmake/IceoryxHoofsDeployment.cmake | 5 ----- iceoryx_hoofs/cmake/iceoryx_hoofs_deployment.hpp.in | 2 -- .../utility/include/iox/detail/system_configuration.hpp | 4 ---- iceoryx_meta/build_options.cmake | 2 -- iceoryx_posh/source/roudi/roudi.cpp | 2 +- iceoryx_posh/source/runtime/posh_runtime.cpp | 2 +- 8 files changed, 3 insertions(+), 18 deletions(-) diff --git a/doc/website/release-notes/iceoryx-unreleased.md b/doc/website/release-notes/iceoryx-unreleased.md index 4a1f6bf565..f0390bba62 100644 --- a/doc/website/release-notes/iceoryx-unreleased.md +++ b/doc/website/release-notes/iceoryx-unreleased.md @@ -8,6 +8,7 @@ - The minimal supported GCC compiler is now 8.3 - The required C++ standard is now C++17 +- Experimental 32-bit support for all platforms supporting 64-bit atomic operations **Features:** @@ -1467,5 +1468,3 @@ ``` 64. The non-functional `iox::popo::Node` was removed - -65. 32-bit support is disabled by default. For development purposes iceoryx can be build with the `-DIOX_IGNORE_32_BIT_CHECK=ON` diff --git a/iceoryx_hoofs/BUILD.bazel b/iceoryx_hoofs/BUILD.bazel index 0d5f4bc5fd..aaa397e4ff 100644 --- a/iceoryx_hoofs/BUILD.bazel +++ b/iceoryx_hoofs/BUILD.bazel @@ -22,7 +22,6 @@ configure_file( src = "cmake/iceoryx_hoofs_deployment.hpp.in", out = "generated/include/iox/iceoryx_hoofs_deployment.hpp", config = { - "IOX_IGNORE_32_BIT_CHECK_FLAG": "false", "IOX_MAX_NAMED_PIPE_MESSAGE_SIZE": "4096", "IOX_MAX_NAMED_PIPE_NUMBER_OF_MESSAGES": "10", # FIXME: for values see "iceoryx_hoofs/cmake/IceoryxHoofsDeployment.cmake" ... for now some nice defaults diff --git a/iceoryx_hoofs/cmake/IceoryxHoofsDeployment.cmake b/iceoryx_hoofs/cmake/IceoryxHoofsDeployment.cmake index 67bea9cfc8..a3404300e9 100644 --- a/iceoryx_hoofs/cmake/IceoryxHoofsDeployment.cmake +++ b/iceoryx_hoofs/cmake/IceoryxHoofsDeployment.cmake @@ -31,11 +31,6 @@ configure_option( DEFAULT_VALUE 10 ) -if(IOX_IGNORE_32_BIT_CHECK) - set(IOX_IGNORE_32_BIT_CHECK_FLAG true) -else() - set(IOX_IGNORE_32_BIT_CHECK_FLAG false) -endif() message(STATUS "[i] IOX_EXPERIMENTAL_POSH_FLAG: ${IOX_EXPERIMENTAL_POSH_FLAG}") message(STATUS "[i] <<<<<<<<<<<<<< End iceoryx_hoofs configuration: >>>>>>>>>>>>>>") diff --git a/iceoryx_hoofs/cmake/iceoryx_hoofs_deployment.hpp.in b/iceoryx_hoofs/cmake/iceoryx_hoofs_deployment.hpp.in index e9e2bf5fca..218db9b65a 100644 --- a/iceoryx_hoofs/cmake/iceoryx_hoofs_deployment.hpp.in +++ b/iceoryx_hoofs/cmake/iceoryx_hoofs_deployment.hpp.in @@ -35,8 +35,6 @@ constexpr iox::log::LogLevel IOX_MINIMAL_LOG_LEVEL = iox::log::LogLevel::@IOX_MI constexpr uint64_t IOX_MAX_NAMED_PIPE_MESSAGE_SIZE = static_cast(@IOX_MAX_NAMED_PIPE_MESSAGE_SIZE@); constexpr uint32_t IOX_MAX_NAMED_PIPE_NUMBER_OF_MESSAGES = static_cast(@IOX_MAX_NAMED_PIPE_NUMBER_OF_MESSAGES@); -constexpr bool IOX_IGNORE_32_BIT_CHECK_FLAG = @IOX_IGNORE_32_BIT_CHECK_FLAG@; - } // namespace build } // namespace iox diff --git a/iceoryx_hoofs/posix/utility/include/iox/detail/system_configuration.hpp b/iceoryx_hoofs/posix/utility/include/iox/detail/system_configuration.hpp index 8ff8c99a62..6ed96be76e 100644 --- a/iceoryx_hoofs/posix/utility/include/iox/detail/system_configuration.hpp +++ b/iceoryx_hoofs/posix/utility/include/iox/detail/system_configuration.hpp @@ -32,10 +32,6 @@ uint64_t pageSize() noexcept; /// @return True if called on 32-bit, false if not 32-bit system constexpr bool isCompiledOn32BitSystem() noexcept { - static_assert(build::IOX_IGNORE_32_BIT_CHECK_FLAG || INTPTR_MAX > INT32_MAX, - "iceoryx is only supported on 64-bit systems. Using it on 32-bit will result in race conditions in " - "the lock-free constructs!"); - return INTPTR_MAX == INT32_MAX; } } // namespace detail diff --git a/iceoryx_meta/build_options.cmake b/iceoryx_meta/build_options.cmake index 63953c85c2..8986a807b0 100644 --- a/iceoryx_meta/build_options.cmake +++ b/iceoryx_meta/build_options.cmake @@ -37,7 +37,6 @@ option(TEST_WITH_ADDITIONAL_USER "Build Test with additional user accounts for t option(TEST_WITH_HUGE_PAYLOAD "Build Tests which use payload bigger than 2GB" OFF) option(TOML_CONFIG "TOML support for RouDi with dynamic configuration" ON) option(IOX_EXPERIMENTAL_POSH "Export experimental posh features (no guarantees)" OFF) -option(IOX_IGNORE_32_BIT_CHECK "Ignores the check for 32 bit systems! It is not recommended to turn this on in production systems" OFF) option(IOX_REPRODUCIBLE_BUILD "Create reproducible builds by omit setting the build timestamp in the version header" ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # "Create compile_commands.json file" @@ -97,6 +96,5 @@ function(show_config_options) message(" TEST_WITH_HUGE_PAYLOAD ..............: " ${TEST_WITH_HUGE_PAYLOAD}) message(" TOML_CONFIG..........................: " ${TOML_CONFIG}) message(" IOX_EXPERIMENTAL_POSH................: " ${IOX_EXPERIMENTAL_POSH}) - message(" IOX_IGNORE_32_BIT_CHECK..............: " ${IOX_IGNORE_32_BIT_CHECK}) message(" IOX_REPRODUCIBLE_BUILD...............: " ${IOX_REPRODUCIBLE_BUILD}) endfunction() diff --git a/iceoryx_posh/source/roudi/roudi.cpp b/iceoryx_posh/source/roudi/roudi.cpp index 2289913c59..096ef0dc47 100644 --- a/iceoryx_posh/source/roudi/roudi.cpp +++ b/iceoryx_posh/source/roudi/roudi.cpp @@ -52,7 +52,7 @@ RouDi::RouDi(RouDiMemoryInterface& roudiMemoryInterface, { if (detail::isCompiledOn32BitSystem()) { - IOX_LOG(WARN, "Runnning RouDi on 32-bit architectures is not supported! Use at your own risk!"); + IOX_LOG(WARN, "Runnning RouDi on 32-bit architectures is experimental! Use at your own risk!"); } m_processIntrospection.registerPublisherPort( PublisherPortUserType(m_prcMgr->addIntrospectionPublisherPort(IntrospectionProcessService))); diff --git a/iceoryx_posh/source/runtime/posh_runtime.cpp b/iceoryx_posh/source/runtime/posh_runtime.cpp index bc84a50dfa..90970f7778 100644 --- a/iceoryx_posh/source/runtime/posh_runtime.cpp +++ b/iceoryx_posh/source/runtime/posh_runtime.cpp @@ -123,7 +123,7 @@ PoshRuntime::PoshRuntime(optional name) noexcept { if (detail::isCompiledOn32BitSystem()) { - IOX_LOG(WARN, "Running applications on 32-bit architectures is not supported! Use at your own risk!"); + IOX_LOG(WARN, "Running applications on 32-bit architectures is experimental! Use at your own risk!"); } } From 2c8dd369e62a71eb72b48d47338b7757fc2dceb2 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Fri, 7 Jun 2024 18:21:55 +0200 Subject: [PATCH 02/10] iox-#2301 Pass C and CXX flags to cpptoml build --- iceoryx_posh/cmake/cpptoml/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/iceoryx_posh/cmake/cpptoml/CMakeLists.txt b/iceoryx_posh/cmake/cpptoml/CMakeLists.txt index 42e79d98fb..e770e4fdba 100644 --- a/iceoryx_posh/cmake/cpptoml/CMakeLists.txt +++ b/iceoryx_posh/cmake/cpptoml/CMakeLists.txt @@ -59,7 +59,9 @@ file(MAKE_DIRECTORY ${BUILD_DIR}) set(CMAKE_ADDITIONAL_OPTIONS "-DCMAKE_C_FLAGS_INIT=${CMAKE_C_FLAGS_INIT}" + "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}" "-DCMAKE_CXX_FLAGS_INIT=${CMAKE_CXX_FLAGS_INIT}" + "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" "-DCMAKE_C_COMPILER_TARGET=${CMAKE_C_COMPILER_TARGET}" "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" From e4f362b0c970038010b73fc3895a581f615f5803 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Fri, 7 Jun 2024 19:13:02 +0200 Subject: [PATCH 03/10] iox-#2301 Print cmake provided C and C++ flags --- iceoryx_meta/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/iceoryx_meta/CMakeLists.txt b/iceoryx_meta/CMakeLists.txt index 1a9a536d06..68cd4181ba 100644 --- a/iceoryx_meta/CMakeLists.txt +++ b/iceoryx_meta/CMakeLists.txt @@ -90,9 +90,11 @@ message(" platform..................: " ${ICEORYX_PLATFORM_STRING}) message(" project name..............: " ${CMAKE_PROJECT_NAME}) message(" c compiler................: " ${CMAKE_C_COMPILER}) message(" c++ compiler..............: " ${CMAKE_CXX_COMPILER}) -message(" c++ standard..............: " ${ICEORYX_CXX_STANDARD}) +message(" c flags...................: " ${CMAKE_C_FLAGS}) +message(" c++ flags.................: " ${CMAKE_CXX_FLAGS}) message(" cmake.....................: " ${CMAKE_VERSION}) -message(" Flags from iceoryx platform") +message(" Additional flags from iceoryx platform") +message(" c++ standard..............: " ${ICEORYX_CXX_STANDARD}) message(" c flags...................: " ${ICEORYX_C_FLAGS}) message(" c warning flags...........: " ${ICEORYX_C_WARNINGS}) message(" c++ flags.................: " ${ICEORYX_CXX_FLAGS}) From 8d58ced39281b0ab276c837277a1663ba8a173f3 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Wed, 24 Jul 2024 18:27:30 +0200 Subject: [PATCH 04/10] iox-#2301 Use fixed width type for relative pointer offset --- iceoryx_hoofs/memory/include/iox/detail/relative_pointer.inl | 4 ++-- iceoryx_hoofs/memory/include/iox/relative_pointer.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/iceoryx_hoofs/memory/include/iox/detail/relative_pointer.inl b/iceoryx_hoofs/memory/include/iox/detail/relative_pointer.inl index c2f55c0e72..0724e9b6b8 100644 --- a/iceoryx_hoofs/memory/include/iox/detail/relative_pointer.inl +++ b/iceoryx_hoofs/memory/include/iox/detail/relative_pointer.inl @@ -189,7 +189,7 @@ inline typename RelativePointer::offset_t RelativePointer::getOffset(const const auto* const basePtr = getBasePtr(id); // AXIVION Next Construct AutosarC++19_03-A5.2.4, AutosarC++19_03-M5.2.9 : Cast needed for pointer arithmetic // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) - return reinterpret_cast(ptr) - reinterpret_cast(basePtr); + return reinterpret_cast(ptr) - reinterpret_cast(basePtr); } template @@ -206,7 +206,7 @@ inline T* RelativePointer::getPtr(const segment_id_t id, const offset_t offse // AXIVION DISABLE STYLE AutosarC++19_03-M5.2.8 : Cast needed for pointer arithmetic // AXIVION DISABLE STYLE AutosarC++19_03-M5.2.9 : Cast needed for pointer arithmetic // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast, performance-no-int-to-ptr) - return reinterpret_cast(offset + reinterpret_cast(basePtr)); + return reinterpret_cast(offset + reinterpret_cast(basePtr)); // AXIVION ENABLE STYLE AutosarC++19_03-M5.2.9 // AXIVION ENABLE STYLE AutosarC++19_03-M5.2.8 // AXIVION ENABLE STYLE AutosarC++19_03-A5.2.4 diff --git a/iceoryx_hoofs/memory/include/iox/relative_pointer.hpp b/iceoryx_hoofs/memory/include/iox/relative_pointer.hpp index 60ed5abb90..3551ee1fa0 100644 --- a/iceoryx_hoofs/memory/include/iox/relative_pointer.hpp +++ b/iceoryx_hoofs/memory/include/iox/relative_pointer.hpp @@ -67,7 +67,7 @@ class RelativePointer final { public: using ptr_t = T*; - using offset_t = std::uintptr_t; + using offset_t = std::uint64_t; /// @brief Default constructs a RelativePointer as a logical nullptr RelativePointer() noexcept = default; From 017b18a6939bb3a2eebb3fd4d22093427efcec8e Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Wed, 24 Jul 2024 18:46:10 +0200 Subject: [PATCH 05/10] iox-#2301 Use fixed width type for received data in runtime interface --- iceoryx_posh/source/runtime/ipc_runtime_interface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp b/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp index 27e69fe747..d7becf2673 100644 --- a/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp +++ b/iceoryx_posh/source/runtime/ipc_runtime_interface.cpp @@ -261,13 +261,13 @@ IpcRuntimeInterface::waitForRegAck(int64_t transmissionTimestamp, auto topic_size_result = iox::convert::from_string(receiveBuffer.getElementAtIndex(1U).c_str()); auto segment_manager_offset_result = - iox::convert::from_string(receiveBuffer.getElementAtIndex(2U).c_str()); + iox::convert::from_string(receiveBuffer.getElementAtIndex(2U).c_str()); auto recv_timestamp_result = iox::convert::from_string(receiveBuffer.getElementAtIndex(3U).c_str()); auto segment_id_result = iox::convert::from_string(receiveBuffer.getElementAtIndex(4U).c_str()); auto heartbeat_offset_result = - iox::convert::from_string(receiveBuffer.getElementAtIndex(5U).c_str()); + iox::convert::from_string(receiveBuffer.getElementAtIndex(5U).c_str()); // validate conversion results if (!topic_size_result.has_value() || !segment_manager_offset_result.has_value() From cc58b72dcd79f60dbbdf87436ffc78ac8a2f8e95 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Wed, 21 Aug 2024 15:55:35 +0200 Subject: [PATCH 06/10] iox-#2301 Add option to build script to build iceoryx as 32 bit library --- tools/iceoryx_build_test.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/iceoryx_build_test.sh b/tools/iceoryx_build_test.sh index 6ca6f8e260..1a891a1f3b 100755 --- a/tools/iceoryx_build_test.sh +++ b/tools/iceoryx_build_test.sh @@ -56,6 +56,7 @@ BUILD_SHARED="OFF" TOML_FLAG="ON" COMPONENTS="iceoryx_platform iceoryx_hoofs iceoryx_posh iceoryx_introspection iceoryx_binding_c iceoryx_component" TOOLCHAIN_FILE="" +CMAKE_C_FLAGS="" CMAKE_CXX_FLAGS="" while (( "$#" )); do @@ -206,7 +207,7 @@ while (( "$#" )); do ;; "libcxx") echo " [i] Build with libc++ library" - CMAKE_CXX_FLAGS="-stdlib=libc++" + CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -stdlib=libc++" shift 1 ;; "doc") @@ -214,6 +215,19 @@ while (( "$#" )); do BUILD_DOC="ON" shift 1 ;; + "32-bit-x86") + echo " [i] Build as 32 bit x86 library" + CMAKE_C_FLAGS="${CMAKE_C_FLAGS} -m32 -malign-double" + CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -m32 -malign-double" + shift 1 + ;; + "32-bit-arm") + echo " [i] Build as 32 bit ARM library" + # NOTE: there is no '-m32' flag on ARM; the architecture is selected via the externally defined toolchain + CMAKE_C_FLAGS="${CMAKE_C_FLAGS} -malign-double" + CMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -malign-double" + shift 1 + ;; "help") echo "Build script for iceoryx." echo "By default, iceoryx with C-Binding and TOML-config is built." @@ -250,6 +264,8 @@ while (( "$#" )); do echo " test-add-user Create additional useraccounts in system for testing access control (default off)" echo " toml-config-off Build without TOML File support" echo " roudi-env Build the roudi environment" + echo " 32-bit-x86 Build as 32 bit library for x64" + echo " 32-bit-arm Build as 32 bit library for arm" echo "" echo "e.g. iceoryx_build_test.sh -b ./build-scripted clean test" echo "for gcov report: iceoryx_build_test.sh clean -c unit" @@ -324,7 +340,8 @@ if [ "$NO_BUILD" == false ]; then -DTHREAD_SANITIZER=$THREAD_SANITIZER_FLAG \ -DTEST_WITH_ADDITIONAL_USER=$TEST_ADD_USER $TOOLCHAIN_FILE \ -DTEST_WITH_HUGE_PAYLOAD=$TEST_HUGE_PAYLOAD \ - -DCMAKE_CXX_FLAGS=$CMAKE_CXX_FLAGS \ + -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" \ + -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \ "$WORKSPACE"/iceoryx_meta cmake --build . --target install -- -j$NUM_JOBS From da969e24b141ffadb24bb153710cf7eadcc82adc Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 22 Aug 2024 18:41:56 +0200 Subject: [PATCH 07/10] iox-#2301 Fix warnings for 32 bit build --- iceoryx_binding_c/source/c_runtime.cpp | 2 +- .../cli/source/command_line_parser.cpp | 2 +- .../container/include/iox/detail/vector.inl | 8 ++--- .../include/iox/detail/static_storage.inl | 2 +- iceoryx_hoofs/memory/include/iox/memory.hpp | 2 +- iceoryx_hoofs/memory/source/memory.cpp | 6 ++-- .../posix/filesystem/source/file.cpp | 8 +++-- .../ipc/include/iox/detail/message_queue.inl | 25 ++++++++------ .../include/iox/detail/unix_domain_socket.inl | 4 +-- .../posix/ipc/include/iox/named_pipe.hpp | 2 +- .../posix/ipc/source/posix_memory_map.cpp | 5 +-- .../posix/ipc/source/posix_shared_memory.cpp | 2 +- .../ipc/source/posix_shared_memory_object.cpp | 2 +- .../posix/ipc/source/unix_domain_socket.cpp | 3 +- .../test_cli_command_line_common.hpp | 4 +-- ...est_container_fixed_position_container.cpp | 4 +-- .../moduletests/test_container_vector.cpp | 8 ++--- .../test_posix_ipc_unix_domain_sockets.cpp | 3 +- .../test_utility_std_string_support.cpp | 2 +- .../test_vocabulary_semantic_string.cpp | 2 +- ...y_string_concatenate_append_and_insert.cpp | 8 ++--- ...test_vocabulary_string_ctor_and_assign.cpp | 4 +-- .../test_mpmc_lockfree_queue_stresstest.cpp | 34 +++++++++---------- ...c_resizeable_lockfree_queue_stresstest.cpp | 32 ++++++++--------- .../include/iox/detail/serialization.inl | 4 +-- .../include/iox/detail/std_string_support.inl | 2 +- .../vocabulary/include/iox/detail/string.inl | 34 ++++++++++--------- .../linux/cmake/IceoryxPlatformSettings.cmake | 3 -- .../qnx/cmake/IceoryxPlatformSettings.cmake | 2 +- iceoryx_posh/experimental/source/node.cpp | 3 +- .../introspection/mempool_introspection.inl | 2 +- .../roudi/memory/default_roudi_memory.cpp | 19 +++++------ .../test/integrationtests/test_posh_mepoo.cpp | 2 +- .../test/mocks/roudi_memory_provider_mock.hpp | 2 +- .../moduletests/test_mepoo_chunk_header.cpp | 2 +- .../moduletests/test_mepoo_chunk_settings.cpp | 4 +-- .../test_popo_chunk_distributor.cpp | 2 +- .../test/moduletests/test_popo_listener.cpp | 10 +++--- .../iceoryx_posh/testing/mocks/chunk_mock.hpp | 5 +-- .../source/introspection_app.cpp | 34 ++++++++++++++----- 40 files changed, 165 insertions(+), 139 deletions(-) diff --git a/iceoryx_binding_c/source/c_runtime.cpp b/iceoryx_binding_c/source/c_runtime.cpp index e343156f4b..a532046d00 100644 --- a/iceoryx_binding_c/source/c_runtime.cpp +++ b/iceoryx_binding_c/source/c_runtime.cpp @@ -42,7 +42,7 @@ uint64_t iox_runtime_get_instance_name(char* const name, const uint64_t nameLeng } auto instanceName = PoshRuntime::getInstance().getInstanceName(); - std::strncpy(name, instanceName.c_str(), nameLength); + std::strncpy(name, instanceName.c_str(), static_cast(nameLength)); name[nameLength - 1U] = '\0'; // strncpy doesn't add a null-termination if destination is smaller than source return instanceName.size(); diff --git a/iceoryx_hoofs/cli/source/command_line_parser.cpp b/iceoryx_hoofs/cli/source/command_line_parser.cpp index 5d2b83beb9..278f18fe4a 100644 --- a/iceoryx_hoofs/cli/source/command_line_parser.cpp +++ b/iceoryx_hoofs/cli/source/command_line_parser.cpp @@ -106,7 +106,7 @@ bool CommandLineParser::doesNotExceedLongOptionDash(const char* option) const no bool CommandLineParser::doesFitIntoString(const char* value, const uint64_t maxLength) noexcept { - return (strnlen(value, maxLength + 1) <= maxLength); + return (strnlen(value, static_cast(maxLength) + 1) <= maxLength); } bool CommandLineParser::doesOptionNameFitIntoString(const char* option) const noexcept diff --git a/iceoryx_hoofs/container/include/iox/detail/vector.inl b/iceoryx_hoofs/container/include/iox/detail/vector.inl index ae822c2787..6c20aaff20 100644 --- a/iceoryx_hoofs/container/include/iox/detail/vector.inl +++ b/iceoryx_hoofs/container/include/iox/detail/vector.inl @@ -90,7 +90,7 @@ inline vector& vector::operator=(const vector& rhs) no if constexpr (std::is_trivially_copyable::value) { - std::memcpy(data(), rhs.data(), rhsSize * sizeof(T)); + std::memcpy(data(), rhs.data(), static_cast(rhsSize) * sizeof(T)); i = rhsSize; } else @@ -129,7 +129,7 @@ inline vector& vector::operator=(vector&& rhs) noexcep if constexpr (std::is_trivially_copyable::value) { - std::memcpy(data(), rhs.data(), rhsSize * sizeof(T)); + std::memcpy(data(), rhs.data(), static_cast(rhsSize) * sizeof(T)); i = rhsSize; } else @@ -220,7 +220,7 @@ inline bool vector::emplace(const uint64_t position, Targs&&... arg if constexpr (std::is_trivial::value) { resize(size() + 1U); - const uint64_t dataLen{sizeBeforeEmplace - position}; + const size_t dataLen{static_cast(sizeBeforeEmplace) - static_cast(position)}; std::memmove(data() + position + 1U, data() + position, dataLen * sizeof(T)); at_unchecked(position) = T{std::forward(args)...}; } @@ -414,7 +414,7 @@ inline bool vector::erase(iterator position) noexcept at_unchecked(n).~T(); } uint64_t dataLen{size() - n - 1U}; - std::memmove(data() + n, data() + n + 1U, dataLen * sizeof(T)); + std::memmove(data() + n, data() + n + 1U, static_cast(dataLen) * sizeof(T)); } else { diff --git a/iceoryx_hoofs/memory/include/iox/detail/static_storage.inl b/iceoryx_hoofs/memory/include/iox/detail/static_storage.inl index d1b2693d04..2fadf98eea 100644 --- a/iceoryx_hoofs/memory/include/iox/detail/static_storage.inl +++ b/iceoryx_hoofs/memory/include/iox/detail/static_storage.inl @@ -67,7 +67,7 @@ constexpr void* static_storage::allocate(const uint64_t align, size_t space{Capacity}; m_ptr = m_bytes; - if (std::align(align, size, m_ptr, space) != nullptr) + if (std::align(static_cast(align), static_cast(size), m_ptr, space) != nullptr) { // fits, ptr was potentially modified to reflect alignment return m_ptr; diff --git a/iceoryx_hoofs/memory/include/iox/memory.hpp b/iceoryx_hoofs/memory/include/iox/memory.hpp index 6e4638b5ab..5fa2cae9bf 100644 --- a/iceoryx_hoofs/memory/include/iox/memory.hpp +++ b/iceoryx_hoofs/memory/include/iox/memory.hpp @@ -37,7 +37,7 @@ T align(const T value, const T alignment) noexcept /// @param[in] alignment, alignment of the memory /// @param[in] size, memory size /// @return void pointer to the aligned memory -void* alignedAlloc(const uint64_t alignment, const uint64_t size) noexcept; +void* alignedAlloc(const size_t alignment, const size_t size) noexcept; /// @brief frees aligned memory allocated with alignedAlloc /// @param[in] memory, pointer to the aligned memory diff --git a/iceoryx_hoofs/memory/source/memory.cpp b/iceoryx_hoofs/memory/source/memory.cpp index 5d602d87a0..403c255690 100644 --- a/iceoryx_hoofs/memory/source/memory.cpp +++ b/iceoryx_hoofs/memory/source/memory.cpp @@ -21,18 +21,18 @@ namespace iox { -void* alignedAlloc(const uint64_t alignment, const uint64_t size) noexcept +void* alignedAlloc(const size_t alignment, const size_t size) noexcept { // -1 == since the max alignment addition is alignment - 1 otherwise the // memory is already aligned and we have to do nothing // low-level memory management, no other approach then to use malloc to acquire heap memory // NOLINTNEXTLINE(cppcoreguidelines-owning-memory,cppcoreguidelines-pro-type-reinterpret-cast,hicpp-no-malloc,cppcoreguidelines-no-malloc) - auto memory = reinterpret_cast(std::malloc(size + alignment + sizeof(void*) - 1)); + auto memory = reinterpret_cast(std::malloc(size + alignment + sizeof(void*) - 1)); if (memory == 0) { return nullptr; } - uint64_t alignedMemory = align(memory + sizeof(void*), alignment); + size_t alignedMemory = align(memory + sizeof(void*), alignment); assert(alignedMemory >= memory + 1); // low-level memory management, we have to store the actual start of the memory a position before the // returned aligned address to be able to release the actual memory address again with free when we diff --git a/iceoryx_hoofs/posix/filesystem/source/file.cpp b/iceoryx_hoofs/posix/filesystem/source/file.cpp index 2219e2da70..7d5821c60e 100644 --- a/iceoryx_hoofs/posix/filesystem/source/file.cpp +++ b/iceoryx_hoofs/posix/filesystem/source/file.cpp @@ -340,7 +340,9 @@ File::read_at(const uint64_t offset, uint8_t* const buffer, const uint64_t buffe return err(FileReadError::OffsetFailure); } - auto result = IOX_POSIX_CALL(iox_read)(m_file_descriptor, buffer, buffer_len).failureReturnValue(-1).evaluate(); + auto result = IOX_POSIX_CALL(iox_read)(m_file_descriptor, buffer, static_cast(buffer_len)) + .failureReturnValue(-1) + .evaluate(); if (!result.has_error()) { @@ -394,7 +396,9 @@ File::write_at(const uint64_t offset, const uint8_t* const buffer, const uint64_ return err(FileWriteError::OffsetFailure); } - auto result = IOX_POSIX_CALL(iox_write)(m_file_descriptor, buffer, buffer_len).failureReturnValue(-1).evaluate(); + auto result = IOX_POSIX_CALL(iox_write)(m_file_descriptor, buffer, static_cast(buffer_len)) + .failureReturnValue(-1) + .evaluate(); if (!result.has_error()) { diff --git a/iceoryx_hoofs/posix/ipc/include/iox/detail/message_queue.inl b/iceoryx_hoofs/posix/ipc/include/iox/detail/message_queue.inl index d626049228..2a7818452c 100644 --- a/iceoryx_hoofs/posix/ipc/include/iox/detail/message_queue.inl +++ b/iceoryx_hoofs/posix/ipc/include/iox/detail/message_queue.inl @@ -40,7 +40,7 @@ MessageQueue::timedSendImpl(not_null msg, uint64_t msgSize, const u } timespec timeOut = timeout.timespec(units::TimeSpecReference::Epoch); - auto mqCall = IOX_POSIX_CALL(mq_timedsend)(m_mqDescriptor, msg, msgSizeToSend, 1U, &timeOut) + auto mqCall = IOX_POSIX_CALL(mq_timedsend)(m_mqDescriptor, msg, static_cast(msgSizeToSend), 1U, &timeOut) .failureReturnValue(ERROR_CODE) // don't use the suppressErrorMessagesForErrnos method since QNX used EINTR instead of ETIMEDOUT .ignoreErrnos(TIMEOUT_ERRNO) @@ -74,8 +74,9 @@ expected MessageQueue::sendImpl(not_null(msgSizeToSend), 1U) + .failureReturnValue(ERROR_CODE) + .evaluate(); if (mqCall.has_error()) { @@ -95,11 +96,12 @@ expected MessageQueue::timedReceiveImpl(not_null msg, uint64_t maxMsgSize, const units::Duration& timeout) const noexcept { timespec timeOut = timeout.timespec(units::TimeSpecReference::Epoch); - auto mqCall = IOX_POSIX_CALL(mq_timedreceive)(m_mqDescriptor, msg, maxMsgSize, nullptr, &timeOut) - .failureReturnValue(ERROR_CODE) - // don't use the suppressErrorMessagesForErrnos method since QNX used EINTR instead of ETIMEDOUT - .ignoreErrnos(TIMEOUT_ERRNO) - .evaluate(); + auto mqCall = + IOX_POSIX_CALL(mq_timedreceive)(m_mqDescriptor, msg, static_cast(maxMsgSize), nullptr, &timeOut) + .failureReturnValue(ERROR_CODE) + // don't use the suppressErrorMessagesForErrnos method since QNX used EINTR instead of ETIMEDOUT + .ignoreErrnos(TIMEOUT_ERRNO) + .evaluate(); if (mqCall.has_error()) { @@ -118,8 +120,9 @@ template expected MessageQueue::receiveImpl(not_null msg, uint64_t maxMsgSize) const noexcept { - auto mqCall = - IOX_POSIX_CALL(mq_receive)(m_mqDescriptor, msg, maxMsgSize, nullptr).failureReturnValue(ERROR_CODE).evaluate(); + auto mqCall = IOX_POSIX_CALL(mq_receive)(m_mqDescriptor, msg, static_cast(maxMsgSize), nullptr) + .failureReturnValue(ERROR_CODE) + .evaluate(); if (mqCall.has_error()) { @@ -210,4 +213,4 @@ expected MessageQueue::receiveVerification(not_n } } // namespace iox -#endif \ No newline at end of file +#endif diff --git a/iceoryx_hoofs/posix/ipc/include/iox/detail/unix_domain_socket.inl b/iceoryx_hoofs/posix/ipc/include/iox/detail/unix_domain_socket.inl index 21dc4636b7..eed222f3d9 100644 --- a/iceoryx_hoofs/posix/ipc/include/iox/detail/unix_domain_socket.inl +++ b/iceoryx_hoofs/posix/ipc/include/iox/detail/unix_domain_socket.inl @@ -53,7 +53,7 @@ expected UnixDomainSocket::timedSendImpl(not_null(msgSizeToSend), 0, nullptr, 0) .failureReturnValue(ERROR_CODE) .evaluate(); @@ -85,7 +85,7 @@ expected UnixDomainSocket::timedReceiveImpl( return err(errnoToEnum(setsockoptCall.error().errnum)); } - auto recvCall = IOX_POSIX_CALL(iox_recvfrom)(m_sockfd, msg, maxMsgSize, 0, nullptr, nullptr) + auto recvCall = IOX_POSIX_CALL(iox_recvfrom)(m_sockfd, msg, static_cast(maxMsgSize), 0, nullptr, nullptr) .failureReturnValue(ERROR_CODE) .suppressErrorMessagesForErrnos(EAGAIN, EWOULDBLOCK) .evaluate(); diff --git a/iceoryx_hoofs/posix/ipc/include/iox/named_pipe.hpp b/iceoryx_hoofs/posix/ipc/include/iox/named_pipe.hpp index 6517654751..123b35e799 100644 --- a/iceoryx_hoofs/posix/ipc/include/iox/named_pipe.hpp +++ b/iceoryx_hoofs/posix/ipc/include/iox/named_pipe.hpp @@ -213,7 +213,7 @@ class NamedPipeBuilder IOX_BUILDER_PARAMETER(PosixIpcChannelSide, channelSide, PosixIpcChannelSide::CLIENT) /// @brief Defines the max message size of the named pipe - IOX_BUILDER_PARAMETER(size_t, maxMsgSize, NamedPipe::MAX_MESSAGE_SIZE) + IOX_BUILDER_PARAMETER(uint64_t, maxMsgSize, NamedPipe::MAX_MESSAGE_SIZE) /// @brief Defines the max number of messages for the named pipe. IOX_BUILDER_PARAMETER(uint64_t, maxMsgNumber, NamedPipe::MAX_NUMBER_OF_MESSAGES) diff --git a/iceoryx_hoofs/posix/ipc/source/posix_memory_map.cpp b/iceoryx_hoofs/posix/ipc/source/posix_memory_map.cpp index c1e05e23dd..27c6500848 100644 --- a/iceoryx_hoofs/posix/ipc/source/posix_memory_map.cpp +++ b/iceoryx_hoofs/posix/ipc/source/posix_memory_map.cpp @@ -31,7 +31,7 @@ expected PosixMemoryMapBuilder::create() no // AXIVION Next Construct AutosarC++19_03-A5.2.3, CertC++-EXP55 : Incompatibility with POSIX definition of mmap // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) low-level memory management auto result = IOX_POSIX_CALL(mmap)(const_cast(m_baseAddressHint), - m_length, + static_cast(m_length), convertToProtFlags(m_accessMode), static_cast(m_flags), m_fileDescriptor, @@ -176,7 +176,8 @@ bool PosixMemoryMap::destroy() noexcept { if (m_baseAddress != nullptr) { - auto unmapResult = IOX_POSIX_CALL(munmap)(m_baseAddress, m_length).failureReturnValue(-1).evaluate(); + auto unmapResult = + IOX_POSIX_CALL(munmap)(m_baseAddress, static_cast(m_length)).failureReturnValue(-1).evaluate(); m_baseAddress = nullptr; m_length = 0U; diff --git a/iceoryx_hoofs/posix/ipc/source/posix_shared_memory.cpp b/iceoryx_hoofs/posix/ipc/source/posix_shared_memory.cpp index 0d4c0022b6..84a25e3c6d 100644 --- a/iceoryx_hoofs/posix/ipc/source/posix_shared_memory.cpp +++ b/iceoryx_hoofs/posix/ipc/source/posix_shared_memory.cpp @@ -129,7 +129,7 @@ expected PosixSharedMemoryBuilder::cr if (hasOwnership) { - auto result = IOX_POSIX_CALL(iox_ftruncate)(sharedMemoryFileHandle, static_cast(m_size)) + auto result = IOX_POSIX_CALL(iox_ftruncate)(sharedMemoryFileHandle, static_cast(m_size)) .failureReturnValue(PosixSharedMemory::INVALID_HANDLE) .evaluate(); if (result.has_error()) diff --git a/iceoryx_hoofs/posix/ipc/source/posix_shared_memory_object.cpp b/iceoryx_hoofs/posix/ipc/source/posix_shared_memory_object.cpp index 836c33a036..1cf72e2c60 100644 --- a/iceoryx_hoofs/posix/ipc/source/posix_shared_memory_object.cpp +++ b/iceoryx_hoofs/posix/ipc/source/posix_shared_memory_object.cpp @@ -163,7 +163,7 @@ expected PosixSharedMemor (m_baseAddressHint) ? *m_baseAddressHint : nullptr, m_permissions.value())); - memset(memoryMap->getBaseAddress(), 0, m_memorySizeInBytes); + memset(memoryMap->getBaseAddress(), 0, static_cast(m_memorySizeInBytes)); } IOX_LOG(DEBUG, "Acquired " << m_memorySizeInBytes << " bytes successfully in the shared memory [" << m_name << "]"); diff --git a/iceoryx_hoofs/posix/ipc/source/unix_domain_socket.cpp b/iceoryx_hoofs/posix/ipc/source/unix_domain_socket.cpp index 3090a3b5d0..74320da023 100644 --- a/iceoryx_hoofs/posix/ipc/source/unix_domain_socket.cpp +++ b/iceoryx_hoofs/posix/ipc/source/unix_domain_socket.cpp @@ -75,7 +75,8 @@ expected UnixDomainSocketBuilderNoPathPr { return err(PosixIpcChannelError::INVALID_CHANNEL_NAME); } - strncpy(&(sockAddr.sun_path[0]), m_name.c_str(), m_name.size()); + auto nameSize = m_name.size(); + strncpy(&(sockAddr.sun_path[0]), m_name.c_str(), static_cast(nameSize)); // the mask will be applied to the permissions, we only allow users and group members to have read and write access // the system call always succeeds, no need to check for errors diff --git a/iceoryx_hoofs/test/moduletests/test_cli_command_line_common.hpp b/iceoryx_hoofs/test/moduletests/test_cli_command_line_common.hpp index 9c78b4512a..2262de0611 100644 --- a/iceoryx_hoofs/test/moduletests/test_cli_command_line_common.hpp +++ b/iceoryx_hoofs/test/moduletests/test_cli_command_line_common.hpp @@ -30,10 +30,10 @@ struct CmdArgs explicit CmdArgs(const std::vector& arguments) : argc{static_cast(arguments.size())} - , argv{new char*[static_cast(argc)]} + , argv{new char*[static_cast(argc)]} { contents = std::make_unique>(arguments); - for (uint64_t i = 0; i < static_cast(argc); ++i) + for (size_t i = 0; i < static_cast(argc); ++i) { // NOLINTJUSTIFICATION required for test // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) diff --git a/iceoryx_hoofs/test/moduletests/test_container_fixed_position_container.cpp b/iceoryx_hoofs/test/moduletests/test_container_fixed_position_container.cpp index bba82bb50d..9de51449ee 100644 --- a/iceoryx_hoofs/test/moduletests/test_container_fixed_position_container.cpp +++ b/iceoryx_hoofs/test/moduletests/test_container_fixed_position_container.cpp @@ -2455,7 +2455,7 @@ TEST_F(FixedPositionContainer_test, PartiallyFilledUpContainerCallsDestructorOnE } } - uint64_t i = 0; + size_t i = 0; for (const auto value : stats.dTorOrder) { EXPECT_THAT(value, Eq(expected_values[i])); @@ -2586,7 +2586,7 @@ TEST_F(FixedPositionContainer_test, ClearAfterPartiallyFillingContainerUpCallsDe } } - uint64_t i = 0; + size_t i = 0; for (const auto value : stats.dTorOrder) { EXPECT_THAT(value, Eq(expected_values[i])); diff --git a/iceoryx_hoofs/test/moduletests/test_container_vector.cpp b/iceoryx_hoofs/test/moduletests/test_container_vector.cpp index ab4a6c342c..d694e1cc41 100644 --- a/iceoryx_hoofs/test/moduletests/test_container_vector.cpp +++ b/iceoryx_hoofs/test/moduletests/test_container_vector.cpp @@ -498,7 +498,7 @@ TEST_F(vector_test, ReverseDestructionOrderInCopyAssignment) EXPECT_THAT(stats.dTor, Eq(VECTOR_CAPACITY)); ASSERT_THAT(stats.dTorOrder.size(), Eq(VECTOR_CAPACITY)); - for (uint64_t i{0}; i < VECTOR_CAPACITY; ++i) + for (size_t i{0}; i < VECTOR_CAPACITY; ++i) { EXPECT_THAT(stats.dTorOrder[i], Eq(VECTOR_CAPACITY - 1 - i)); } @@ -518,7 +518,7 @@ TEST_F(vector_test, ReverseDestructionOrderInMoveAssignment) EXPECT_THAT(stats.dTor, Eq(VECTOR_CAPACITY)); ASSERT_THAT(stats.dTorOrder.size(), Eq(VECTOR_CAPACITY)); - for (uint64_t i{0}; i < VECTOR_CAPACITY; ++i) + for (size_t i{0}; i < VECTOR_CAPACITY; ++i) { EXPECT_THAT(stats.dTorOrder[i], Eq(VECTOR_CAPACITY - i)); } @@ -1262,7 +1262,7 @@ TEST_F(vector_test, FullVectorDestroysElementsInReverseOrder) } ASSERT_THAT(stats.dTorOrder.size(), Eq(VECTOR_CAPACITY)); - for (uint64_t i = 0U; i < VECTOR_CAPACITY; ++i) + for (size_t i = 0U; i < VECTOR_CAPACITY; ++i) { EXPECT_THAT(stats.dTorOrder[i], Eq(INDEX_END - i + SOME_OFFSET)); } @@ -1286,7 +1286,7 @@ TEST_F(vector_test, PartiallyFullVectorDestroysElementsInReverseOrder) } ASSERT_THAT(stats.dTorOrder.size(), Eq(VECTOR_SIZE)); - for (uint64_t i = 0U; i < VECTOR_SIZE; ++i) + for (size_t i = 0U; i < VECTOR_SIZE; ++i) { EXPECT_THAT(stats.dTorOrder[i], Eq(INDEX_END - i + SOME_OFFSET)); } diff --git a/iceoryx_hoofs/test/moduletests/test_posix_ipc_unix_domain_sockets.cpp b/iceoryx_hoofs/test/moduletests/test_posix_ipc_unix_domain_sockets.cpp index 466ae2bfab..45d661362f 100644 --- a/iceoryx_hoofs/test/moduletests/test_posix_ipc_unix_domain_sockets.cpp +++ b/iceoryx_hoofs/test/moduletests/test_posix_ipc_unix_domain_sockets.cpp @@ -87,7 +87,8 @@ class UnixDomainSocket_test : public Test memset(&sockAddr, 0, sizeof(sockAddr)); sockAddr.sun_family = AF_LOCAL; - strncpy(&(sockAddr.sun_path[0]), name.c_str(), name.size()); + auto nameSize = name.size(); + strncpy(&(sockAddr.sun_path[0]), name.c_str(), static_cast(nameSize)); IOX_POSIX_CALL(iox_socket) (AF_LOCAL, SOCK_DGRAM, 0) diff --git a/iceoryx_hoofs/test/moduletests/test_utility_std_string_support.cpp b/iceoryx_hoofs/test/moduletests/test_utility_std_string_support.cpp index ae111a541b..e88ee2ba35 100644 --- a/iceoryx_hoofs/test/moduletests/test_utility_std_string_support.cpp +++ b/iceoryx_hoofs/test/moduletests/test_utility_std_string_support.cpp @@ -543,7 +543,7 @@ TYPED_TEST(StdString_test, AppendStdStringContainingNullWorks) sut.append(TruncateToCapacity, testStdString); EXPECT_THAT(sut.capacity(), Eq(RESULT_CAPACITY)); EXPECT_THAT(sut.size(), Eq(7U)); - EXPECT_THAT(std::memcmp(sut.c_str(), expectedString.c_str(), sut.size()), Eq(0)); + EXPECT_THAT(std::memcmp(sut.c_str(), expectedString.c_str(), static_cast(sut.size())), Eq(0)); } TYPED_TEST(StdString_test, FindStdStringInEmptyStringFails) diff --git a/iceoryx_hoofs/test/moduletests/test_vocabulary_semantic_string.cpp b/iceoryx_hoofs/test/moduletests/test_vocabulary_semantic_string.cpp index 4309422fed..76e4e0bad0 100644 --- a/iceoryx_hoofs/test/moduletests/test_vocabulary_semantic_string.cpp +++ b/iceoryx_hoofs/test/moduletests/test_vocabulary_semantic_string.cpp @@ -500,7 +500,7 @@ TYPED_TEST(SemanticString_test, InsertValidContentToValidStringWorks) { for (auto& add_value : TestValues::VALID_VALUES) { - for (uint64_t insert_position = 0; insert_position < value.size(); ++insert_position) + for (size_t insert_position = 0; insert_position < value.size(); ++insert_position) { auto sut = SutType::create(string(TruncateToCapacity, value.c_str())); ASSERT_THAT(sut.has_error(), Eq(false)); diff --git a/iceoryx_hoofs/test/moduletests/test_vocabulary_string_concatenate_append_and_insert.cpp b/iceoryx_hoofs/test/moduletests/test_vocabulary_string_concatenate_append_and_insert.cpp index 26e78672ed..43ad950a6b 100644 --- a/iceoryx_hoofs/test/moduletests/test_vocabulary_string_concatenate_append_and_insert.cpp +++ b/iceoryx_hoofs/test/moduletests/test_vocabulary_string_concatenate_append_and_insert.cpp @@ -95,9 +95,9 @@ TYPED_TEST(stringTyped_test, ConcatenateThreeStringsWorks) string testString2("YOD"); auto testString3 = concatenate(testString2, this->testSubject, testString1); - std::string cmpString = std::string(testString2.c_str(), testString2.size()) - + std::string(this->testSubject.c_str(), this->testSubject.size()) - + std::string(testString1.c_str(), testString1.size()); + std::string cmpString = std::string(testString2.c_str(), static_cast(testString2.size())) + + std::string(this->testSubject.c_str(), static_cast(this->testSubject.size())) + + std::string(testString1.c_str(), static_cast(testString1.size())); EXPECT_THAT(testString3.capacity(), Eq(3U * STRINGCAP + 2U)); EXPECT_THAT(testString3.size(), Eq(cmpString.size())); EXPECT_THAT(testString3.c_str(), StrEq(cmpString)); @@ -566,7 +566,7 @@ TYPED_TEST(stringTyped_test, AppendStringContainingNullWorks) sut.append(TruncateToCapacity, testCxxString); EXPECT_THAT(sut.capacity(), Eq(RESULT_CAPACITY)); EXPECT_THAT(sut.size(), Eq(7U)); - EXPECT_THAT(std::memcmp(sut.c_str(), expectedString.c_str(), sut.size()), Eq(0)); + EXPECT_THAT(std::memcmp(sut.c_str(), expectedString.c_str(), static_cast(sut.size())), Eq(0)); } /// @note string& append(TruncateToCapacity_t, char c) noexcept diff --git a/iceoryx_hoofs/test/moduletests/test_vocabulary_string_ctor_and_assign.cpp b/iceoryx_hoofs/test/moduletests/test_vocabulary_string_ctor_and_assign.cpp index 4ce0d48f64..e5bd6dc8d2 100644 --- a/iceoryx_hoofs/test/moduletests/test_vocabulary_string_ctor_and_assign.cpp +++ b/iceoryx_hoofs/test/moduletests/test_vocabulary_string_ctor_and_assign.cpp @@ -171,12 +171,12 @@ TYPED_TEST(stringTyped_test, SelfMoveAssignmentExcluded) { ::testing::Test::RecordProperty("TEST_ID", "0ad45975-b68b-465a-b8c5-83dd8d8290d5"); this->testSubject = "M"; -#if (defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)) +#if (defined(__GNUC__) && (__GNUC__ >= 13 && __GNUC__ <= 14) && !defined(__clang__)) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wself-move" #endif this->testSubject = std::move(this->testSubject); -#if (defined(__GNUC__) && __GNUC__ == 13 && !defined(__clang__)) +#if (defined(__GNUC__) && (__GNUC__ >= 13 && __GNUC__ <= 14) == 13 && !defined(__clang__)) #pragma GCC diagnostic pop #endif EXPECT_THAT(this->testSubject.size(), Eq(1U)); diff --git a/iceoryx_hoofs/test/stresstests/test_mpmc_lockfree_queue_stresstest.cpp b/iceoryx_hoofs/test/stresstests/test_mpmc_lockfree_queue_stresstest.cpp index fb70d307c3..d21f6f1c26 100644 --- a/iceoryx_hoofs/test/stresstests/test_mpmc_lockfree_queue_stresstest.cpp +++ b/iceoryx_hoofs/test/stresstests/test_mpmc_lockfree_queue_stresstest.cpp @@ -80,7 +80,7 @@ void consume( bool error = false; - std::vector lastCount(maxId + 1, 0); + std::vector lastCount(static_cast(maxId) + 1U, 0); while (run || !queue.empty()) { @@ -88,16 +88,16 @@ void consume( if (popped.has_value()) { auto& value = popped.value(); - if (lastCount[value.id] + 1 != value.count) + if (lastCount[static_cast(value.id)] + 1 != value.count) { error = true; } - lastCount[value.id] = value.count; + lastCount[static_cast(value.id)] = value.count; } } - for (uint64_t i = 1; i <= maxId; ++i) + for (size_t i = 1; i <= maxId; ++i) { if (lastCount[i] != expectedFinalCount) { @@ -150,7 +150,7 @@ bool isStrictlyMonotonic(std::list& list) return true; } - size_t prev = iter->count; + auto prev = iter->count; iter++; while (iter != list.end()) @@ -171,12 +171,12 @@ bool isComplete(std::list& list1, std::list& list2, size_t finalCoun std::vector count(finalCount + 1); for (auto& data : list1) { - count[data.count]++; + count[static_cast(data.count)]++; } for (auto& data : list2) { - count[data.count]++; + count[static_cast(data.count)]++; } for (size_t i = 1; i <= finalCount; ++i) @@ -196,7 +196,7 @@ bool checkTwoConsumerResult(std::list& consumed1, uint64_t expectedFinalCount, uint64_t maxId) { - std::vector> consumed(maxId + 1U); + std::vector> consumed(static_cast(maxId) + 1U); for (uint64_t id = 1; id <= maxId; ++id) { @@ -209,7 +209,7 @@ bool checkTwoConsumerResult(std::list& consumed1, return false; } - if (!isComplete(filtered1, filtered2, expectedFinalCount)) + if (!isComplete(filtered1, filtered2, static_cast(expectedFinalCount))) { IOX_LOG(INFO, "id " << id << " incomplete"); return false; @@ -517,11 +517,11 @@ TYPED_TEST(MpmcLockFreeQueueStressTest, TimedMultiProducerMultiConsumer) } // check whether all elements are there, but there is no specific ordering we can expect - std::vector count(capacity, 0); + std::vector count(static_cast(capacity), 0); auto popped = q.pop(); while (popped.has_value()) { - count[popped.value().count]++; + count[static_cast(popped.value().count)]++; popped = q.pop(); } @@ -585,8 +585,8 @@ TYPED_TEST(MpmcLockFreeQueueStressTest, TimedMultiProducerMultiConsumer0verflow) std::ref(q), id, std::ref(run), - std::ref(overflowCount[id - 1]), - std::ref(itemVec[id - 1]), + std::ref(overflowCount[static_cast(id) - 1]), + std::ref(itemVec[static_cast(id) - 1]), popProbability); } @@ -603,11 +603,11 @@ TYPED_TEST(MpmcLockFreeQueueStressTest, TimedMultiProducerMultiConsumer0verflow) // check whether all elements are there, but there is no specific ordering we can expect // items are either in the local lists or the queue, in total we expect each count numThreads times - std::vector count(capacity, 0U); + std::vector count(static_cast(capacity), 0U); auto popped = q.pop(); while (popped.has_value()) { - count[popped.value().count]++; + count[static_cast(popped.value().count)]++; popped = q.pop(); } @@ -616,14 +616,14 @@ TYPED_TEST(MpmcLockFreeQueueStressTest, TimedMultiProducerMultiConsumer0verflow) { for (auto& item : items) { - count[item.count]++; + count[static_cast(item.count)]++; } } // we expect at least one overflow in the test (since the queue is full in the beginning) // we cannot expect one overflow in each thread due to thread scheduling auto numOverflows = std::accumulate(overflowCount.begin(), overflowCount.end(), 0ULL); - EXPECT_GT(numOverflows, 0LL); + EXPECT_GT(numOverflows, 0ULL); bool testResult = true; for (size_t i = 0; i < capacity; ++i) diff --git a/iceoryx_hoofs/test/stresstests/test_mpmc_resizeable_lockfree_queue_stresstest.cpp b/iceoryx_hoofs/test/stresstests/test_mpmc_resizeable_lockfree_queue_stresstest.cpp index 198eee7567..8af8784a4a 100644 --- a/iceoryx_hoofs/test/stresstests/test_mpmc_resizeable_lockfree_queue_stresstest.cpp +++ b/iceoryx_hoofs/test/stresstests/test_mpmc_resizeable_lockfree_queue_stresstest.cpp @@ -65,7 +65,7 @@ void producePeriodic(Queue& queue, const uint32_t id, CountArray& producedCount, { if (queue.tryPush(d)) { - producedCount[d.count].fetch_add(1U, std::memory_order_relaxed); + producedCount[static_cast(d.count)].fetch_add(1U, std::memory_order_relaxed); d.count = (d.count + 1U) % n; } } @@ -83,7 +83,7 @@ void consume(Queue& queue, CountArray& consumedCount, iox::concurrent::Atomic(value.count)].fetch_add(1U, std::memory_order_relaxed); } } } @@ -305,7 +305,7 @@ void changeCapacity(Queue& queue, incrementK = false; } - if (queue.setCapacity(capacities[static_cast(k)], removeHandler)) + if (queue.setCapacity(capacities[static_cast(k)], removeHandler)) { ++numChanges; } @@ -427,7 +427,7 @@ TYPED_TEST(MpmcResizeableLockFreeQueueStressTest, MultiProducerMultiConsumerComp CountArray consumedCount(cycleLength); // cannot be done with the vector ctor for atomics - for (uint64_t i = 0; i < cycleLength; ++i) + for (size_t i = 0; i < cycleLength; ++i) { producedCount[i].store(0U, std::memory_order_relaxed); consumedCount[i].store(0U, std::memory_order_relaxed); @@ -465,11 +465,11 @@ TYPED_TEST(MpmcResizeableLockFreeQueueStressTest, MultiProducerMultiConsumerComp while (const auto popped = queue.pop()) { const auto& value = popped.value(); - consumedCount[value.count].fetch_add(1U, std::memory_order_relaxed); + consumedCount[static_cast(value.count)].fetch_add(1U, std::memory_order_relaxed); } // verify counts - for (uint64_t i = 0; i < cycleLength; ++i) + for (size_t i = 0; i < cycleLength; ++i) { EXPECT_EQ(producedCount[i].load(), consumedCount[i].load()); } @@ -575,11 +575,11 @@ TYPED_TEST(MpmcResizeableLockFreeQueueStressTest, HybridMultiProducerMultiConsum } // check whether all elements are there, but there is no specific ordering we can expect - std::vector count(capacity, 0); + std::vector count(static_cast(capacity), 0); auto popped = q.pop(); while (popped.has_value()) { - count[popped.value().count]++; + count[static_cast(popped.value().count)]++; popped = q.pop(); } @@ -667,12 +667,12 @@ TYPED_TEST(MpmcResizeableLockFreeQueueStressTest, HybridMultiProducerMultiConsum // items are either in the local lists or the queue, in total we expect each count numThreads times // and for each count each id exactly once - std::vector> count(capacity, std::vector(numThreads + 1, 0)); + std::vector> count(static_cast(capacity), std::vector(numThreads + 1, 0)); auto popped = q.pop(); while (popped.has_value()) { const auto& value = popped.value(); - count[value.count][value.id]++; + count[static_cast(value.count)][value.id]++; popped = q.pop(); } @@ -681,7 +681,7 @@ TYPED_TEST(MpmcResizeableLockFreeQueueStressTest, HybridMultiProducerMultiConsum { for (auto& item : items) { - count[item.count][item.id]++; + count[static_cast(item.count)][item.id]++; } } @@ -787,12 +787,12 @@ TYPED_TEST(MpmcResizeableLockFreeQueueStressTest, HybridMultiProducerMultiConsum // items are either in the local lists or the queue, in total we expect each count numThreads times // and for each count each id exactly once - std::vector> count(capacity, std::vector(numThreads + 1, 0)); + std::vector> count(static_cast(capacity), std::vector(numThreads + 1, 0)); auto popped = q.pop(); while (popped.has_value()) { const auto& value = popped.value(); - count[value.count][value.id]++; + count[static_cast(value.count)][value.id]++; popped = q.pop(); } @@ -801,17 +801,17 @@ TYPED_TEST(MpmcResizeableLockFreeQueueStressTest, HybridMultiProducerMultiConsum { for (auto& item : items) { - count[item.count][item.id]++; + count[static_cast(item.count)][item.id]++; } } bool testResult = true; - for (uint64_t i = 0; i < capacity; ++i) + for (size_t i = 0; i < capacity; ++i) { // we expect each data item exactly numThreads + 1 times, // the extra one is for the initially full queue // and each count appears for all ids exactly ones - for (uint32_t j = 0; j <= numThreads; ++j) + for (size_t j = 0; j <= numThreads; ++j) { if (count[i][j] != 1) { diff --git a/iceoryx_hoofs/utility/include/iox/detail/serialization.inl b/iceoryx_hoofs/utility/include/iox/detail/serialization.inl index 7c8ee96c55..46f0f2213b 100644 --- a/iceoryx_hoofs/utility/include/iox/detail/serialization.inl +++ b/iceoryx_hoofs/utility/include/iox/detail/serialization.inl @@ -107,13 +107,13 @@ inline bool Serialization::deserialize(const std::string& serializedString, T& t inline bool Serialization::removeFirstEntry(std::string& firstEntry, std::string& remainder) noexcept { - uint64_t pos = remainder.find_first_of(SEPARATOR); + auto pos = remainder.find_first_of(SEPARATOR); if (pos == std::string::npos) { return false; } - auto result = convert::from_string(remainder.substr(0, pos).c_str()); + auto result = convert::from_string(remainder.substr(0U, pos).c_str()); if (!result.has_value()) { diff --git a/iceoryx_hoofs/utility/include/iox/detail/std_string_support.inl b/iceoryx_hoofs/utility/include/iox/detail/std_string_support.inl index ea5c5aba5d..95106d03b7 100644 --- a/iceoryx_hoofs/utility/include/iox/detail/std_string_support.inl +++ b/iceoryx_hoofs/utility/include/iox/detail/std_string_support.inl @@ -24,7 +24,7 @@ namespace iox template inline std::string FromImpl, std::string>::fromImpl(const string& value) noexcept { - return std::string(value.c_str(), value.size()); + return std::string(value.c_str(), static_cast(value.size())); } template diff --git a/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl b/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl index 4ed91aa090..4c96ca7b08 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl +++ b/iceoryx_hoofs/vocabulary/include/iox/detail/string.inl @@ -147,7 +147,7 @@ inline string::string(TruncateToCapacity_t, const char* const other, c } else { - std::memcpy(m_rawstring, other, count); + std::memcpy(m_rawstring, other, static_cast(count)); m_rawstring[count] = '\0'; m_rawstringSize = count; } @@ -187,7 +187,7 @@ inline string& string::operator=(const char (&rhs)[N]) noexc #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Warray-bounds" #endif - std::memcpy(m_rawstring, rhs, m_rawstringSize); + std::memcpy(m_rawstring, rhs, static_cast(m_rawstringSize)); #if (defined(__GNUC__) && (__GNUC__ == 8)) && (__GNUC_MINOR__ >= 3) #pragma GCC diagnostic pop #endif @@ -234,7 +234,7 @@ inline bool string::unsafe_assign(const char* const str) noexcept << ") of the fixed string."); return false; } - std::memcpy(m_rawstring, str, strSize); + std::memcpy(m_rawstring, str, static_cast(strSize)); m_rawstring[strSize] = '\0'; m_rawstringSize = strSize; return true; @@ -264,7 +264,8 @@ template inline IsStringOrCharArray string::compare(const T& other) const noexcept { const uint64_t otherSize{internal::GetSize::call(other)}; - const auto result = memcmp(c_str(), internal::GetData::call(other), std::min(m_rawstringSize, otherSize)); + const auto result = + memcmp(c_str(), internal::GetData::call(other), static_cast(std::min(m_rawstringSize, otherSize))); if (result == 0) { if (m_rawstringSize < otherSize) @@ -330,7 +331,7 @@ inline string& string::copy(const string& rhs) noexcept static_assert(N <= Capacity, "Assignment failed. The capacity of the given fixed string is larger than the capacity of this."); const uint64_t strSize{rhs.size()}; - std::memcpy(m_rawstring, rhs.c_str(), strSize); + std::memcpy(m_rawstring, rhs.c_str(), static_cast(strSize)); m_rawstring[strSize] = '\0'; m_rawstringSize = strSize; return *this; @@ -344,7 +345,7 @@ inline string& string::move(string&& rhs) noexcept static_assert(N <= Capacity, "Assignment failed. The capacity of the given fixed string is larger than the capacity of this."); const uint64_t strSize{rhs.size()}; - std::memcpy(m_rawstring, rhs.c_str(), strSize); + std::memcpy(m_rawstring, rhs.c_str(), static_cast(strSize)); m_rawstring[strSize] = '\0'; m_rawstringSize = strSize; rhs.clear(); @@ -379,8 +380,8 @@ concatenate(const T1& str1, const T2& str2) noexcept uint64_t size2{internal::GetSize::call(str2)}; using NewStringType = string::value>; NewStringType newString; - std::memcpy(newString.m_rawstring, internal::GetData::call(str1), size1); - std::memcpy(&newString.m_rawstring[size1], internal::GetData::call(str2), size2); + std::memcpy(newString.m_rawstring, internal::GetData::call(str1), static_cast(size1)); + std::memcpy(&newString.m_rawstring[size1], internal::GetData::call(str2), static_cast(size2)); newString.m_rawstring[size1 + size2] = '\0'; newString.m_rawstringSize = size1 + size2; @@ -417,7 +418,7 @@ inline IsStringOrCharArrayOrChar string::unsafe_append(const return false; } - std::memcpy(&(m_rawstring[m_rawstringSize]), tData, clampedTSize); + std::memcpy(&(m_rawstring[m_rawstringSize]), tData, static_cast(clampedTSize)); m_rawstringSize += clampedTSize; m_rawstring[m_rawstringSize] = '\0'; return true; @@ -434,7 +435,7 @@ inline IsStringOrCharArrayOrChar&> string::append( const char* const tData{internal::GetData::call(str)}; uint64_t const clampedTSize{std::min(Capacity - m_rawstringSize, tSize)}; - std::memcpy(&(m_rawstring[m_rawstringSize]), tData, clampedTSize); + std::memcpy(&(m_rawstring[m_rawstringSize]), tData, static_cast(clampedTSize)); if (tSize > clampedTSize) { IOX_LOG(WARN, @@ -487,8 +488,9 @@ string::insert(const uint64_t pos, const T& str, const uint64_t count) { return false; } - std::memmove(&m_rawstring[pos + count], &m_rawstring[pos], m_rawstringSize - pos); - std::memcpy(&m_rawstring[pos], internal::GetData::call(str), count); + auto number_of_characters_to_move = static_cast(m_rawstringSize) - static_cast(pos); + std::memmove(&m_rawstring[pos + count], &m_rawstring[pos], number_of_characters_to_move); + std::memcpy(&m_rawstring[pos], internal::GetData::call(str), static_cast(count)); m_rawstring[new_size] = '\0'; m_rawstringSize = new_size; @@ -506,7 +508,7 @@ inline optional> string::substr(const uint64_t pos, c const uint64_t length{std::min(count, m_rawstringSize - pos)}; string subString; - std::memcpy(subString.m_rawstring, &m_rawstring[pos], length); + std::memcpy(subString.m_rawstring, &m_rawstring[pos], static_cast(length)); subString.m_rawstring[length] = '\0'; subString.m_rawstringSize = length; return subString; @@ -549,7 +551,7 @@ inline IsStringOrCharArray> string::find_first_o const uint64_t dataSize{internal::GetSize::call(str)}; for (auto p = pos; p < m_rawstringSize; ++p) { - const void* const found{memchr(data, m_rawstring[p], dataSize)}; + const void* const found{memchr(data, m_rawstring[p], static_cast(dataSize))}; if (found != nullptr) { return p; @@ -577,13 +579,13 @@ inline IsStringOrCharArray> string::find_last_of const uint64_t dataSize{internal::GetSize::call(str)}; for (; p > 0U; --p) { - const void* const found{memchr(data, m_rawstring[p], dataSize)}; + const void* const found{memchr(data, m_rawstring[p], static_cast(dataSize))}; if (found != nullptr) { return p; } } - const void* const found{memchr(data, m_rawstring[p], dataSize)}; + const void* const found{memchr(data, m_rawstring[p], static_cast(dataSize))}; if (found != nullptr) { return 0U; diff --git a/iceoryx_platform/linux/cmake/IceoryxPlatformSettings.cmake b/iceoryx_platform/linux/cmake/IceoryxPlatformSettings.cmake index 61343796eb..084cb4df1f 100644 --- a/iceoryx_platform/linux/cmake/IceoryxPlatformSettings.cmake +++ b/iceoryx_platform/linux/cmake/IceoryxPlatformSettings.cmake @@ -23,9 +23,6 @@ set_global(VAR ICEORYX_TEST_CXX_FLAGS VALUE ) set_global(VAR ICEORYX_C_WARNINGS VALUE -W -Wall -Wextra -Wuninitialized -Wpedantic -Wstrict-aliasing -Wcast-align -Wconversion) set_global(VAR ICEORYX_CXX_WARNINGS VALUE ${ICEORYX_C_WARNINGS} -Wno-noexcept-type) -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - set_global(VAR ICEORYX_CXX_WARNINGS VALUE ${ICEORYX_CXX_WARNINGS} -Wuseless-cast) -endif() if(BUILD_STRICT) set_global(VAR ICEORYX_C_WARNINGS VALUE ${ICEORYX_C_WARNINGS} -Werror) diff --git a/iceoryx_platform/qnx/cmake/IceoryxPlatformSettings.cmake b/iceoryx_platform/qnx/cmake/IceoryxPlatformSettings.cmake index 6440019655..11d59ab562 100644 --- a/iceoryx_platform/qnx/cmake/IceoryxPlatformSettings.cmake +++ b/iceoryx_platform/qnx/cmake/IceoryxPlatformSettings.cmake @@ -22,7 +22,7 @@ set_global(VAR ICEORYX_CXX_FLAGS VALUE ) set_global(VAR ICEORYX_TEST_CXX_FLAGS VALUE ) set_global(VAR ICEORYX_C_WARNINGS VALUE -W -Wall -Wextra -Wuninitialized -Wpedantic -Wstrict-aliasing -Wcast-align -Wconversion) -set_global(VAR ICEORYX_CXX_WARNINGS VALUE ${ICEORYX_C_WARNINGS} -Wno-noexcept-type -Wno-useless-cast) +set_global(VAR ICEORYX_CXX_WARNINGS VALUE ${ICEORYX_C_WARNINGS} -Wno-noexcept-type) if(BUILD_STRICT) set_global(VAR ICEORYX_C_WARNINGS VALUE ${ICEORYX_C_WARNINGS} -Werror) diff --git a/iceoryx_posh/experimental/source/node.cpp b/iceoryx_posh/experimental/source/node.cpp index 03d30fdc06..e9a9d56d2b 100644 --- a/iceoryx_posh/experimental/source/node.cpp +++ b/iceoryx_posh/experimental/source/node.cpp @@ -41,7 +41,8 @@ NodeBuilder&& NodeBuilder::domain_id_from_env() && noexcept iox::string<10> domain_id_string; domain_id_string.unsafe_raw_access([](auto* buffer, const auto info) { size_t actual_size_with_null{0}; - auto result = IOX_POSIX_CALL(iox_getenv_s)(&actual_size_with_null, buffer, info.total_size, "IOX_DOMAIN_ID") + auto result = IOX_POSIX_CALL(iox_getenv_s)( + &actual_size_with_null, buffer, static_cast(info.total_size), "IOX_DOMAIN_ID") .failureReturnValue(-1) .evaluate(); if (result.has_error() && result.error().errnum == ERANGE) diff --git a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl index ce035ff5fd..b7a568b9f3 100644 --- a/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl +++ b/iceoryx_posh/include/iceoryx_posh/internal/roudi/introspection/mempool_introspection.inl @@ -163,7 +163,7 @@ MemPoolIntrospection::copyMemPoolI dst.m_minFreeChunks = src.m_minFreeChunks; dst.m_numChunks = src.m_numChunks; dst.m_chunkSize = src.m_chunkSize; - dst.m_chunkPayloadSize = src.m_chunkSize - static_cast(sizeof(mepoo::ChunkHeader)); + dst.m_chunkPayloadSize = src.m_chunkSize - sizeof(mepoo::ChunkHeader); } } diff --git a/iceoryx_posh/source/roudi/memory/default_roudi_memory.cpp b/iceoryx_posh/source/roudi/memory/default_roudi_memory.cpp index 386e47d077..6c87d3843c 100644 --- a/iceoryx_posh/source/roudi/memory/default_roudi_memory.cpp +++ b/iceoryx_posh/source/roudi/memory/default_roudi_memory.cpp @@ -48,19 +48,17 @@ DefaultRouDiMemory::DefaultRouDiMemory(const IceoryxConfig& config) noexcept mepoo::MePooConfig DefaultRouDiMemory::introspectionMemPoolConfig(const uint32_t chunkCount) const noexcept { - constexpr uint32_t ALIGNMENT{mepoo::MemPool::CHUNK_MEMORY_ALIGNMENT}; + constexpr size_t ALIGNMENT{mepoo::MemPool::CHUNK_MEMORY_ALIGNMENT}; mepoo::MePooConfig mempoolConfig; mempoolConfig.m_mempoolConfig.push_back( - {align(static_cast(sizeof(roudi::MemPoolIntrospectionInfoContainer)), ALIGNMENT), chunkCount}); + {align(sizeof(roudi::MemPoolIntrospectionInfoContainer), ALIGNMENT), chunkCount}); mempoolConfig.m_mempoolConfig.push_back( - {align(static_cast(sizeof(roudi::ProcessIntrospectionFieldTopic)), ALIGNMENT), chunkCount}); + {align(sizeof(roudi::ProcessIntrospectionFieldTopic), ALIGNMENT), chunkCount}); + mempoolConfig.m_mempoolConfig.push_back({align(sizeof(roudi::PortIntrospectionFieldTopic), ALIGNMENT), chunkCount}); mempoolConfig.m_mempoolConfig.push_back( - {align(static_cast(sizeof(roudi::PortIntrospectionFieldTopic)), ALIGNMENT), chunkCount}); + {align(sizeof(roudi::PortThroughputIntrospectionFieldTopic), ALIGNMENT), chunkCount}); mempoolConfig.m_mempoolConfig.push_back( - {align(static_cast(sizeof(roudi::PortThroughputIntrospectionFieldTopic)), ALIGNMENT), chunkCount}); - mempoolConfig.m_mempoolConfig.push_back( - {align(static_cast(sizeof(roudi::SubscriberPortChangingIntrospectionFieldTopic)), ALIGNMENT), - chunkCount}); + {align(sizeof(roudi::SubscriberPortChangingIntrospectionFieldTopic), ALIGNMENT), chunkCount}); mempoolConfig.optimize(); return mempoolConfig; @@ -68,10 +66,9 @@ mepoo::MePooConfig DefaultRouDiMemory::introspectionMemPoolConfig(const uint32_t mepoo::MePooConfig DefaultRouDiMemory::discoveryMemPoolConfig(const uint32_t chunkCount) const noexcept { - constexpr uint32_t ALIGNMENT{mepoo::MemPool::CHUNK_MEMORY_ALIGNMENT}; + constexpr size_t ALIGNMENT{mepoo::MemPool::CHUNK_MEMORY_ALIGNMENT}; mepoo::MePooConfig mempoolConfig; - mempoolConfig.m_mempoolConfig.push_back( - {align(static_cast(sizeof(roudi::ServiceRegistry)), ALIGNMENT), chunkCount}); + mempoolConfig.m_mempoolConfig.push_back({align(sizeof(roudi::ServiceRegistry), ALIGNMENT), chunkCount}); mempoolConfig.optimize(); return mempoolConfig; diff --git a/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp b/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp index 4c528934bb..07428bfdf8 100644 --- a/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp +++ b/iceoryx_posh/test/integrationtests/test_posh_mepoo.cpp @@ -254,7 +254,7 @@ class Mepoo_IntegrationTest : public Test { if (info.m_chunkSize != 0) { - info.m_chunkSize = info.m_chunkSize - static_cast(sizeof(iox::mepoo::ChunkHeader)); + info.m_chunkSize = info.m_chunkSize - sizeof(iox::mepoo::ChunkHeader); } } }); diff --git a/iceoryx_posh/test/mocks/roudi_memory_provider_mock.hpp b/iceoryx_posh/test/mocks/roudi_memory_provider_mock.hpp index cc4caea58e..6a1d0db39b 100644 --- a/iceoryx_posh/test/mocks/roudi_memory_provider_mock.hpp +++ b/iceoryx_posh/test/mocks/roudi_memory_provider_mock.hpp @@ -46,7 +46,7 @@ class MemoryProviderTestImpl : public iox::roudi::MemoryProvider createMemoryMock(size, alignment); } - dummyMemory = iox::alignedAlloc(alignment, size); + dummyMemory = iox::alignedAlloc(static_cast(alignment), static_cast(size)); return iox::ok(dummyMemory); } MOCK_METHOD(void, createMemoryMock, (uint64_t, uint64_t), (noexcept)); diff --git a/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp b/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp index 0152bd535b..d0422bf7e9 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_chunk_header.cpp @@ -456,7 +456,7 @@ void checkUserPayloadNotOverlappingWithUserHeader(const ChunkHeader& sut, const const uint64_t chunkStartAddress{reinterpret_cast(&sut)}; const uint64_t userPayloadStartAddress{reinterpret_cast(sut.userPayload())}; const uint64_t userHeaderSizeAndPadding{ - iox::algorithm::maxVal(userHeaderSize, static_cast(alignof(UserPayloadOffset_t)))}; + iox::algorithm::maxVal(static_cast(userHeaderSize), alignof(UserPayloadOffset_t))}; constexpr uint64_t BACK_OFFSET_SIZE{sizeof(UserPayloadOffset_t)}; const uint64_t expectedRequiredSpace{sizeof(ChunkHeader) + userHeaderSizeAndPadding + BACK_OFFSET_SIZE}; diff --git a/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp b/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp index 2a4ca2f4af..0d2cbb026e 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_chunk_settings.cpp @@ -349,8 +349,8 @@ INSTANTIATE_TEST_SUITE_P(ChunkSettings_test, uint64_t expectedChunkSizeWithUserHeader(const PayloadParams& userPayload, uint32_t userHeaderSize) { - const uint32_t userHeaderSizeAndPaddingToBackOffset = - iox::algorithm::maxVal(userHeaderSize, static_cast(alignof(UserPayloadOffset_t))); + const auto userHeaderSizeAndPaddingToBackOffset = + iox::algorithm::maxVal(static_cast(userHeaderSize), alignof(UserPayloadOffset_t)); if (userPayload.alignment <= alignof(UserPayloadOffset_t)) { diff --git a/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp b/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp index 04e9f65a0d..dd073ca655 100644 --- a/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_chunk_distributor.cpp @@ -798,7 +798,7 @@ TYPED_TEST(ChunkDistributor_test, MultipleBlockingQueuesWillBeFilledWhenThereBec std::this_thread::sleep_for(this->BLOCKING_DURATION); EXPECT_THAT(wasChunkDelivered.load(), Eq(false)); - for (uint64_t i = 0U; i < NUMBER_OF_QUEUES; ++i) + for (size_t i = 0U; i < NUMBER_OF_QUEUES; ++i) { auto maybeSharedChunk = queues[i].tryPop(); ASSERT_THAT(maybeSharedChunk.has_value(), Eq(true)); diff --git a/iceoryx_posh/test/moduletests/test_popo_listener.cpp b/iceoryx_posh/test/moduletests/test_popo_listener.cpp index 556d697ad7..92c01b5016 100644 --- a/iceoryx_posh/test/moduletests/test_popo_listener.cpp +++ b/iceoryx_posh/test/moduletests/test_popo_listener.cpp @@ -892,7 +892,7 @@ TIMING_TEST_F(Listener_test, TriggeringAllEventsCallsAllCallbacks, Repeat(5), [& TIMING_TEST_EXPECT_TRUE(g_triggerCallbackArg[0].m_source.load() == &events[0U]); TIMING_TEST_EXPECT_TRUE(g_triggerCallbackArg[0].m_count.load() == 2U); - for (uint64_t i = 1U; i < iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER; ++i) + for (size_t i = 1U; i < iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER; ++i) { TIMING_TEST_EXPECT_TRUE(g_triggerCallbackArg[i].m_source.load() == &events[i]); TIMING_TEST_EXPECT_TRUE(g_triggerCallbackArg[i].m_count.load() == 1U); @@ -925,7 +925,7 @@ TIMING_TEST_F(Listener_test, TriggeringAllEventsCallsAllCallbacksOnce, Repeat(5) TIMING_TEST_EXPECT_TRUE(g_triggerCallbackArg[0].m_source.load() == &events[0U]); TIMING_TEST_EXPECT_TRUE(g_triggerCallbackArg[0].m_count.load() == 3U); - for (uint64_t i = 1U; i < iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER; ++i) + for (size_t i = 1U; i < iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER; ++i) { TIMING_TEST_EXPECT_TRUE(g_triggerCallbackArg[i].m_source.load() == &events[i]); TIMING_TEST_EXPECT_TRUE(g_triggerCallbackArg[i].m_count.load() == 1U); @@ -984,13 +984,13 @@ TIMING_TEST_F(Listener_test, AttachingMultipleWhileCallbackIsRunningWorks, Repea AttachEvent::doIt(*m_sut, events, SimpleEvent::StoepselBachelorParty); g_triggerCallbackRuntimeInMs = 0U; - for (uint64_t i = 0U; i + 1U < iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER; ++i) + for (size_t i = 0U; i + 1U < iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER; ++i) { events[i].triggerStoepsel(); } std::this_thread::sleep_for(std::chrono::milliseconds(CALLBACK_WAIT_IN_MS / 2U)); - for (uint64_t i = 0U; i + 1U < iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER; ++i) + for (size_t i = 0U; i + 1U < iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER; ++i) { TIMING_TEST_EXPECT_TRUE(g_triggerCallbackArg[i].m_source.load() == &events[i]); TIMING_TEST_EXPECT_TRUE(g_triggerCallbackArg[i].m_count.load() == 1U); @@ -1089,7 +1089,7 @@ TIMING_TEST_F(Listener_test, DetachingMultipleWhileCallbackIsRunningWorks, Repea } std::this_thread::sleep_for(std::chrono::milliseconds(CALLBACK_WAIT_IN_MS)); - for (uint64_t i = 0U; i < iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER; ++i) + for (size_t i = 0U; i < iox::MAX_NUMBER_OF_EVENTS_PER_LISTENER; ++i) { TIMING_TEST_EXPECT_TRUE(g_triggerCallbackArg[i].m_source.load() == nullptr); } diff --git a/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/chunk_mock.hpp b/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/chunk_mock.hpp index 3a8a58f4fc..4240e9d7c0 100644 --- a/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/chunk_mock.hpp +++ b/iceoryx_posh/testing/include/iceoryx_posh/testing/mocks/chunk_mock.hpp @@ -48,9 +48,10 @@ class ChunkMock auto& chunkSettings = chunkSettingsResult.value(); auto chunkSize = chunkSettings.requiredChunkSize(); - m_rawMemory = static_cast(iox::alignedAlloc(alignof(iox::mepoo::ChunkHeader), chunkSize)); + m_rawMemory = + static_cast(iox::alignedAlloc(alignof(iox::mepoo::ChunkHeader), static_cast(chunkSize))); assert(m_rawMemory != nullptr && "Could not get aligned memory"); - memset(m_rawMemory, 0xFF, chunkSize); + memset(m_rawMemory, 0xFF, static_cast(chunkSize)); m_chunkHeader = new (m_rawMemory) iox::mepoo::ChunkHeader(chunkSize, chunkSettings); diff --git a/tools/introspection/source/introspection_app.cpp b/tools/introspection/source/introspection_app.cpp index d938298005..9fe006599d 100644 --- a/tools/introspection/source/introspection_app.cpp +++ b/tools/introspection/source/introspection_app.cpp @@ -280,6 +280,22 @@ void IntrospectionApp::printProcessIntrospectionData(const ProcessIntrospectionF wprintw(pad, "\n"); } +template +constexpr const char* format_uint64_t() noexcept; +template <> +constexpr const char* format_uint64_t() noexcept +{ + return "%*lu%s"; +} +template <> +constexpr const char* format_uint64_t() noexcept +{ + return "%*llu%s"; +} + +template +static constexpr const char* FORMAT_UINT64_T{format_uint64_t()}; + void IntrospectionApp::printMemPoolInfo(const MemPoolIntrospectionInfo& introspectionInfo) { wprintw(pad, "Segment ID: %d\n", introspectionInfo.m_id); @@ -312,12 +328,12 @@ void IntrospectionApp::printMemPoolInfo(const MemPoolIntrospectionInfo& introspe auto& info = introspectionInfo.m_mempoolInfo[i]; if (info.m_numChunks > 0u) { - wprintw(pad, "%*zd |", memPoolWidth, i + 1u); - wprintw(pad, "%*d |", usedchunksWidth, info.m_usedChunks); - wprintw(pad, "%*d |", numchunksWidth, info.m_numChunks); - wprintw(pad, "%*d |", minFreechunksWidth, info.m_minFreeChunks); - wprintw(pad, "%*ld |", chunkSizeWidth, info.m_chunkSize); - wprintw(pad, "%*ld\n", chunkPayloadSizeWidth, info.m_chunkPayloadSize); + wprintw(pad, "%*zu |", memPoolWidth, i + 1u); + wprintw(pad, "%*u |", usedchunksWidth, info.m_usedChunks); + wprintw(pad, "%*u |", numchunksWidth, info.m_numChunks); + wprintw(pad, "%*u |", minFreechunksWidth, info.m_minFreeChunks); + wprintw(pad, FORMAT_UINT64_T, chunkSizeWidth, info.m_chunkSize, " |"); + wprintw(pad, FORMAT_UINT64_T, chunkPayloadSizeWidth, info.m_chunkPayloadSize, "\n"); } } wprintw(pad, "\n"); @@ -576,7 +592,8 @@ IntrospectionApp::composePublisherPortData(const PortIntrospectionFieldTopic* po const PortThroughputIntrospectionFieldTopic* throughputData) { std::vector publisherPortData; - publisherPortData.reserve(portData->m_publisherList.size()); + auto listSize = portData->m_publisherList.size(); + publisherPortData.reserve(static_cast(listSize)); const PortThroughputData dummyThroughputData; @@ -625,7 +642,8 @@ std::vector IntrospectionApp::composeSubscriberPortD const SubscriberPortChangingIntrospectionFieldTopic* subscriberPortChangingData) { std::vector subscriberPortData; - subscriberPortData.reserve(portData->m_subscriberList.size()); + auto listSize = portData->m_subscriberList.size(); + subscriberPortData.reserve(static_cast(listSize)); uint32_t i = 0U; if (portData->m_subscriberList.size() == subscriberPortChangingData->subscriberPortChangingDataList.size()) From eabd91ec28bd138841c589a4d3d795eb0d2a400a Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Thu, 22 Aug 2024 21:19:34 +0200 Subject: [PATCH 08/10] iox-#2301 Add 32 bit build to CI --- .../install-iceoryx-deps-and-clang/action.yml | 2 ++ .github/workflows/build-test.yml | 25 ++++++++++++++++--- doc/website/getting-started/installation.md | 7 ++++++ tools/ci/build-test-ubuntu.sh | 22 +++++++++++----- tools/iceoryx_build_test.sh | 2 ++ tools/scripts/ice_env.sh | 7 +++++- 6 files changed, 55 insertions(+), 10 deletions(-) diff --git a/.github/actions/install-iceoryx-deps-and-clang/action.yml b/.github/actions/install-iceoryx-deps-and-clang/action.yml index 5b4c51da03..b4fd5e2afc 100644 --- a/.github/actions/install-iceoryx-deps-and-clang/action.yml +++ b/.github/actions/install-iceoryx-deps-and-clang/action.yml @@ -5,10 +5,12 @@ runs: - name: Install iceoryx dependencies and clang-tidy shell: bash run: | + sudo dpkg --add-architecture i386 sudo wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main" sudo apt-get update sudo apt-get install -y libacl1-dev libncurses5-dev + sudo apt-get install -y libacl1-dev:i386 libc6-dev-i386 libc6-dev-i386-cross libstdc++6-i386-cross gcc-multilib g++-multilib sudo apt-get install -y clang-format-15 clang-tidy-15 clang-tools-15 clang-15 lld sudo rm /usr/bin/clang sudo rm /usr/bin/clang++ diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 753ef62f70..e925a669bd 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -55,17 +55,24 @@ jobs: runs-on: ubuntu-20.04 needs: pre-flight-check steps: - - uses: actions/checkout@v4 - - uses: egor-tensin/setup-gcc@v1.3 + - name: Checkout + uses: actions/checkout@v4 + - name: Install iceoryx dependencies and clang-tidy + uses: ./.github/actions/install-iceoryx-deps-and-clang + - name: Setup GCC + uses: egor-tensin/setup-gcc@v1.3 with: # gcc 8.3 is compiler used in QNX 7.1 version: 8 platform: x64 - - uses: jwlawson/actions-setup-cmake@v2.0 + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0 with: cmake-version: '3.16.3' # version used in Ubuntu 20.04 LTS - run: ./tools/ci/build-test-ubuntu.sh + + build-test-windows-msvc: # prevent stuck jobs consuming runners for 6 hours timeout-minutes: 60 @@ -172,6 +179,18 @@ jobs: - name: Run Thread Sanitizer run: ./tools/ci/build-test-ubuntu-with-sanitizers.sh clang tsan + build-test-ubuntu-32-bit: + # prevent stuck jobs consuming runners for 6 hours + timeout-minutes: 60 + runs-on: ubuntu-latest + needs: pre-flight-check + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install iceoryx dependencies and clang-tidy + uses: ./.github/actions/install-iceoryx-deps-and-clang + - run: ./tools/ci/build-test-ubuntu.sh 32-bit-x86 + # Bazel sanity check build-test-ubuntu-bazel: # prevent stuck jobs consuming runners for 6 hours diff --git a/doc/website/getting-started/installation.md b/doc/website/getting-started/installation.md index 32d253baf3..cfc486a208 100644 --- a/doc/website/getting-started/installation.md +++ b/doc/website/getting-started/installation.md @@ -43,6 +43,13 @@ You will need to install the following packages: sudo apt install gcc g++ cmake libacl1-dev libncurses5-dev pkg-config ``` +To build iceoryx as 32-bit library, the following packages need to be installed additionally: + +```bash +sudo dpkg --add-architecture i386 +sudo apt install libacl1-dev:i386 libc6-dev-i386 libc6-dev-i386-cross libstdc++6-i386-cross gcc-multilib g++-multilib +``` + Additionally, there is an optional dependency to the [cpptoml](https://github.com/skystrife/cpptoml) library, which is used to parse the RouDi config file containing mempool configuration. ### QNX diff --git a/tools/ci/build-test-ubuntu.sh b/tools/ci/build-test-ubuntu.sh index 443ce3dc4c..20a4ffd595 100755 --- a/tools/ci/build-test-ubuntu.sh +++ b/tools/ci/build-test-ubuntu.sh @@ -19,6 +19,19 @@ set -e +COMPILER=gcc +SANITIZER=asan +BUILD_32BIT="" + +while (( "$#" )); do + case "$1" in + "32-bit-x86") + BUILD_32BIT="32-bit-x86" + shift 1 + ;; + esac +done + msg() { printf "\033[1;32m%s: %s\033[0m\n" ${FUNCNAME[1]} "$1" } @@ -26,9 +39,6 @@ msg() { WORKSPACE=$(git rev-parse --show-toplevel) cd ${WORKSPACE} -msg "installing build dependencies" -sudo apt-get update && sudo apt-get install -y libacl1-dev libncurses5-dev - msg "creating local test users and groups for testing access control" sudo ./tools/scripts/add_test_users.sh @@ -37,10 +47,10 @@ $(gcc --version) $(clang --version)" msg "building sources" -./tools/iceoryx_build_test.sh build-strict build-all out-of-tree build-shared test-add-user +./tools/iceoryx_build_test.sh build-strict build-all out-of-tree build-shared test-add-user ${BUILD_32BIT} msg "building debian package" -./tools/iceoryx_build_test.sh package +./tools/iceoryx_build_test.sh package ${BUILD_32BIT} # there are tests which open quite a lot of file descriptors simultaneously to exhaust the creation of some resources # therefore the limits needs to be increased @@ -53,4 +63,4 @@ cd ./build cd - msg "building roudi examples without toml support" -./tools/iceoryx_build_test.sh relwithdebinfo out-of-tree examples toml-config-off clean +./tools/iceoryx_build_test.sh relwithdebinfo out-of-tree examples toml-config-off clean ${BUILD_32BIT} diff --git a/tools/iceoryx_build_test.sh b/tools/iceoryx_build_test.sh index 1a891a1f3b..b0e4ad278c 100755 --- a/tools/iceoryx_build_test.sh +++ b/tools/iceoryx_build_test.sh @@ -382,6 +382,8 @@ if [ "$OUT_OF_TREE_FLAG" == "ON" ]; then cmake -DCMAKE_INSTALL_PREFIX="$ICEORYX_INSTALL_PREFIX" \ -DTOML_CONFIG=$TOML_FLAG \ -DBINDING_C=$BINDING_C_FLAG \ + -DCMAKE_C_FLAGS="$CMAKE_C_FLAGS" \ + -DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \ "$WORKSPACE"/iceoryx_examples/"$ex" if ! cmake --build . --target install -- -j$NUM_JOBS; then echo "Out of tree build failed" diff --git a/tools/scripts/ice_env.sh b/tools/scripts/ice_env.sh index a91cd98c82..62f8fa55d3 100755 --- a/tools/scripts/ice_env.sh +++ b/tools/scripts/ice_env.sh @@ -17,7 +17,7 @@ # SPDX-License-Identifier: Apache-2.0 CONTAINER_NAME_PREFIX="ice_env_" -CONTAINER_MEMORY_SIZE="6g" +CONTAINER_MEMORY_SIZE="8g" CONTAINER_SHM_MEMORY_SIZE="2g" DEFAULT_OS_VERSION="ubuntu:22.04" CMAKE_VERSION="cmake-3.23.1-linux-x86_64" @@ -48,8 +48,10 @@ setup_docker_image() { # ubuntu/debian and derivatives if command -v apt &>/dev/null; then + dpkg --add-architecture i386 apt update apt -y install g++ gcc sudo cmake git fish gdb lldb llvm clang clang-format wget libncurses5-dev libacl1-dev wget lsb-release software-properties-common vim + apt -y install libacl1-dev:i386 libc6-dev-i386 libc6-dev-i386-cross libstdc++6-i386-cross gcc-multilib g++-multilib install_cmake # install newest clang @@ -67,7 +69,10 @@ setup_docker_image() { # archlinux based ones elif command -v pacman &>/dev/null; then + echo "[multilib]" >> /etc/pacman.conf + echo "Include = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf pacman -Syu --noconfirm base base-devel clang cmake git fish gdb lldb llvm wget ncurses vim + pacman -Syu --noconfirm lib32-acl lib32-gcc-libs lib32-ncurses install_cmake else echo Please install the following packages to have a working iceoryx environment: From 848f805af692e4270e3010204d1debcbec4160af Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Fri, 23 Aug 2024 00:26:37 +0200 Subject: [PATCH 09/10] iox-#2301 Fix tests for 32 bit builds --- iceoryx_binding_c/source/c_subscriber.cpp | 5 ++-- .../test/moduletests/test_client.cpp | 2 +- .../test/moduletests/test_publisher.cpp | 2 +- .../test/moduletests/test_server.cpp | 2 +- .../test/moduletests/test_subscriber.cpp | 17 +++++++++++-- .../moduletests/test_time_unit_duration.cpp | 8 +++--- iceoryx_hoofs/testing/CMakeLists.txt | 3 +++ .../test_posh_experimental_node.cpp | 7 ++++++ .../test/moduletests/test_mepoo_mempool.cpp | 25 ++++++++++++------- .../test/moduletests/test_mepoo_segment.cpp | 2 +- 10 files changed, 52 insertions(+), 21 deletions(-) diff --git a/iceoryx_binding_c/source/c_subscriber.cpp b/iceoryx_binding_c/source/c_subscriber.cpp index 9886ebce3b..0cb263c68e 100644 --- a/iceoryx_binding_c/source/c_subscriber.cpp +++ b/iceoryx_binding_c/source/c_subscriber.cpp @@ -110,8 +110,9 @@ iox_sub_t iox_sub_init(iox_sub_storage_t* self, auto meWithStoragePointer = new SubscriberWithStoragePointer(); meWithStoragePointer->subscriberStorage = self; auto me = &meWithStoragePointer->subscriber; - assert(reinterpret_cast(me) - reinterpret_cast(meWithStoragePointer) == sizeof(void*) - && "Size mismatch for SubscriberWithStoragePointer!"); + auto ptrDiff = reinterpret_cast(me) - reinterpret_cast(meWithStoragePointer); + IOX_ENFORCE(ptrDiff >= sizeof(void*), "Size mismatch for SubscriberWithStoragePointer!"); + IOX_ENFORCE(ptrDiff <= 2 * sizeof(void*), "Size mismatch for SubscriberWithStoragePointer!"); me->m_portData = PoshRuntime::getInstance().getMiddlewareSubscriber(ServiceDescription{IdString_t(TruncateToCapacity, service), diff --git a/iceoryx_binding_c/test/moduletests/test_client.cpp b/iceoryx_binding_c/test/moduletests/test_client.cpp index 02861d195f..3f74e6a615 100644 --- a/iceoryx_binding_c/test/moduletests/test_client.cpp +++ b/iceoryx_binding_c/test/moduletests/test_client.cpp @@ -109,7 +109,7 @@ class iox_client_test : public Test char managementMemory[MANAGEMENT_MEMORY_SIZE]; iox::BumpAllocator mgmtAllocator{managementMemory, MANAGEMENT_MEMORY_SIZE}; static constexpr uint64_t DATA_MEMORY_SIZE = 1024 * 1024; - char dataMemory[DATA_MEMORY_SIZE]; + alignas(8) char dataMemory[DATA_MEMORY_SIZE]; iox::BumpAllocator dataAllocator{dataMemory, DATA_MEMORY_SIZE}; iox::mepoo::MemoryManager memoryManager; iox::mepoo::MePooConfig memoryConfig; diff --git a/iceoryx_binding_c/test/moduletests/test_publisher.cpp b/iceoryx_binding_c/test/moduletests/test_publisher.cpp index 484cf185dd..ee9f37e126 100644 --- a/iceoryx_binding_c/test/moduletests/test_publisher.cpp +++ b/iceoryx_binding_c/test/moduletests/test_publisher.cpp @@ -97,7 +97,7 @@ class iox_pub_test : public Test } static constexpr size_t MEMORY_SIZE = 1024 * 1024; - uint8_t m_memory[MEMORY_SIZE]; + alignas(8) uint8_t m_memory[MEMORY_SIZE]; static constexpr uint32_t NUM_CHUNKS_IN_POOL = 20; static constexpr uint64_t CHUNK_SIZE = 256; diff --git a/iceoryx_binding_c/test/moduletests/test_server.cpp b/iceoryx_binding_c/test/moduletests/test_server.cpp index 7b6f9ca793..642847c076 100644 --- a/iceoryx_binding_c/test/moduletests/test_server.cpp +++ b/iceoryx_binding_c/test/moduletests/test_server.cpp @@ -104,7 +104,7 @@ class iox_server_test : public Test char managementMemory[MANAGEMENT_MEMORY_SIZE]; iox::BumpAllocator mgmtAllocator{managementMemory, MANAGEMENT_MEMORY_SIZE}; static constexpr uint64_t DATA_MEMORY_SIZE = 1024 * 1024; - char dataMemory[DATA_MEMORY_SIZE]; + alignas(8) char dataMemory[DATA_MEMORY_SIZE]; iox::BumpAllocator dataAllocator{dataMemory, DATA_MEMORY_SIZE}; iox::mepoo::MemoryManager memoryManager; iox::mepoo::MePooConfig memoryConfig; diff --git a/iceoryx_binding_c/test/moduletests/test_subscriber.cpp b/iceoryx_binding_c/test/moduletests/test_subscriber.cpp index b75647ed91..9e7823b708 100644 --- a/iceoryx_binding_c/test/moduletests/test_subscriber.cpp +++ b/iceoryx_binding_c/test/moduletests/test_subscriber.cpp @@ -25,6 +25,7 @@ #include "iceoryx_posh/internal/popo/ports/subscriber_port_user.hpp" #include "iceoryx_posh/mepoo/mepoo_config.hpp" #include "iox/detail/hoofs_error_reporting.hpp" +#include "iox/detail/system_configuration.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" #include "iceoryx_posh/roudi_env/minimal_iceoryx_config.hpp" @@ -98,8 +99,8 @@ class iox_sub_test : public Test } static iox_sub_t m_triggerCallbackLatestArgument; - static constexpr size_t MEMORY_SIZE = 1024 * 1024 * 100; - uint8_t m_memory[MEMORY_SIZE]; + static constexpr size_t MEMORY_SIZE = 1024 * 1024; + alignas(8) uint8_t m_memory[MEMORY_SIZE]; static constexpr uint32_t NUM_CHUNKS_IN_POOL = MAX_CHUNKS_HELD_PER_SUBSCRIBER_SIMULTANEOUSLY + 2U; static constexpr uint64_t CHUNK_SIZE = 128U; @@ -145,6 +146,12 @@ TEST_F(iox_sub_test, initSubscriberWithNotInitializedSubscriberOptionsTerminates TEST_F(iox_sub_test, initSubscriberWithDefaultOptionsWorks) { ::testing::Test::RecordProperty("TEST_ID", "40eaa006-4781-46cd-bde3-40fa7d572f29"); + + if (iox::detail::isCompiledOn32BitSystem()) + { + GTEST_SKIP() << "@todo iox-#2301 This test does not work on 32 bit builds due to the usage of RouDiEnv"; + } + RouDiEnv roudiEnv; iox_runtime_init("hypnotoad"); @@ -402,6 +409,12 @@ TEST_F(iox_sub_test, hasDataTriggersWaitSetWithCorrectCallback) TEST_F(iox_sub_test, deinitSubscriberDetachesTriggerFromWaitSet) { ::testing::Test::RecordProperty("TEST_ID", "93e350fb-5430-43ff-982b-b43c6ae9b890"); + + if (iox::detail::isCompiledOn32BitSystem()) + { + GTEST_SKIP() << "@todo iox-#2301 This test does not work on 32 bit builds due to the usage of RouDiEnv"; + } + RouDiEnv roudiEnv; iox_runtime_init("hypnotoad"); diff --git a/iceoryx_hoofs/test/moduletests/test_time_unit_duration.cpp b/iceoryx_hoofs/test/moduletests/test_time_unit_duration.cpp index 5cf61a5026..8c5f842d2b 100644 --- a/iceoryx_hoofs/test/moduletests/test_time_unit_duration.cpp +++ b/iceoryx_hoofs/test/moduletests/test_time_unit_duration.cpp @@ -1050,7 +1050,7 @@ TEST(Duration_test, ConvertTimespecWithNoneReferenceFromDurationMoreThanOneSecon TEST(Duration_test, ConvertTimespecWithNoneReferenceFromDurationResultsNotYetInSaturation) { ::testing::Test::RecordProperty("TEST_ID", "70f11b99-78ec-442a-aefe-4dd9152b7903"); - constexpr int64_t SECONDS{std::numeric_limits::max()}; + constexpr int64_t SECONDS{std::numeric_limits::max()}; constexpr int64_t NANOSECONDS{NANOSECS_PER_SECOND - 1U}; auto duration = createDuration(SECONDS, NANOSECONDS); @@ -1064,7 +1064,7 @@ TEST(Duration_test, ConvertTimespecWithNoneReferenceFromDurationResultsNotYetInS TEST(Duration_test, ConvertTimespecWithNoneReferenceFromMaxDurationResultsInSaturation) { ::testing::Test::RecordProperty("TEST_ID", "3bf4bb34-46f3-4889-84f5-9220b32fff73"); - constexpr int64_t SECONDS{std::numeric_limits::max()}; + constexpr int64_t SECONDS{std::numeric_limits::max()}; constexpr int64_t NANOSECONDS{NANOSECS_PER_SECOND - 1U}; const timespec sut = DurationAccessor::max().timespec(iox::units::TimeSpecReference::None); @@ -1101,7 +1101,7 @@ TEST(Duration_test, ConvertTimespecWithMonotonicReference) TEST(Duration_test, ConvertTimespecWithMonotonicReferenceFromMaxDurationResultsInSaturation) { ::testing::Test::RecordProperty("TEST_ID", "ff5a1fe2-65c8-490a-b31d-4d8ea615c91a"); - constexpr int64_t SECONDS{std::numeric_limits::max()}; + constexpr int64_t SECONDS{std::numeric_limits::max()}; constexpr int64_t NANOSECONDS{NANOSECS_PER_SECOND - 1U}; const timespec sut = DurationAccessor::max().timespec(iox::units::TimeSpecReference::Monotonic); @@ -1129,7 +1129,7 @@ TEST(Duration_test, ConvertTimespecWithEpochReference) TEST(Duration_test, ConvertTimespecWithEpochReferenceFromMaxDurationResultsInSaturation) { ::testing::Test::RecordProperty("TEST_ID", "97ff4204-a7f7-43ef-b81e-0e359d1dce93"); - constexpr int64_t SECONDS{std::numeric_limits::max()}; + constexpr int64_t SECONDS{std::numeric_limits::max()}; constexpr int64_t NANOSECONDS{NANOSECS_PER_SECOND - 1U}; const timespec sut = DurationAccessor::max().timespec(iox::units::TimeSpecReference::Epoch); diff --git a/iceoryx_hoofs/testing/CMakeLists.txt b/iceoryx_hoofs/testing/CMakeLists.txt index fffa71d365..202ec59977 100644 --- a/iceoryx_hoofs/testing/CMakeLists.txt +++ b/iceoryx_hoofs/testing/CMakeLists.txt @@ -38,6 +38,9 @@ iox_add_library( error_reporting/testing_support.cpp ) +# deactivate _FORTIFY_SOURCE since it causes issues with longjmp in the testing logger and error handler +target_compile_options(iceoryx_hoofs_testing PRIVATE -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0) + if(TEST_WITH_ADDITIONAL_USER) target_compile_definitions(iceoryx_hoofs_testing PUBLIC -DTEST_WITH_ADDITIONAL_USER) endif(TEST_WITH_ADDITIONAL_USER) diff --git a/iceoryx_posh/test/integrationtests/test_posh_experimental_node.cpp b/iceoryx_posh/test/integrationtests/test_posh_experimental_node.cpp index 3db5b4d0b2..df4fad3873 100644 --- a/iceoryx_posh/test/integrationtests/test_posh_experimental_node.cpp +++ b/iceoryx_posh/test/integrationtests/test_posh_experimental_node.cpp @@ -18,6 +18,7 @@ #include "iceoryx_platform/stdlib.hpp" #include "iox/deadline_timer.hpp" +#include "iox/detail/system_configuration.hpp" #include "iox/duration.hpp" #include "iox/vector.hpp" @@ -256,6 +257,12 @@ TEST(Node_test, ExhaustingNodesLeadsToError) "number of file descriptors is not increased with 'ulimit -n 2000'!"; } + if (iox::detail::isCompiledOn32BitSystem()) + { + GTEST_SKIP() << "@todo iox-#2301 This test fails on 32 bit builds on the CI after ~240 created Nodes. " + "Potentially some issues with the amount of file descriptors."; + } + RouDiEnv roudi; iox::vector nodes; diff --git a/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp b/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp index 53749a4469..80b1cd207f 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_mempool.cpp @@ -20,6 +20,7 @@ #include "iceoryx_posh/internal/posh_error_reporting.hpp" #include "iox/bump_allocator.hpp" #include "iox/detail/hoofs_error_reporting.hpp" +#include "iox/detail/system_configuration.hpp" #include "iceoryx_hoofs/testing/fatal_failure.hpp" #include "test.hpp" @@ -46,9 +47,6 @@ class MemPool_test : public Test { } - void SetUp(){}; - void TearDown(){}; - alignas(MemPool::CHUNK_MEMORY_ALIGNMENT) uint8_t m_rawMemory[NUMBER_OF_CHUNKS * CHUNK_SIZE + LOFFLI_MEMORY_REQUIREMENT]; iox::BumpAllocator allocator; @@ -138,14 +136,23 @@ TEST_F(MemPool_test, MempoolPointeToIndexConversionForMemoryOffsetsLargerThan4GB constexpr uint64_t GB{1ULL << 30}; constexpr uint64_t CHUNK_SIZE{128 * MB}; constexpr uint64_t RAW_MEMORY_BASE{0x7f60d90c5000ULL}; - uint8_t* const RAW_MEMORY_PTR{reinterpret_cast(RAW_MEMORY_BASE)}; - constexpr uint32_t EXPECTED_INDEX{42}; - uint8_t* const CHUNK_PTR{RAW_MEMORY_PTR + static_cast(EXPECTED_INDEX) * CHUNK_SIZE}; - const auto index = MemPool::pointerToIndex(CHUNK_PTR, CHUNK_SIZE, RAW_MEMORY_PTR); + if constexpr (iox::detail::isCompiledOn32BitSystem()) + { + GTEST_SKIP() << "This test does not work on 32 bit builds since it requires pointer larger than the 32 bit " + "address space"; + } + else + { + uint8_t* const RAW_MEMORY_PTR{reinterpret_cast(RAW_MEMORY_BASE)}; + constexpr uint32_t EXPECTED_INDEX{42}; + uint8_t* const CHUNK_PTR{RAW_MEMORY_PTR + static_cast(EXPECTED_INDEX) * CHUNK_SIZE}; - EXPECT_THAT(index, Eq(EXPECTED_INDEX)); - EXPECT_THAT(reinterpret_cast(CHUNK_PTR) - RAW_MEMORY_BASE, Gt(5 * GB)); + const auto index = MemPool::pointerToIndex(CHUNK_PTR, CHUNK_SIZE, RAW_MEMORY_PTR); + + EXPECT_THAT(index, Eq(EXPECTED_INDEX)); + EXPECT_THAT(reinterpret_cast(CHUNK_PTR) - RAW_MEMORY_BASE, Gt(5 * GB)); + } } TEST_F(MemPool_test, MempoolCtorInitialisesTheObjectWithValuesPassedToTheCtor) diff --git a/iceoryx_posh/test/moduletests/test_mepoo_segment.cpp b/iceoryx_posh/test/moduletests/test_mepoo_segment.cpp index 12406772fb..03e87ff121 100644 --- a/iceoryx_posh/test/moduletests/test_mepoo_segment.cpp +++ b/iceoryx_posh/test/moduletests/test_mepoo_segment.cpp @@ -90,7 +90,7 @@ class MePooSegment_test : public Test uint64_t m_memorySizeInBytes{0}; void* m_baseAddressHint{nullptr}; static constexpr int MEM_SIZE = 100000; - char memory[MEM_SIZE]; + alignas(8) char memory[MEM_SIZE]; shm_handle_t filehandle; static createFct createVerificator; }; From 72a8dfd9de356bd6b04b7eda0f65da58467b29a2 Mon Sep 17 00:00:00 2001 From: Mathias Kraus Date: Fri, 23 Aug 2024 05:25:21 +0200 Subject: [PATCH 10/10] iox-#2301 Clear caches log entries from testing logger once the cache is printed to the terminal --- iceoryx_hoofs/testing/testing_logger.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/iceoryx_hoofs/testing/testing_logger.cpp b/iceoryx_hoofs/testing/testing_logger.cpp index 9803e1a74d..73f1589193 100644 --- a/iceoryx_hoofs/testing/testing_logger.cpp +++ b/iceoryx_hoofs/testing/testing_logger.cpp @@ -83,6 +83,7 @@ void TestingLogger::printLogBuffer() noexcept puts(log.c_str()); } puts("#### Log end ####"); + loggerData->buffer.clear(); } uint64_t TestingLogger::getNumberOfLogMessages() noexcept