coverity fix

This commit is contained in:
Robin Müller 2021-04-08 19:07:03 +02:00
parent efb7c8760a
commit b30a3aaa38

View File

@ -106,6 +106,9 @@ bool MessageQueue::isDefaultDestinationSet() const {
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo, ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
MessageQueueMessageIF* message, MessageQueueId_t sentFrom, MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
bool ignoreFault) { bool ignoreFault) {
if(message == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
message->setSender(sentFrom); message->setSender(sentFrom);
if(message->getMessageSize() > message->getMaximumMessageSize()) { if(message->getMessageSize() > message->getMaximumMessageSize()) {
// Actually, this should never happen or an error will be emitted // Actually, this should never happen or an error will be emitted
@ -128,12 +131,12 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
if(targetQueue->messageQueue.size() < targetQueue->messageDepth) { if(targetQueue->messageQueue.size() < targetQueue->messageDepth) {
MutexGuard mutexLock(targetQueue->queueLock, MutexGuard mutexLock(targetQueue->queueLock, MutexIF::TimeoutType::WAITING, 20);
MutexIF::TimeoutType::WAITING, 20); // TODO: Would be nice to support other message types, but this would require
// not ideal, works for now though. // create the message on the heap from an upper layer and simply storing
MessageQueueMessage* mqmMessage = // MessageQueueMessageIF pointers in the queue.
dynamic_cast<MessageQueueMessage*>(message); MessageQueueMessage* mqmMessage = dynamic_cast<MessageQueueMessage*>(message);
if(message != nullptr) { if(mqmMessage != nullptr) {
targetQueue->messageQueue.push(*mqmMessage); targetQueue->messageQueue.push(*mqmMessage);
} }
else { else {