diff --git a/quality/static_analysis/coding-standards.yaml b/quality/static_analysis/coding-standards.yaml index 58fe148688..d12c0a9991 100644 --- a/quality/static_analysis/coding-standards.yaml +++ b/quality/static_analysis/coding-standards.yaml @@ -24,6 +24,46 @@ deviations: code-identifier: "shared-memory-align-const-cast" scope: "Applies only to the specific const_cast marked with this code identifier in score/memory/shared/shared_memory_resource.cpp. This code-identifier must not be used anywhere else in the codebase." justification: "`do_allocation_algorithm` uses `std::align`, whose `void*&` out-parameter cannot bind to the `const void*` input pointer. `std::align` only reads and arithmetically adjusts the pointer value to compute an aligned address within the given buffer; it never writes through the pointer to modify the pointee (https://timsong-cpp.github.io/cppwp/n4659/ptr.align#lib:align). The const qualification of `alloc_start` is therefore not violated at runtime, and the `const_cast` is required purely to satisfy `std::align`'s non-const parameter type." + - rule-id: "RULE-15-1-3" + query-id: "cpp/misra/non-explicit-conversion-member" + code-identifier: "offset-ptr-implicit-pointer-constructor" + scope: "Applies only to the single-argument `pointer`-taking constructor of `OffsetPtr` marked with this code identifier in score/memory/shared/offset_ptr.h. This code-identifier must not be used anywhere else in the codebase." + justification: "OffsetPtr is a drop-in replacement for a raw pointer in shared memory, and existing code across the codebase relies on being able to implicitly construct an OffsetPtr from a raw pointer (e.g. via assignment or as a default-initialized member/parameter). Requiring `explicit` here would force every one of these call sites to add redundant, purely mechanical `OffsetPtr{...}` wrapping without preventing any real defect, since a pointer-to-OffsetPtr conversion is exactly the intended, single well-defined semantics of this type." + - rule-id: "RULE-15-1-3" + query-id: "cpp/misra/non-explicit-conversion-member" + code-identifier: "offset-ptr-implicit-converting-constructor" + scope: "Applies only to the templated converting constructor of `OffsetPtr` taking `const OffsetPtr&` marked with this code identifier in score/memory/shared/offset_ptr.h. This code-identifier must not be used anywhere else in the codebase." + justification: "This constructor mirrors the standard-library convention (e.g. `std::shared_ptr`'s converting constructor) allowing an `OffsetPtr` to be implicitly used wherever an `OffsetPtr` is expected, exactly as a raw `Derived*` may be implicitly converted to `Base*`. Marking it `explicit` would break this pointer-like substitutability that OffsetPtr is designed to preserve, without eliminating any ambiguity risk beyond what already exists for ordinary pointer conversions." + - rule-id: "RULE-15-1-3" + query-id: "cpp/misra/non-explicit-conversion-member" + code-identifier: "offset-ptr-implicit-pointer-conversion" + scope: "Applies only to the `operator pointer() const` conversion operator of `OffsetPtr` marked with this code identifier in score/memory/shared/offset_ptr.h. This code-identifier must not be used anywhere else in the codebase." + justification: "OffsetPtr is used as the pointer type of allocator-aware standard containers (e.g. `basic_string`, `vector`) living in shared memory. These containers' implementations perform implicit conversions from the container's pointer type to the underlying raw pointer type in numerous internal code paths that cannot be modified. Making this conversion operator `explicit` would break compatibility with these standard-library container implementations, which is the entire purpose of this conversion operator." + - rule-id: "RULE-15-1-3" + query-id: "cpp/misra/non-explicit-conversion-member" + code-identifier: "polymorphic-offset-ptr-allocator-resource-constructor" + scope: "Applies only to the single-argument `ManagedMemoryResource&`-taking constructor of `PolymorphicOffsetPtrAllocator` marked with this code identifier in score/memory/shared/polymorphic_offset_ptr_allocator.h. This code-identifier must not be used anywhere else in the codebase." + justification: "This constructor exists specifically to allow a `ManagedMemoryResource&` to be implicitly used wherever the C++ Allocator named requirements expect an allocator object (e.g. when constructing an allocator-aware container in-place from a memory resource), mirroring the standard library's own `polymorphic_allocator` convention of implicit construction from a `memory_resource*`. Requiring `explicit` here would break this Allocator-requirements-driven usage pattern that is the entire purpose of the constructor." + - rule-id: "RULE-15-1-3" + query-id: "cpp/misra/non-explicit-conversion-member" + code-identifier: "polymorphic-offset-ptr-allocator-rebind-constructor" + scope: "Applies only to the templated `PolymorphicOffsetPtrAllocator`-taking constructor of `PolymorphicOffsetPtrAllocator` marked with this code identifier in score/memory/shared/polymorphic_offset_ptr_allocator.h. This code-identifier must not be used anywhere else in the codebase." + justification: "This constructor implements the C++ Allocator named requirements' rebind-conversion contract, which requires that an allocator of one value type be implicitly constructible from an allocator of another value type (this is how standard containers rebind their allocator to internal node/element types). This is a copy-like construction, not an unrelated-type conversion, and marking it `explicit` would violate the Allocator named requirements and break rebind support in standard containers, which is the entire purpose of this constructor." + - rule-id: "RULE-15-1-3" + query-id: "cpp/misra/non-explicit-conversion-member" + code-identifier: "copyable-atomic-implicit-conversion" + scope: "Applies only to the `operator T() const noexcept` conversion operator of `CopyableAtomic` marked with this code identifier in score/mw/com/impl/util/copyable_atomic.h. This code-identifier must not be used anywhere else in the codebase." + justification: "CopyableAtomic is a thin wrapper intended to behave exactly like `std::atomic` except for being copyable, and `std::atomic` itself provides an implicit, non-explicit `operator T()` conversion. Marking this wrapper's conversion operator `explicit` would make it behave differently from the type it wraps and break existing code that relies on `std::atomic`-compatible implicit-conversion semantics, which is the entire purpose of this wrapper." + - rule-id: "RULE-15-1-3" + query-id: "cpp/misra/non-explicit-conversion-member" + code-identifier: "sample-ptr-implicit-nullptr-constructor" + scope: "Applies only to the `std::nullptr_t`-taking constructor of `SamplePtr` marked with this code identifier in score/mw/com/impl/plumbing/sample_ptr.h. This code-identifier must not be used anywhere else in the codebase." + justification: "This constructor exists specifically to allow `nullptr` to be used as a default argument value for `SamplePtr` function parameters (e.g. `void TestFunc(SamplePtr ptr = nullptr)`), matching the ergonomics of a raw pointer default argument. Requiring `explicit` would prevent this default-argument idiom and force every such call site to spell out `SamplePtr{nullptr}`, without preventing any real defect, since `nullptr` unambiguously identifies the empty/null state of this type." + - rule-id: "RULE-15-1-3" + query-id: "cpp/misra/non-explicit-conversion-member" + code-identifier: "lambda-closure-function-pointer-conversion" + scope: "Applies only to the compiler-generated conversion operator of non-capturing lambda closure types, as they appear when such a lambda is assigned to, or returned as, a function pointer / function reference (e.g. `score::cpp::overload(...)` visitor patterns and factory functions that build and return callback function pointers from lambda literals) throughout the codebase." + justification: "Per the C++ standard ([expr.prim.lambda.closure]), a non-capturing lambda's closure type has an implicitly-declared, non-explicit conversion function to a pointer (or reference) to function with a matching signature. This conversion function is entirely compiler-generated: there is no source location associated with it where a user could write the `explicit` specifier, since the lambda expression itself declares no conversion operator at all. It is therefore structurally impossible to satisfy this rule for these findings without changing the language feature being used (i.e. rewriting a lambda literal as a free function or explicit functor class purely to silence the tool), which would be a purely cosmetic change with no functional or safety benefit." guideline-recategorizations: - rule-id: "RULE-0-1-1" category: "disapplied" diff --git a/score/memory/shared/new_delete_delegate_resource.cpp b/score/memory/shared/new_delete_delegate_resource.cpp index cd0069c808..abac885a59 100644 --- a/score/memory/shared/new_delete_delegate_resource.cpp +++ b/score/memory/shared/new_delete_delegate_resource.cpp @@ -155,6 +155,7 @@ void* NewDeleteDelegateMemoryResource::do_allocate(const std::size_t bytes, std: // result in a memory buffer large enough to align start_remaining_allocatable_memory in the worst case. If the // pointer is worst-case aligned, then it would require (alignment - 1) bytes of padding. auto max_required_padding_result = + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) safe_math::Add(bytes, alignment).and_then([](const auto max_required_padding) noexcept { return safe_math::Subtract(max_required_padding, 1U); }); diff --git a/score/memory/shared/offset_ptr.h b/score/memory/shared/offset_ptr.h index cd30d87a1e..299abb9e8b 100644 --- a/score/memory/shared/offset_ptr.h +++ b/score/memory/shared/offset_ptr.h @@ -160,6 +160,7 @@ class OffsetPtr // Rationale : Non-explicit constructor is needed for implicit conversion // NOLINTBEGIN(google-explicit-constructor): needed implicit conversion // coverity[autosar_cpp14_a12_1_4_violation] + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(offset-ptr-implicit-pointer-constructor) OffsetPtr(pointer ptr = nullptr) noexcept; // NOLINTEND(google-explicit-constructor): see above @@ -173,6 +174,7 @@ class OffsetPtr // NOLINTBEGIN(google-explicit-constructor): needed implicit conversion // coverity[autosar_cpp14_a12_1_4_violation] template + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(offset-ptr-implicit-converting-constructor) OffsetPtr(const OffsetPtr& other); // NOLINTEND(google-explicit-constructor): see above @@ -243,6 +245,7 @@ class OffsetPtr // Rationale: Using an offset pointer in a basic_string requires this conversion operator to be implicit. // NOLINTBEGIN(google-explicit-constructor): requires conversion operator to be implicit // coverity[autosar_cpp14_a13_5_2_violation] + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(offset-ptr-implicit-pointer-conversion) operator pointer() const { // NOLINTNEXTLINE(score-banned-function) See justification above class. @@ -395,6 +398,7 @@ template // identical between in-class declaration and definition. // coverity[autosar_cpp14_m8_4_2_violation : FALSE] // coverity[autosar_cpp14_m3_9_1_violation : FALSE] +// Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(offset-ptr-implicit-pointer-constructor) OffsetPtr::OffsetPtr(pointer ptr) noexcept : offset_{CalculateOffsetFromPointer(this, ptr)}, memory_bounds_{} { @@ -416,6 +420,7 @@ OffsetPtr::OffsetPtr(const OffsetPtr& other) : offset_ template template +// Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(offset-ptr-implicit-converting-constructor) OffsetPtr::OffsetPtr(const OffsetPtr& other) : offset_{}, memory_bounds_{} { std::tie(offset_, memory_bounds_) = CopyFrom(other, *this); diff --git a/score/memory/shared/polymorphic_offset_ptr_allocator.h b/score/memory/shared/polymorphic_offset_ptr_allocator.h index 9b2fb8ee7e..e8b3c55f20 100644 --- a/score/memory/shared/polymorphic_offset_ptr_allocator.h +++ b/score/memory/shared/polymorphic_offset_ptr_allocator.h @@ -44,6 +44,7 @@ class PolymorphicOffsetPtrAllocator // Non-explicit constructor is good enough for maintaining required implicit conversion // NOLINTNEXTLINE(google-explicit-constructor): Tolerated, discard explicit. + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(polymorphic-offset-ptr-allocator-resource-constructor) PolymorphicOffsetPtrAllocator(ManagedMemoryResource& resource) noexcept : proxy_{resource.getMemoryResourceProxy()} { } @@ -52,6 +53,7 @@ class PolymorphicOffsetPtrAllocator // Non-explicit constructor is good enough for maintaining required implicit conversion. // In addition semantically is a copy constructor. // NOLINTNEXTLINE(google-explicit-constructor): Tolerated, discard explicit. + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(polymorphic-offset-ptr-allocator-rebind-constructor) PolymorphicOffsetPtrAllocator(const PolymorphicOffsetPtrAllocator& rhs) : proxy_(rhs.getMemoryResourceProxy()) { } diff --git a/score/message_passing/log/logging_callback.cpp b/score/message_passing/log/logging_callback.cpp index 53faec5658..57afb0de88 100644 --- a/score/message_passing/log/logging_callback.cpp +++ b/score/message_passing/log/logging_callback.cpp @@ -59,6 +59,7 @@ class FixedBufferStreamBuf final : public std::streambuf LoggingCallback GetCerrLogger() { + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) return [](LogSeverity /*severity*/, LogItems items) -> void { std::array buffer{}; FixedBufferStreamBuf stream_buffer{buffer.data(), buffer.size()}; diff --git a/score/message_passing/unix_domain/unix_domain_engine.cpp b/score/message_passing/unix_domain/unix_domain_engine.cpp index 21c52dd3d8..4a4340fd09 100644 --- a/score/message_passing/unix_domain/unix_domain_engine.cpp +++ b/score/message_passing/unix_domain/unix_domain_engine.cpp @@ -110,6 +110,7 @@ void UnixDomainEngine::RegisterPosixEndpoint(PosixEndpointEntry& endpoint) noexc // TODO: not used/not supported yet events |= POLLOUT; } + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) const auto found = std::find_if(poll_fds_.begin(), poll_fds_.end(), [](pollfd& poll) noexcept { return poll.fd < 0; }); diff --git a/score/message_passing/unix_domain/unix_domain_engine.h b/score/message_passing/unix_domain/unix_domain_engine.h index 895a210cd2..d9f79dca8e 100644 --- a/score/message_passing/unix_domain/unix_domain_engine.h +++ b/score/message_passing/unix_domain/unix_domain_engine.h @@ -53,8 +53,8 @@ class UnixDomainEngine final : public ISharedResourceEngine score::cpp::pmr::unique_ptr unistd{}; }; - UnixDomainEngine(score::cpp::pmr::memory_resource* memory_resource, - LoggingCallback logger = GetCerrLogger()) noexcept; + explicit UnixDomainEngine(score::cpp::pmr::memory_resource* memory_resource, + LoggingCallback logger = GetCerrLogger()) noexcept; ~UnixDomainEngine() noexcept override; UnixDomainEngine(const UnixDomainEngine&) = delete; diff --git a/score/mw/com/impl/bindings/lola/consumer_event_data_control_local_view.h b/score/mw/com/impl/bindings/lola/consumer_event_data_control_local_view.h index 8fd536ee8a..4ad6d3632f 100644 --- a/score/mw/com/impl/bindings/lola/consumer_event_data_control_local_view.h +++ b/score/mw/com/impl/bindings/lola/consumer_event_data_control_local_view.h @@ -54,7 +54,7 @@ class ConsumerEventDataControlLocalView final public: using LocalEventControlSlots = score::cpp::span; - ConsumerEventDataControlLocalView(EventDataControl& event_data_control_shared); + explicit ConsumerEventDataControlLocalView(EventDataControl& event_data_control_shared); /// Test-only constructor which allows to directly set the TransactionLogLocalView. This avoids having to /// inject the TransactionLogLocalView via the production code path which would require creating a diff --git a/score/mw/com/impl/bindings/lola/consumer_event_data_control_local_view_test.cpp b/score/mw/com/impl/bindings/lola/consumer_event_data_control_local_view_test.cpp index 90992e6bb3..39d98475a8 100644 --- a/score/mw/com/impl/bindings/lola/consumer_event_data_control_local_view_test.cpp +++ b/score/mw/com/impl/bindings/lola/consumer_event_data_control_local_view_test.cpp @@ -95,7 +95,7 @@ class ConsumerEventDataControlLocalViewFixture : public ::testing::Test { auto& transaction_log = transaction_log_.emplace(max_slots, memory_); event_data_control_ = std::make_unique(max_slots, memory_); - unit_ = std::make_unique>(*event_data_control_, transaction_log); + unit_ = std::make_unique>(*event_data_control_, TransactionLogLocalView{transaction_log}); provider_event_data_control_local_ = std::make_unique>(*event_data_control_); return *this; @@ -111,9 +111,8 @@ class ConsumerEventDataControlLocalViewFixture : public ::testing::Test atomic_indirector_mock_guard_ = std::make_unique>(*atomic_mock_); - unit_with_mock_atomics_ = - std::make_unique>(*event_data_control_, - transaction_log); + unit_with_mock_atomics_ = std::make_unique>( + *event_data_control_, TransactionLogLocalView{transaction_log}); provider_event_data_control_local_ = std::make_unique>(*event_data_control_); @@ -419,7 +418,7 @@ TEST_P(MultiSenderMultiReceiverTest, MultiSenderMultiReceiver) // In the real code, each ProxyEvent has its own ConsumerEventDataControlLocalView and TransactionLog. So we // replicate that here by creating one of each per receiver thread. TransactionLog transaction_log{GetParam().num_slots, memory_}; - ConsumerEventDataControlLocalView<> consumer_event_data_control_local{event_data_control_, transaction_log}; + ConsumerEventDataControlLocalView<> consumer_event_data_control_local{event_data_control_, TransactionLogLocalView{transaction_log}}; std::vector used_slots{}; EventSlotStatus::EventTimeStamp start_ts{1}; @@ -499,7 +498,7 @@ TEST_P(MultiSenderMultiReceiverTest, DISABLED_MultiSenderMultiReceiverMaxReceive // In the real code, each ProxyEvent has its own ConsumerEventDataControlLocalView and TransactionLog. So we // replicate that here by creating one of each per receiver thread. TransactionLog transaction_log{GetParam().num_slots, memory_}; - ConsumerEventDataControlLocalView<> consumer_event_data_control_local{event_data_control_, transaction_log}; + ConsumerEventDataControlLocalView<> consumer_event_data_control_local{event_data_control_, TransactionLogLocalView{transaction_log}}; std::vector used_slots{}; EventSlotStatus::EventTimeStamp start_ts{0}; diff --git a/score/mw/com/impl/bindings/lola/event_data_control_composite_test.cpp b/score/mw/com/impl/bindings/lola/event_data_control_composite_test.cpp index 69cb99ef07..9399d99392 100644 --- a/score/mw/com/impl/bindings/lola/event_data_control_composite_test.cpp +++ b/score/mw/com/impl/bindings/lola/event_data_control_composite_test.cpp @@ -100,8 +100,8 @@ class EventDataControlCompositeFixture : public ::testing::Test auto& transaction_log_qm = transaction_log_qm_.emplace(kSlotCount, memory_); auto& transaction_log_asil = transaction_log_asil_.emplace(kSlotCount, memory_); - proxy_qm_local_.emplace(*qm_, transaction_log_qm); - proxy_asil_local_.emplace(*asil_, transaction_log_asil); + proxy_qm_local_.emplace(*qm_, TransactionLogLocalView{transaction_log_qm}); + proxy_asil_local_.emplace(*asil_, TransactionLogLocalView{transaction_log_asil}); unit_ = std::make_unique>(skeleton_qm_local_.value(), &skeleton_asil_local_.value()); @@ -134,7 +134,7 @@ class EventDataControlCompositeFixture : public ::testing::Test skeleton_qm_local_.emplace(*qm_); auto& transaction_log_qm = transaction_log_qm_.emplace(kSlotCount, memory_); - proxy_qm_local_.emplace(*qm_, transaction_log_qm); + proxy_qm_local_.emplace(*qm_, TransactionLogLocalView{transaction_log_qm}); unit_ = std::make_unique>(skeleton_qm_local_.value(), nullptr); @@ -702,8 +702,8 @@ TEST(EventDataControlCompositeTest, DISABLED_fuzz) auto receiver = [&last_send_time_stamp, &qm, &asil, &memory]() { TransactionLog transaction_log_qm{MAX_SLOTS, memory}; TransactionLog transaction_log_asil{MAX_SLOTS, memory}; - ConsumerEventDataControlLocalView proxy_asil_local{asil, transaction_log_asil}; - ConsumerEventDataControlLocalView proxy_qm_local{qm, transaction_log_qm}; + ConsumerEventDataControlLocalView proxy_asil_local{asil, TransactionLogLocalView{transaction_log_asil}}; + ConsumerEventDataControlLocalView proxy_qm_local{qm, TransactionLogLocalView{transaction_log_qm}}; std::set used_slots_qm{}; std::set used_slots_asil{}; diff --git a/score/mw/com/impl/bindings/lola/messaging/message_passing_service_instance.cpp b/score/mw/com/impl/bindings/lola/messaging/message_passing_service_instance.cpp index b5d2a7410b..57ebba6187 100644 --- a/score/mw/com/impl/bindings/lola/messaging/message_passing_service_instance.cpp +++ b/score/mw/com/impl/bindings/lola/messaging/message_passing_service_instance.cpp @@ -240,10 +240,12 @@ MessagePassingServiceInstance::MessagePassingServiceInstance( score::message_passing::IServerFactory::ServerConfig server_config{}; server_ = server_factory.Create(protocol_config, server_config); + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) auto connect_callback = [](score::message_passing::IServerConnection& connection) noexcept -> std::uintptr_t { const pid_t client_pid = connection.GetClientIdentity().pid; return static_cast(client_pid); }; + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) auto disconnect_callback = [](score::message_passing::IServerConnection& /*connection*/) noexcept { // TODO: outdated node id? // TODO: update related unit test as well @@ -1162,6 +1164,7 @@ void MessagePassingServiceInstance::UnregisterEventNotification( bool notify_status_change = false; std::unique_lock write_lock(event_update_handlers_mutex_); + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) auto search = event_update_handlers_.find(event_id); if (search != event_update_handlers_.end()) { diff --git a/score/mw/com/impl/bindings/lola/messaging/mw_log_logger.cpp b/score/mw/com/impl/bindings/lola/messaging/mw_log_logger.cpp index 6738a364ba..234bc66661 100644 --- a/score/mw/com/impl/bindings/lola/messaging/mw_log_logger.cpp +++ b/score/mw/com/impl/bindings/lola/messaging/mw_log_logger.cpp @@ -22,6 +22,7 @@ namespace score::mw::com::impl::lola score::message_passing::LoggingCallback GetMwLogLogger() { + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) return [](score::message_passing::LogSeverity severity, score::message_passing::LogItems items) -> void { using LogStreamFactoryPtr = score::mw::log::LogStream (*)(std::string_view) noexcept; constexpr auto kLogLevels = score::cpp::to_underlying(score::message_passing::LogSeverity::kVerbose) + 1U; diff --git a/score/mw/com/impl/bindings/lola/provider_event_data_control_local_view.h b/score/mw/com/impl/bindings/lola/provider_event_data_control_local_view.h index 8c807682fb..acf48a6950 100644 --- a/score/mw/com/impl/bindings/lola/provider_event_data_control_local_view.h +++ b/score/mw/com/impl/bindings/lola/provider_event_data_control_local_view.h @@ -59,7 +59,7 @@ class ProviderEventDataControlLocalView final using LocalEventControlSlots = score::cpp::span; - ProviderEventDataControlLocalView(EventDataControl& event_data_control); + explicit ProviderEventDataControlLocalView(EventDataControl& event_data_control); ~ProviderEventDataControlLocalView() noexcept = default; diff --git a/score/mw/com/impl/bindings/lola/sample_ptr_test.cpp b/score/mw/com/impl/bindings/lola/sample_ptr_test.cpp index da9fe1d3f4..182b0d6e35 100644 --- a/score/mw/com/impl/bindings/lola/sample_ptr_test.cpp +++ b/score/mw/com/impl/bindings/lola/sample_ptr_test.cpp @@ -41,7 +41,7 @@ class SamplePtrTest : public ::testing::Test FakeMemoryResource memory_{}; EventDataControl event_data_control_{kMaxSlots, memory_}; TransactionLog transaction_log_{kMaxSlots, memory_}; - ConsumerEventDataControlLocalView<> consumer_event_data_control_local_{event_data_control_, transaction_log_}; + ConsumerEventDataControlLocalView<> consumer_event_data_control_local_{event_data_control_, TransactionLogLocalView{transaction_log_}}; ProviderEventDataControlLocalView<> provider_event_data_control_local_{event_data_control_}; SlotIndexType AllocateSlot(EventSlotStatus::EventTimeStamp timestamp = 1) diff --git a/score/mw/com/impl/bindings/lola/skeleton.cpp b/score/mw/com/impl/bindings/lola/skeleton.cpp index eefd614b20..c4a61df05a 100644 --- a/score/mw/com/impl/bindings/lola/skeleton.cpp +++ b/score/mw/com/impl/bindings/lola/skeleton.cpp @@ -566,6 +566,7 @@ void Skeleton::RegisterMethod(const UniqueMethodIdentifier method_id, SkeletonMe bool Skeleton::VerifyAllMethodHandlersRegistered() const { + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) return std::all_of(skeleton_methods_.begin(), skeleton_methods_.end(), [](const auto& method_pair) { return method_pair.second.get().IsRegistered(); }); diff --git a/score/mw/com/impl/bindings/lola/skeleton_memory_manager.cpp b/score/mw/com/impl/bindings/lola/skeleton_memory_manager.cpp index ef77cb61e5..835ebb671b 100644 --- a/score/mw/com/impl/bindings/lola/skeleton_memory_manager.cpp +++ b/score/mw/com/impl/bindings/lola/skeleton_memory_manager.cpp @@ -342,6 +342,7 @@ void SkeletonMemoryManager::RollbackSkeletonTracingTransactions(EventControl& ev void SkeletonMemoryManager::RemoveSharedMemory() { + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) constexpr auto RemoveMemoryIfExists = [](const std::optional& path) -> void { if (path.has_value()) { diff --git a/score/mw/com/impl/bindings/lola/skeleton_test.cpp b/score/mw/com/impl/bindings/lola/skeleton_test.cpp index 303fba0389..b865cf5ddd 100644 --- a/score/mw/com/impl/bindings/lola/skeleton_test.cpp +++ b/score/mw/com/impl/bindings/lola/skeleton_test.cpp @@ -1007,12 +1007,12 @@ TEST_P(SkeletonRegisterParamaterisedFixture, RegisterWillOpenEventDataIfShmRegio auto& existing_event_data_storage = GetEventStorageFromServiceDataStorage( test::kDummyElementFqId, existing_service_data_storage_); - ProviderEventDataControlLocalView<> opened_event_control_local_qm = - registration_result.event_control_qm.data_control; + ProviderEventDataControlLocalView<> opened_event_control_local_qm{ + registration_result.event_control_qm.data_control}; ASSERT_TRUE(registration_result.event_control_asil_b != nullptr); - ProviderEventDataControlLocalView<> opened_event_control_local_asil_b = - registration_result.event_control_asil_b->data_control; + ProviderEventDataControlLocalView<> opened_event_control_local_asil_b{ + registration_result.event_control_asil_b->data_control}; EXPECT_EQ(existing_event_control_qm.data_control.state_slots_[0], 0U); EXPECT_EQ(existing_event_control_asil_b.data_control.state_slots_[0], 0U); diff --git a/score/mw/com/impl/bindings/lola/slot_collector_test.cpp b/score/mw/com/impl/bindings/lola/slot_collector_test.cpp index 788f499f9f..809ff6cc89 100644 --- a/score/mw/com/impl/bindings/lola/slot_collector_test.cpp +++ b/score/mw/com/impl/bindings/lola/slot_collector_test.cpp @@ -46,7 +46,7 @@ class SlotCollectorWithFakeMem : public ::testing::Test FakeMemoryResource fake_memory_resource_; EventDataControl event_data_control_{kMaxSlots, fake_memory_resource_}; TransactionLog transaction_log_{kMaxSlots, fake_memory_resource_}; - ConsumerEventDataControlLocalView<> consumer_event_data_control_local_{event_data_control_, transaction_log_}; + ConsumerEventDataControlLocalView<> consumer_event_data_control_local_{event_data_control_, TransactionLogLocalView{transaction_log_}}; ProviderEventDataControlLocalView<> provider_event_data_control_local_{event_data_control_}; }; diff --git a/score/mw/com/impl/bindings/lola/slot_decrementer_test.cpp b/score/mw/com/impl/bindings/lola/slot_decrementer_test.cpp index 2178f4c746..90dce380a5 100644 --- a/score/mw/com/impl/bindings/lola/slot_decrementer_test.cpp +++ b/score/mw/com/impl/bindings/lola/slot_decrementer_test.cpp @@ -69,7 +69,7 @@ class SlotDecrementerFixture : public ::testing::Test FakeMemoryResource memory_{}; EventDataControl event_data_control_{kMaxSlots, memory_}; TransactionLog transaction_log_{kMaxSlots, memory_}; - ConsumerEventDataControlLocalView<> consumer_event_data_control_local_{event_data_control_, transaction_log_}; + ConsumerEventDataControlLocalView<> consumer_event_data_control_local_{event_data_control_, TransactionLogLocalView{transaction_log_}}; ProviderEventDataControlLocalView<> provider_event_data_control_local_{event_data_control_}; std::optional event_slot_index_{}; diff --git a/score/mw/com/impl/bindings/lola/test/transaction_log_test_resources.cpp b/score/mw/com/impl/bindings/lola/test/transaction_log_test_resources.cpp index f4fffeef6d..73ce3f9400 100644 --- a/score/mw/com/impl/bindings/lola/test/transaction_log_test_resources.cpp +++ b/score/mw/com/impl/bindings/lola/test/transaction_log_test_resources.cpp @@ -60,7 +60,7 @@ void InsertProxyTransactionLogWithValidTransactions( transaction_log_set.RegisterProxyElement(transaction_log_id, consumer_event_data_control_local).value(); const auto transaction_log_index = transaction_registration_guard.GetTransactionLogIndex(); - TransactionLogLocalView transaction_log_local_view = transaction_log_set.GetTransactionLog(transaction_log_index); + TransactionLogLocalView transaction_log_local_view{transaction_log_set.GetTransactionLog(transaction_log_index)}; transaction_log_local_view.SubscribeTransactionBegin(subscription_max_sample_count); transaction_log_local_view.SubscribeTransactionCommit(); @@ -84,7 +84,7 @@ void InsertSkeletonTransactionLogWithValidTransactions( transaction_log_set.RegisterSkeletonTransactionLog(consumer_event_data_control_local); const auto transaction_log_index = transaction_registration_guard.GetTransactionLogIndex(); - TransactionLogLocalView transaction_log_local_view = transaction_log_set.GetTransactionLog(transaction_log_index); + TransactionLogLocalView transaction_log_local_view{transaction_log_set.GetTransactionLog(transaction_log_index)}; constexpr std::size_t slot_index{0U}; transaction_log_local_view.ReferenceTransactionBegin(slot_index); @@ -114,7 +114,7 @@ void InsertProxyTransactionLogWithInvalidTransactions( transaction_log_set.RegisterProxyElement(transaction_log_id, consumer_event_data_control_local).value(); const auto transaction_log_index = transaction_registration_guard.GetTransactionLogIndex(); - TransactionLogLocalView transaction_log_local_view = transaction_log_set.GetTransactionLog(transaction_log_index); + TransactionLogLocalView transaction_log_local_view{transaction_log_set.GetTransactionLog(transaction_log_index)}; transaction_log_local_view.SubscribeTransactionBegin(subscription_max_sample_count); transaction_log_local_view.SubscribeTransactionCommit(); @@ -137,7 +137,7 @@ void InsertSkeletonTransactionLogWithInvalidTransactions( transaction_log_set.RegisterSkeletonTransactionLog(consumer_event_data_control_local); const auto transaction_log_index = transaction_registration_guard.GetTransactionLogIndex(); - TransactionLogLocalView transaction_log_local_view = transaction_log_set.GetTransactionLog(transaction_log_index); + TransactionLogLocalView transaction_log_local_view{transaction_log_set.GetTransactionLog(transaction_log_index)}; constexpr std::size_t slot_index{0U}; transaction_log_local_view.ReferenceTransactionBegin(slot_index); diff --git a/score/mw/com/impl/bindings/lola/transaction_log_local_view.h b/score/mw/com/impl/bindings/lola/transaction_log_local_view.h index c21922f828..3c437a11b4 100644 --- a/score/mw/com/impl/bindings/lola/transaction_log_local_view.h +++ b/score/mw/com/impl/bindings/lola/transaction_log_local_view.h @@ -45,7 +45,7 @@ class TransactionLogLocalView using UnsubscribeCallback = score::cpp::callback; - TransactionLogLocalView(TransactionLog& transaction_log); + explicit TransactionLogLocalView(TransactionLog& transaction_log); /// \brief Record Subscription / Unsubscription transactions /// diff --git a/score/mw/com/impl/bindings/lola/transaction_log_registration_guard.cpp b/score/mw/com/impl/bindings/lola/transaction_log_registration_guard.cpp index 9bcc2d782f..aa966619bf 100644 --- a/score/mw/com/impl/bindings/lola/transaction_log_registration_guard.cpp +++ b/score/mw/com/impl/bindings/lola/transaction_log_registration_guard.cpp @@ -82,7 +82,7 @@ TransactionLogRegistrationGuard::TransactionLogRegistrationGuard( }} { auto& transaction_log = transaction_log_set.GetTransactionLog(transaction_log_index); - consumer_event_data_control_local_view.SetTransactionLogLocalView(transaction_log); + consumer_event_data_control_local_view.SetTransactionLogLocalView(TransactionLogLocalView{transaction_log}); constexpr bool is_transaction_log_set_movable_or_copyable = is_movable_or_copyable::value; static_assert(!is_transaction_log_set_movable_or_copyable, diff --git a/score/mw/com/impl/bindings/lola/transaction_log_rollback_executor_test.cpp b/score/mw/com/impl/bindings/lola/transaction_log_rollback_executor_test.cpp index fba18983bf..409ac11e40 100644 --- a/score/mw/com/impl/bindings/lola/transaction_log_rollback_executor_test.cpp +++ b/score/mw/com/impl/bindings/lola/transaction_log_rollback_executor_test.cpp @@ -109,7 +109,7 @@ class TransactionLogRollbackExecutorFixture : public ::testing::Test { auto find_result = service_data_control_->event_controls_.find(element_fq_id); EXPECT_NE(find_result, service_data_control_->event_controls_.cend()); - return {find_result->second.data_control}; + return ConsumerEventDataControlLocalView<>{find_result->second.data_control}; } TransactionLogSet& GetTransactionLogSet(const ElementFqId element_fq_id) noexcept diff --git a/score/mw/com/impl/bindings/lola/transaction_log_set_test.cpp b/score/mw/com/impl/bindings/lola/transaction_log_set_test.cpp index b583e9e649..15a8dfca8d 100644 --- a/score/mw/com/impl/bindings/lola/transaction_log_set_test.cpp +++ b/score/mw/com/impl/bindings/lola/transaction_log_set_test.cpp @@ -78,7 +78,7 @@ class TransactionLogSetFixture : public TransactionLogSetHelperFixture auto transaction_log_registration_guard = unit_->RegisterProxyElement(transaction_log_id, consumer_event_data_control_local_).value(); const auto transaction_log_index = transaction_log_registration_guard.GetTransactionLogIndex(); - TransactionLogLocalView transaction_log_local_view = unit_->GetTransactionLog(transaction_log_index); + TransactionLogLocalView transaction_log_local_view{unit_->GetTransactionLog(transaction_log_index)}; transaction_log_local_view.SubscribeTransactionBegin(kSubscriptionMaxSampleCount); transaction_log_local_view.SubscribeTransactionCommit(); @@ -99,7 +99,7 @@ class TransactionLogSetFixture : public TransactionLogSetHelperFixture auto transaction_log_registration_guard = unit_->RegisterProxyElement(transaction_log_id, consumer_event_data_control_local_).value(); const auto transaction_log_index = transaction_log_registration_guard.GetTransactionLogIndex(); - TransactionLogLocalView transaction_log_local_view = unit_->GetTransactionLog(transaction_log_index); + TransactionLogLocalView transaction_log_local_view{unit_->GetTransactionLog(transaction_log_index)}; transaction_log_local_view.SubscribeTransactionBegin(kSubscriptionMaxSampleCount); transaction_log_local_view.SubscribeTransactionCommit(); transaction_log_local_view.ReferenceTransactionBegin(slot_index); @@ -329,7 +329,7 @@ TEST_F(TransactionLogSetRollbackFixture, const auto transaction_log_index = transaction_registration_guard.GetTransactionLogIndex(); // and a subscribe transaction is begun but never finished, indicating a crash - TransactionLogLocalView transaction_log_local_view = unit_->GetTransactionLog(transaction_log_index); + TransactionLogLocalView transaction_log_local_view{unit_->GetTransactionLog(transaction_log_index)}; transaction_log_local_view.SubscribeTransactionBegin(kSubscriptionMaxSampleCount); // When MarkTransactionLogsNeedRollback is called @@ -377,7 +377,7 @@ TEST_F(TransactionLogSetRollbackFixture, unit_->RegisterSkeletonTransactionLog(consumer_event_data_control_local_); const auto transaction_log_index = transaction_registration_guard.GetTransactionLogIndex(); - TransactionLogLocalView transaction_log_local_view = unit_->GetTransactionLog(transaction_log_index); + TransactionLogLocalView transaction_log_local_view{unit_->GetTransactionLog(transaction_log_index)}; // and a successful reference transaction is recorded transaction_log_local_view.ReferenceTransactionBegin(slot_index); @@ -414,7 +414,7 @@ TEST_F(TransactionLogSetRollbackFixture, const auto transaction_log_index = transaction_registration_guard.GetTransactionLogIndex(); // and a reference transaction is begun but never finished, indicating a crash - TransactionLogLocalView transaction_log_local_view = unit_->GetTransactionLog(transaction_log_index); + TransactionLogLocalView transaction_log_local_view{unit_->GetTransactionLog(transaction_log_index)}; transaction_log_local_view.ReferenceTransactionBegin(slot_index); // When RollbackProxyTransactions is called @@ -597,7 +597,7 @@ TEST_F(TransactionLogSetRegisterFixtureDeathTest, CallingUnRegisterWhileTransact const auto transaction_log_index = transaction_registration_guard.GetTransactionLogIndex(); // and a reference transaction is begun but never finished, indicating a crash - TransactionLogLocalView transaction_log_local_view = unit_->GetTransactionLog(transaction_log_index); + TransactionLogLocalView transaction_log_local_view{unit_->GetTransactionLog(transaction_log_index)}; transaction_log_local_view.ReferenceTransactionBegin(2U); }; diff --git a/score/mw/com/impl/configuration/configuration.cpp b/score/mw/com/impl/configuration/configuration.cpp index 529b72b307..6b6a7344d5 100644 --- a/score/mw/com/impl/configuration/configuration.cpp +++ b/score/mw/com/impl/configuration/configuration.cpp @@ -272,9 +272,11 @@ score::Result Configuration::CrossCheckServiceInstancesToTypes() const noe score::Result Configuration::HasLolaServiceDeployment() const noexcept { auto deployment_info_visitor = score::cpp::overload( + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const LolaServiceTypeDeployment&) { return true; }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept { return false; }); @@ -344,6 +346,7 @@ std::set Configuration::GetElementNamesOfServiceType(const std // LCOV_EXCL_START (Unreachable Code: GetElementNamesOfServiceType can only be called on an existing service // type. I.e. The ServiceTypeDeployment must be LolaServiceTypeDeployment and can never be score::cpp::blank. // This code is there because std::visitor must handle all std::variant types. + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept { return; } diff --git a/score/mw/com/impl/configuration/service_instance_deployment.cpp b/score/mw/com/impl/configuration/service_instance_deployment.cpp index 23c82beac0..7d5f20354c 100644 --- a/score/mw/com/impl/configuration/service_instance_deployment.cpp +++ b/score/mw/com/impl/configuration/service_instance_deployment.cpp @@ -129,6 +129,7 @@ score::json::Object ServiceInstanceDeployment::Serialize() const [&json_object](const LolaServiceInstanceDeployment& deployment) { json_object[kBindingInfoKey] = deployment.Serialize(); }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept {}); std::visit(visitor, bindingInfo_); @@ -149,11 +150,13 @@ BindingType ServiceInstanceDeployment::GetBindingType() const // FP: only one statement in this line // coverity[autosar_cpp14_a7_1_7_violation] auto visitor = score::cpp::overload( + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const LolaServiceInstanceDeployment&) noexcept { return BindingType::kLoLa; }, // FP: only one statement in this line // coverity[autosar_cpp14_a7_1_7_violation] + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept { return BindingType::kFake; }); diff --git a/score/mw/com/impl/configuration/service_instance_id.cpp b/score/mw/com/impl/configuration/service_instance_id.cpp index b861cb4190..884b7b8130 100644 --- a/score/mw/com/impl/configuration/service_instance_id.cpp +++ b/score/mw/com/impl/configuration/service_instance_id.cpp @@ -82,9 +82,11 @@ std::string ToHashStringImpl(const ServiceInstanceId::BindingInformation& bindin binding_index_string_stream << std::hex << binding_info_index; auto visitor = score::cpp::overload( + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const LolaServiceInstanceId& instance_id) noexcept -> std::string_view { return instance_id.ToHashString(); }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept -> std::string_view { return ""; }); @@ -132,6 +134,7 @@ score::json::Object ServiceInstanceId::Serialize() const [&json_object](const LolaServiceInstanceId& instance_id) { json_object[kBindingInfoKeySerInstID] = instance_id.Serialize(); }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept {}); std::visit(visitor, binding_info_); return json_object; diff --git a/score/mw/com/impl/configuration/service_type_deployment.cpp b/score/mw/com/impl/configuration/service_type_deployment.cpp index fb16841056..9ea1169469 100644 --- a/score/mw/com/impl/configuration/service_type_deployment.cpp +++ b/score/mw/com/impl/configuration/service_type_deployment.cpp @@ -68,11 +68,13 @@ std::string ToHashStringImpl(const ServiceTypeDeployment::BindingInformation& bi binding_index_string_stream << std::hex << binding_info_index; auto visitor = score::cpp::overload( + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const LolaServiceTypeDeployment& service_type_deployment) noexcept -> std::string_view { return service_type_deployment.ToHashString(); }, // FP: only one statement in this line // coverity[autosar_cpp14_a7_1_7_violation] + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept -> std::string_view { return ""; }); @@ -125,6 +127,7 @@ score::json::Object ServiceTypeDeployment::Serialize() const [&json_object](const LolaServiceTypeDeployment& deployment) { json_object[kBindingInfoKey] = deployment.Serialize(); }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept {}); std::visit(visitor, binding_info_); diff --git a/score/mw/com/impl/generic_proxy.cpp b/score/mw/com/impl/generic_proxy.cpp index c139015a6c..5a8da449c2 100644 --- a/score/mw/com/impl/generic_proxy.cpp +++ b/score/mw/com/impl/generic_proxy.cpp @@ -45,6 +45,7 @@ std::vector GetEventNameList(const InstanceIdentifier& identif const auto& service_type_deployment = InstanceIdentifierView{identifier}.GetServiceTypeDeployment(); auto visitor = score::cpp::overload( + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const LolaServiceTypeDeployment& deployment) -> ReturnType { ReturnType event_names; for (const auto& event : deployment.events_) @@ -53,6 +54,7 @@ std::vector GetEventNameList(const InstanceIdentifier& identif } return event_names; }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept -> ReturnType { return {}; }); @@ -84,6 +86,7 @@ Result GenericProxy::Create(HandleType instance_handle) generic_proxy.FillEventMap(event_names); auto generic_proxy_events = generic_proxy.GetEvents(); const bool are_event_bindings_valid = + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) std::all_of(generic_proxy_events.cbegin(), generic_proxy_events.cend(), [](const auto& element) { const auto binding_construction_result = ProxyEventBaseView{element.second}.GetBindingConstructionResult(); if (!binding_construction_result.has_value()) diff --git a/score/mw/com/impl/generic_proxy_event.cpp b/score/mw/com/impl/generic_proxy_event.cpp index a02c3875da..51b3c612b6 100644 --- a/score/mw/com/impl/generic_proxy_event.cpp +++ b/score/mw/com/impl/generic_proxy_event.cpp @@ -25,6 +25,7 @@ GenericProxyEvent::GenericProxyEvent(ProxyBase& base, const std::string_view eve ProxyBaseView{base}.GetBinding(), event_name, ServiceElementType::EVENT) + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) .and_then([](std::unique_ptr binding) { return Result>{std::move(binding)}; })} diff --git a/score/mw/com/impl/generic_skeleton.cpp b/score/mw/com/impl/generic_skeleton.cpp index 800b77ab91..e436fe7925 100644 --- a/score/mw/com/impl/generic_skeleton.cpp +++ b/score/mw/com/impl/generic_skeleton.cpp @@ -46,6 +46,7 @@ std::string_view GetEventName(const InstanceIdentifier& identifier, std::string_ } return {}; }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept -> std::string_view { return {}; }); diff --git a/score/mw/com/impl/instance_identifier.cpp b/score/mw/com/impl/instance_identifier.cpp index 0642b29d9a..aa6d99402c 100644 --- a/score/mw/com/impl/instance_identifier.cpp +++ b/score/mw/com/impl/instance_identifier.cpp @@ -164,6 +164,7 @@ InstanceIdentifierView::InstanceIdentifierView(const InstanceIdentifier& identif auto InstanceIdentifierView::GetServiceInstanceId() const -> std::optional { auto visitor = score::cpp::overload( + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const LolaServiceInstanceDeployment& deployment) -> std::optional { if (!deployment.instance_id_.has_value()) { @@ -171,6 +172,7 @@ auto InstanceIdentifierView::GetServiceInstanceId() const -> std::optional std::optional { return std::optional{}; }); diff --git a/score/mw/com/impl/instance_specifier.cpp b/score/mw/com/impl/instance_specifier.cpp index f88b706edf..39ca5e9523 100644 --- a/score/mw/com/impl/instance_specifier.cpp +++ b/score/mw/com/impl/instance_specifier.cpp @@ -42,6 +42,7 @@ bool IsShortNameValid(const std::string_view shortname) noexcept return false; } + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) auto validate_chars = [](auto it_begin, auto it_end, const bool first_char) -> bool { const auto found_invalid_chars = std::find_if_not(it_begin, it_end, [first_char](const auto curent_char) { const auto u_ch = static_cast(curent_char); diff --git a/score/mw/com/impl/plumbing/proxy_event_binding_factory_impl.cpp b/score/mw/com/impl/plumbing/proxy_event_binding_factory_impl.cpp index 58e82723e0..553e79a765 100644 --- a/score/mw/com/impl/plumbing/proxy_event_binding_factory_impl.cpp +++ b/score/mw/com/impl/plumbing/proxy_event_binding_factory_impl.cpp @@ -57,6 +57,7 @@ Result> GenericProxyEventBindingFactor GetElementFqId(parent_handle, lola_type_deployment, std::string{event_name}, service_element_type); return std::make_unique(*lola_proxy, element_fq_id, event_name); }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept -> ReturnType { return MakeUnexpected(BindingFactoryErrorCode::kUnsupportedBindingType); }); diff --git a/score/mw/com/impl/plumbing/proxy_method_binding_factory_impl.h b/score/mw/com/impl/plumbing/proxy_method_binding_factory_impl.h index 767b608108..cde220be01 100644 --- a/score/mw/com/impl/plumbing/proxy_method_binding_factory_impl.h +++ b/score/mw/com/impl/plumbing/proxy_method_binding_factory_impl.h @@ -158,6 +158,7 @@ Result> ProxyMethodBindingFactoryImpl( *lola_proxy, proxy_method_instance_identifier, type_erased_element_info); }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept -> LambdaReturnType { return MakeUnexpected(BindingFactoryErrorCode::kUnsupportedBindingType); }); diff --git a/score/mw/com/impl/plumbing/sample_ptr.h b/score/mw/com/impl/plumbing/sample_ptr.h index 70476ebcce..684ad635cc 100644 --- a/score/mw/com/impl/plumbing/sample_ptr.h +++ b/score/mw/com/impl/plumbing/sample_ptr.h @@ -65,6 +65,7 @@ class SamplePtr final // nullptr: void TestFunc(SamplePtr ptr = nullptr) // coverity[autosar_cpp14_a12_1_4_violation] see above rationale for clang-tidy // coverity[autosar_cpp14_a13_3_1_violation] + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(sample-ptr-implicit-nullptr-constructor) constexpr SamplePtr(std::nullptr_t /* ptr */) noexcept : SamplePtr() {} // NOLINTEND(google-explicit-constructor): see above for detailed explanation diff --git a/score/mw/com/impl/plumbing/sample_ptr_test.cpp b/score/mw/com/impl/plumbing/sample_ptr_test.cpp index 4ef0a433c0..f4d38a3956 100644 --- a/score/mw/com/impl/plumbing/sample_ptr_test.cpp +++ b/score/mw/com/impl/plumbing/sample_ptr_test.cpp @@ -16,6 +16,7 @@ #include "score/mw/com/impl/bindings/lola/provider_event_data_control_local_view.h" #include "score/mw/com/impl/bindings/lola/test_doubles/fake_memory_resource.h" #include "score/mw/com/impl/bindings/lola/transaction_log.h" +#include "score/mw/com/impl/bindings/lola/transaction_log_local_view.h" #include @@ -38,7 +39,8 @@ class LolaForwardingSamplePtrTest : public ::testing::Test lola::EventDataControl event_data_control_{kMaxSlots, memory_}; lola::TransactionLog transaction_log_{kMaxSlots, memory_}; lola::ProviderEventDataControlLocalView<> provider_event_data_control_local_{event_data_control_}; - lola::ConsumerEventDataControlLocalView<> consumer_event_data_control_local_{event_data_control_, transaction_log_}; + lola::ConsumerEventDataControlLocalView<> consumer_event_data_control_local_{ + event_data_control_, lola::TransactionLogLocalView{transaction_log_}}; lola::SlotIndexType AllocateSlot(lola::EventSlotStatus::EventTimeStamp timestamp) { diff --git a/score/mw/com/impl/plumbing/skeleton_method_binding_factory_impl.cpp b/score/mw/com/impl/plumbing/skeleton_method_binding_factory_impl.cpp index d78abc1e9c..eb32509f26 100644 --- a/score/mw/com/impl/plumbing/skeleton_method_binding_factory_impl.cpp +++ b/score/mw/com/impl/plumbing/skeleton_method_binding_factory_impl.cpp @@ -66,6 +66,7 @@ auto SkeletonMethodBindingFactoryImpl::Create(const InstanceIdentifier& instance }; auto deployment_info_visitor = + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) score::cpp::overload(lola_deployment_handler, [](const score::cpp::blank&) noexcept -> LambdaReturnType { // coverage false positive. Covered by the test: // SkeletonMethodFactoryFixture.CannotConstructEventFromBlankBinding diff --git a/score/mw/com/impl/plumbing/skeleton_service_element_binding_factory_impl.h b/score/mw/com/impl/plumbing/skeleton_service_element_binding_factory_impl.h index bc2ced08d2..63009c2c0e 100644 --- a/score/mw/com/impl/plumbing/skeleton_service_element_binding_factory_impl.h +++ b/score/mw/com/impl/plumbing/skeleton_service_element_binding_factory_impl.h @@ -238,6 +238,7 @@ auto CreateGenericSkeletonEventOrField(const InstanceIdentifier& identifier, size_info, tracing::SkeletonEventTracingData{}); }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const score::cpp::blank&) noexcept -> ReturnType { return nullptr; }); diff --git a/score/mw/com/impl/proxy_base.cpp b/score/mw/com/impl/proxy_base.cpp index b2600f5680..0392b65ba0 100644 --- a/score/mw/com/impl/proxy_base.cpp +++ b/score/mw/com/impl/proxy_base.cpp @@ -102,6 +102,7 @@ bool ProxyBase::AreBindingsValid() const noexcept { const bool is_proxy_binding_valid = proxy_binding_ != nullptr; + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) const bool are_event_bindings_valid = std::all_of(events_.begin(), events_.end(), [](const auto& element) { const auto binding_construction_result = ProxyEventBaseView{element.second.get().Get()}.GetBindingConstructionResult(); @@ -112,6 +113,7 @@ bool ProxyBase::AreBindingsValid() const noexcept } return binding_construction_result.has_value(); }); + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) const bool are_field_bindings_valid = std::all_of(fields_.begin(), fields_.end(), [](const auto& element) { const auto event_binding_construction_result = ProxyFieldBaseView{element.second.get().Get()}.GetEventBindingConstructionResult(); @@ -140,6 +142,7 @@ bool ProxyBase::AreBindingsValid() const noexcept return event_binding_construction_result.has_value() && setter_binding_construction_result.has_value() && getter_binding_construction_result.has_value(); }); + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) const bool are_method_bindings_valid = std::all_of(methods_.begin(), methods_.end(), [](const auto& element) { const auto binding_construction_result = ProxyMethodBaseView{element.second.get().Get()}.GetBindingConstructionResult(); diff --git a/score/mw/com/impl/runtime.cpp b/score/mw/com/impl/runtime.cpp index dbc831c804..0f08278fd9 100644 --- a/score/mw/com/impl/runtime.cpp +++ b/score/mw/com/impl/runtime.cpp @@ -189,6 +189,7 @@ Runtime& Runtime::getInstanceInternal() // Suppress "AUTOSAR C++14 A3-3-2" rule finding. This rule states: "Static and thread-local objects shall be // constant-initialized.". This cannot be constexpr as the lambda function executes at runtime. // coverity[autosar_cpp14_a3_3_2_violation] + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) return singleton::MeyerSingleton::GetInstanceInitializedWithCallable([]() -> Runtime { std::lock_guard lock{mutex_}; runtime_initialization_locked_ = true; diff --git a/score/mw/com/impl/service_element_map_view.h b/score/mw/com/impl/service_element_map_view.h index 2aa1e4cba5..59181231cf 100644 --- a/score/mw/com/impl/service_element_map_view.h +++ b/score/mw/com/impl/service_element_map_view.h @@ -93,7 +93,7 @@ class ServiceElementMapView /// \details ctor is private. Creation shall be done via ServiceElementMapView<>::Create(). /// @param service_element_map underlying map on which the view is created. It must not be moved or copied after /// being passed to this ctor. - ServiceElementMapView(map_type& service_element_map) noexcept : elements_{service_element_map} {} + explicit ServiceElementMapView(map_type& service_element_map) noexcept : elements_{service_element_map} {} std::reference_wrapper elements_; }; diff --git a/score/mw/com/impl/skeleton_base.cpp b/score/mw/com/impl/skeleton_base.cpp index b80c16130e..1896e3e7d4 100644 --- a/score/mw/com/impl/skeleton_base.cpp +++ b/score/mw/com/impl/skeleton_base.cpp @@ -209,6 +209,7 @@ auto SkeletonBase::OfferService() -> Result // Since the service has been successfully offered, we release the offer guards so that they do not call // PrepareStopOffer() when they go out of scope. binding_offer_guard.Release(); + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) auto release_guards = [](auto& offer_guards) { for (auto& guard : offer_guards) { diff --git a/score/mw/com/impl/tracing/configuration/tracing_filter_config.cpp b/score/mw/com/impl/tracing/configuration/tracing_filter_config.cpp index 58b54af264..b1ed735809 100644 --- a/score/mw/com/impl/tracing/configuration/tracing_filter_config.cpp +++ b/score/mw/com/impl/tracing/configuration/tracing_filter_config.cpp @@ -229,6 +229,7 @@ std::size_t FindNumberOfTracingSlots( const std::string service_element_name{service_element.service_element_name}; const auto get_number_of_tracing_slots = + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const auto& service_elements_map, const std::string& local_service_element_name, const ServiceElementIdentifierView& local_service_element, @@ -250,6 +251,7 @@ std::size_t FindNumberOfTracingSlots( get_number_of_tracing_slots(lola_service_instance_deployment->events_, service_element_name, service_element, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const LolaEventInstanceDeployment& e) noexcept { return e.GetNumberOfTracingSlots(); }); @@ -264,6 +266,7 @@ std::size_t FindNumberOfTracingSlots( get_number_of_tracing_slots(lola_service_instance_deployment->fields_, service_element_name, service_element, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const LolaFieldInstanceDeployment& f) noexcept { return f.lola_event_instance_deployment_.GetNumberOfTracingSlots(); }); diff --git a/score/mw/com/impl/tracing/tracing_runtime.cpp b/score/mw/com/impl/tracing/tracing_runtime.cpp index ea3bb45c3c..0977dc9343 100644 --- a/score/mw/com/impl/tracing/tracing_runtime.cpp +++ b/score/mw/com/impl/tracing/tracing_runtime.cpp @@ -135,6 +135,7 @@ analysis::tracing::TracePointType InternalToExternalTracePointType( const TracingRuntime::TracePointType& internal_trace_point_type) { auto visitor = score::cpp::overload( + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const ProxyEventTracePointType& proxy_event_trace_point) -> analysis::tracing::TracePointType { if (proxy_event_trace_point == ProxyEventTracePointType::INVALID) { @@ -143,6 +144,7 @@ analysis::tracing::TracePointType InternalToExternalTracePointType( } return kProxyEventTracePointToTracingTracePointMap.at(proxy_event_trace_point); }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const ProxyFieldTracePointType& proxy_field_trace_point) -> analysis::tracing::TracePointType { if (proxy_field_trace_point == ProxyFieldTracePointType::INVALID) { @@ -151,6 +153,7 @@ analysis::tracing::TracePointType InternalToExternalTracePointType( } return kProxyFieldTracePointToTracingTracePointMap.at(proxy_field_trace_point); }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const SkeletonEventTracePointType& skeleton_event_trace_point) -> analysis::tracing::TracePointType { if (skeleton_event_trace_point == SkeletonEventTracePointType::INVALID) { @@ -159,6 +162,7 @@ analysis::tracing::TracePointType InternalToExternalTracePointType( } return kSkeletonEventTracePointToTracingTracePointMap.at(skeleton_event_trace_point); }, + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(lambda-closure-function-pointer-conversion) [](const SkeletonFieldTracePointType& skeleton_field_trace_point) -> analysis::tracing::TracePointType { if (skeleton_field_trace_point == SkeletonFieldTracePointType::INVALID) { diff --git a/score/mw/com/impl/util/copyable_atomic.h b/score/mw/com/impl/util/copyable_atomic.h index bf3353a07c..35ec2ff9e0 100644 --- a/score/mw/com/impl/util/copyable_atomic.h +++ b/score/mw/com/impl/util/copyable_atomic.h @@ -62,6 +62,7 @@ class CopyableAtomic // NOLINTBEGIN(google-explicit-constructor): Explanation provided below. // We want to have implicit conversions exactly as std::atomic allows as this is just a wrapper around std::atomic. // coverity[autosar_cpp14_a13_5_2_violation] + // Deviation of MISRA RULE-15-1-3: codeql::misra_deviation_next_line(copyable-atomic-implicit-conversion) operator T() const noexcept { return atomic_.operator T(); diff --git a/score/mw/com/runtime_configuration.h b/score/mw/com/runtime_configuration.h index aa0c7f0036..5ac7f86c34 100644 --- a/score/mw/com/runtime_configuration.h +++ b/score/mw/com/runtime_configuration.h @@ -62,7 +62,7 @@ class RuntimeConfiguration * path. If the key is not found, a default path is used. * \param command_line_arguments The command line arguments. */ - RuntimeConfiguration(cpp::span command_line_arguments); + explicit RuntimeConfiguration(cpp::span command_line_arguments); /** * \api