diff --git a/include/libcyphal/transport/can/delegate.hpp b/include/libcyphal/transport/can/delegate.hpp index 7053222f8..59698e3b1 100644 --- a/include/libcyphal/transport/can/delegate.hpp +++ b/include/libcyphal/transport/can/delegate.hpp @@ -215,7 +215,9 @@ class TransportDelegate /// @brief Releases memory allocated for canard (by previous `allocateMemoryForCanard` call). /// - void freeCanardMemory(void* const pointer) + /// NOSONAR b/s it is unavoidable: this is integration with low-level C code of Canard memory management. + /// + void freeCanardMemory(void* const pointer) // NOSONAR { if (pointer == nullptr) { diff --git a/include/libcyphal/transport/can/msg_rx_session.hpp b/include/libcyphal/transport/can/msg_rx_session.hpp index 21e8f9ff0..53f992a7e 100644 --- a/include/libcyphal/transport/can/msg_rx_session.hpp +++ b/include/libcyphal/transport/can/msg_rx_session.hpp @@ -77,8 +77,8 @@ class MessageRxSession final : public IMessageRxSession, private IRxSessionDeleg { const std::int8_t result = ::canardRxSubscribe(&delegate.canard_instance(), CanardTransferKindMessage, - static_cast(params_.subject_id), - static_cast(params_.extent_bytes), + params_.subject_id, + params_.extent_bytes, CANARD_DEFAULT_TRANSFER_ID_TIMEOUT_USEC, &subscription_); (void) result; @@ -97,9 +97,8 @@ class MessageRxSession final : public IMessageRxSession, private IRxSessionDeleg ~MessageRxSession() override { - const int8_t result = ::canardRxUnsubscribe(&delegate_.canard_instance(), - CanardTransferKindMessage, - static_cast(params_.subject_id)); + const int8_t result = + ::canardRxUnsubscribe(&delegate_.canard_instance(), CanardTransferKindMessage, params_.subject_id); (void) result; CETL_DEBUG_ASSERT(result >= 0, "There is no way currently to get an error here."); CETL_DEBUG_ASSERT(result > 0, "Subscription supposed to be made at constructor."); @@ -156,7 +155,7 @@ class MessageRxSession final : public IMessageRxSession, private IRxSessionDeleg const MessageTransferMetadata meta{transfer_id, timestamp, priority, publisher_node_id}; TransportDelegate::CanardMemory canard_memory{delegate_, transfer.payload, transfer.payload_size}; - last_rx_transfer_.emplace(MessageRxTransfer{meta, ScatteredBuffer{std::move(canard_memory)}}); + (void) last_rx_transfer_.emplace(MessageRxTransfer{meta, ScatteredBuffer{std::move(canard_memory)}}); } // MARK: Data members: diff --git a/include/libcyphal/transport/can/msg_tx_session.hpp b/include/libcyphal/transport/can/msg_tx_session.hpp index a459b8293..9e8237577 100644 --- a/include/libcyphal/transport/can/msg_tx_session.hpp +++ b/include/libcyphal/transport/can/msg_tx_session.hpp @@ -89,7 +89,7 @@ class MessageTxSession final : public IMessageTxSession { const auto canard_metadata = CanardTransferMetadata{static_cast(metadata.priority), CanardTransferKindMessage, - static_cast(params_.subject_id), + params_.subject_id, CANARD_NODE_ID_UNSET, static_cast(metadata.transfer_id)}; diff --git a/include/libcyphal/transport/can/svc_rx_sessions.hpp b/include/libcyphal/transport/can/svc_rx_sessions.hpp index 2cad4ddd6..2bbf7508e 100644 --- a/include/libcyphal/transport/can/svc_rx_sessions.hpp +++ b/include/libcyphal/transport/can/svc_rx_sessions.hpp @@ -85,8 +85,8 @@ class SvcRxSession final : public Interface_, private IRxSessionDelegate { const int8_t result = ::canardRxSubscribe(&delegate.canard_instance(), TransferKind, - static_cast(params_.service_id), - static_cast(params_.extent_bytes), + params_.service_id, + params_.extent_bytes, CANARD_DEFAULT_TRANSFER_ID_TIMEOUT_USEC, &subscription_); (void) result; @@ -105,9 +105,7 @@ class SvcRxSession final : public Interface_, private IRxSessionDelegate ~SvcRxSession() override { - const int8_t result = ::canardRxUnsubscribe(&delegate_.canard_instance(), - TransferKind, - static_cast(params_.service_id)); + const int8_t result = ::canardRxUnsubscribe(&delegate_.canard_instance(), TransferKind, params_.service_id); (void) result; CETL_DEBUG_ASSERT(result >= 0, "There is no way currently to get an error here."); CETL_DEBUG_ASSERT(result > 0, "Subscription supposed to be made at constructor."); @@ -160,7 +158,7 @@ class SvcRxSession final : public Interface_, private IRxSessionDelegate const ServiceTransferMetadata meta{transfer_id, timestamp, priority, remote_node_id}; TransportDelegate::CanardMemory canard_memory{delegate_, transfer.payload, transfer.payload_size}; - last_rx_transfer_.emplace(ServiceRxTransfer{meta, ScatteredBuffer{std::move(canard_memory)}}); + (void) last_rx_transfer_.emplace(ServiceRxTransfer{meta, ScatteredBuffer{std::move(canard_memory)}}); } // MARK: Data members: diff --git a/include/libcyphal/transport/can/svc_tx_sessions.hpp b/include/libcyphal/transport/can/svc_tx_sessions.hpp index 84e79e185..c57017755 100644 --- a/include/libcyphal/transport/can/svc_tx_sessions.hpp +++ b/include/libcyphal/transport/can/svc_tx_sessions.hpp @@ -101,7 +101,7 @@ class SvcRequestTxSession final : public IRequestTxSession const auto canard_metadata = CanardTransferMetadata{static_cast(metadata.priority), CanardTransferKindRequest, - static_cast(params_.service_id), + params_.service_id, static_cast(params_.server_node_id), static_cast(metadata.transfer_id)}; @@ -196,7 +196,7 @@ class SvcResponseTxSession final : public IResponseTxSession const auto canard_metadata = CanardTransferMetadata{static_cast(metadata.priority), CanardTransferKindResponse, - static_cast(params_.service_id), + params_.service_id, static_cast(metadata.remote_node_id), static_cast(metadata.transfer_id)}; diff --git a/include/libcyphal/transport/can/transport.hpp b/include/libcyphal/transport/can/transport.hpp index c5d32f3fe..8223b75f0 100644 --- a/include/libcyphal/transport/can/transport.hpp +++ b/include/libcyphal/transport/can/transport.hpp @@ -116,8 +116,10 @@ class TransportImpl final : public ICanTransport, private TransportDelegate // - At least one media interface must be provided, but no more than the maximum allowed (255). // - If a local node ID is provided, it must be within the valid range. // - const auto media_count = static_cast( - std::count_if(media.begin(), media.end(), [](IMedia* const media) { return media != nullptr; })); + const auto media_count = + static_cast(std::count_if(media.begin(), media.end(), [](const IMedia* const media_ptr) { + return media_ptr != nullptr; + })); if ((media_count == 0) || (media_count > std::numeric_limits::max())) { return ArgumentError{}; @@ -416,7 +418,8 @@ class TransportImpl final : public ICanTransport, private TransportDelegate if (media_interface != nullptr) { IMedia& media = *media_interface; - media_array.emplace_back(index++, media, tx_capacity); + media_array.emplace_back(index, media, tx_capacity); + index++; } } CETL_DEBUG_ASSERT(index == media_count, ""); @@ -493,7 +496,7 @@ class TransportImpl final : public ICanTransport, private TransportDelegate const cetl::span payload{static_cast(tx_item->frame.payload), tx_item->frame.payload_size}; const Expected maybe_pushed = - media.interface().push(deadline, static_cast(tx_item->frame.extended_can_id), payload); + media.interface().push(deadline, tx_item->frame.extended_can_id, payload); if (const auto* const is_pushed = cetl::get_if(&maybe_pushed)) { if (!*is_pushed) diff --git a/include/libcyphal/transport/udp/transport.hpp b/include/libcyphal/transport/udp/transport.hpp index f3f1fab72..e05b48305 100644 --- a/include/libcyphal/transport/udp/transport.hpp +++ b/include/libcyphal/transport/udp/transport.hpp @@ -81,8 +81,7 @@ class TransportImpl final : public IUdpTransport } // TODO: Implement! - - return ArgumentError{}; + return {}; } CETL_NODISCARD ProtocolParams getProtocolParams() const noexcept override