cleaned up a bit

This commit is contained in:
Robin Müller 2021-05-31 12:30:54 +02:00
parent e961f3f038
commit 54e60f4ddc
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 20 additions and 25 deletions

View File

@ -204,11 +204,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
return MessageQueueIF::EMPTY; return MessageQueueIF::EMPTY;
case EBADF: { case EBADF: {
//mqdes doesn't represent a valid queue open for reading. //mqdes doesn't represent a valid queue open for reading.
#if FSFW_CPP_OSTREAM_ENABLED == 1 return handleRecvError("EBADF");
sif::error << "MessageQueue::receive: configuration error "
<< strerror(errno) << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
} }
case EINVAL: { case EINVAL: {
/* /*
@ -220,11 +216,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
* queue, and the QNX extended option MQ_READBUF_DYNAMIC hasn't * queue, and the QNX extended option MQ_READBUF_DYNAMIC hasn't
* been set in the queue's mq_flags. * been set in the queue's mq_flags.
*/ */
#if FSFW_CPP_OSTREAM_ENABLED == 1 return handleRecvError("EINVAL");
sif::error << "MessageQueue::receive: EINVAL error "
<< strerror(errno) << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
} }
case EMSGSIZE: { case EMSGSIZE: {
/* /*
@ -236,28 +228,16 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
* given msg_len is too short for the message that would have * given msg_len is too short for the message that would have
* been received. * been received.
*/ */
#if FSFW_CPP_OSTREAM_ENABLED == 1 return handleRecvError("EMSGSIZE");
sif::error << "MessageQueue::receive: EMSGSIZE error "
<< strerror(errno) << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
} }
case EINTR: { case EINTR: {
//The operation was interrupted by a signal. //The operation was interrupted by a signal.
#if FSFW_CPP_OSTREAM_ENABLED == 1 return handleRecvError("EINTR");
sif::error << "MessageQueue::receiveMessage: EINTR error " << strerror(errno) <<
std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
} }
case ETIMEDOUT: { case ETIMEDOUT: {
//The operation was interrupted by a signal. //The operation was interrupted by a signal.
#if FSFW_CPP_OSTREAM_ENABLED == 1 return handleRecvError("ETIMEDOUT");
sif::error << "MessageQueue::receiveMessage: ETIMEDOUT error " << strerror(errno) <<
std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED;
} }
default: default:
@ -423,3 +403,17 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t MessageQueue::handleRecvError(const char * const failString) {
if(failString == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::receiveMessage: " << failString << " error "
<< strerror(errno) << std::endl;
#else
sif::printError("MessageQueue::receiveMessage: %s error %s\n", failString,
strerror(errno));
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}

View File

@ -182,6 +182,7 @@ private:
const size_t maxMessageSize; const size_t maxMessageSize;
ReturnValue_t handleError(mq_attr* attributes, uint32_t messageDepth); ReturnValue_t handleError(mq_attr* attributes, uint32_t messageDepth);
ReturnValue_t handleRecvError(const char* const failString);
}; };
#endif /* FSFW_OSAL_LINUX_MESSAGEQUEUE_H_ */ #endif /* FSFW_OSAL_LINUX_MESSAGEQUEUE_H_ */