From 8889a52e630ecd12cb53b86a2861f1ad3296d5aa Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 14 Mar 2014 11:33:37 +0400 Subject: [PATCH] Added runtime checks for server and client --- libuavcan/include/uavcan/service_client.hpp | 5 +++-- libuavcan/include/uavcan/service_server.hpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libuavcan/include/uavcan/service_client.hpp b/libuavcan/include/uavcan/service_client.hpp index bc42b5eff6..9e0e07a99b 100644 --- a/libuavcan/include/uavcan/service_client.hpp +++ b/libuavcan/include/uavcan/service_client.hpp @@ -88,13 +88,14 @@ private: handleFatalError("Invalid caller callback"); } - void handleReceivedDataStruct(ReceivedDataStructure& request) + void handleReceivedDataStruct(ReceivedDataStructure& response) { + assert(response.getTransferType() == TransferTypeServiceResponse); const TransferListenerType* const listener = SubscriberType::getTransferListener(); if (listener) { const typename TransferListenerType::ExpectedResponseParams erp = listener->getExpectedResponseParams(); - ServiceCallResultType result(ServiceCallResultType::Success, erp.src_node_id, request); + ServiceCallResultType result(ServiceCallResultType::Success, erp.src_node_id, response); cancel(); invokeCallback(result); } diff --git a/libuavcan/include/uavcan/service_server.hpp b/libuavcan/include/uavcan/service_server.hpp index a3f37500c1..cbe8e436ff 100644 --- a/libuavcan/include/uavcan/service_server.hpp +++ b/libuavcan/include/uavcan/service_server.hpp @@ -38,6 +38,7 @@ private: void handleReceivedDataStruct(ReceivedDataStructure& request) { + assert(request.getTransferType() == TransferTypeServiceRequest); if (try_implicit_cast(callback_, true)) { response_ = ResponseType(); // The application needs newly initialized structure