queue nullptr check in action helper #458

Merged
gaisser merged 3 commits from meier/ActionHelperQueueCheck into development 2021-09-13 15:24:35 +02:00
Owner
  • added nullptr check for queueToUse in ActionHelper
* added nullptr check for queueToUse in ActionHelper
meierj added 1 commit 2021-08-07 14:31:04 +02:00
mohr reviewed 2021-08-09 12:04:36 +02:00
mohr left a comment
Owner

I would suggest removing setQueueToUse(MessageQueueIF* queue), when introducing the nullptr check as it becomes mostly useless.

I would suggest removing `setQueueToUse(MessageQueueIF* queue)`, when introducing the `nullptr` check as it becomes mostly useless.
@ -33,6 +33,17 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
setQueueToUse(queueToUse_);
Owner

As there is a check for nullptr in the following line, this if can be removed and setQueueToUse(queueToUse_); be moved to the end.

As there is a check for nullptr in the following line, this if can be removed and ` setQueueToUse(queueToUse_);` be moved to the end.
@ -33,6 +33,17 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
setQueueToUse(queueToUse_);
}
if(queueToUse == nullptr) {
Owner

If setQueueToUse(queueToUse_); is moved to below this check, queueToUse_ needs to be checked instead of queueToUse.

If `setQueueToUse(queueToUse_);` is moved to below this check, `queueToUse_` needs to be checked instead of `queueToUse`.
Owner

queueToUse_ is allowed to be nullptr in ActionHelper::initialize(MessageQueueIF* queueToUse_) as queueToUse can be set in the constructor or by calling setQueueToUse(xxx) before initialize. Therefore, we need to check both as we have three cases:

  1. queueToUse was set before
    1. queueToUse_ can be nullptr and setQueueToUse(queueToUse_); should not be called
  2. queueToUse was not set before
    1. queueToUse_ is nullptr -> Error Message
    2. queueToUse_ is not a nullptr -> call setQueueToUse(queueToUse_);
``queueToUse_`` is allowed to be nullptr in `` ActionHelper::initialize(MessageQueueIF* queueToUse_)`` as ``queueToUse`` can be set in the constructor or by calling ``setQueueToUse(xxx)`` before ``initialize``. Therefore, we need to check both as we have three cases: 1. ``queueToUse`` was set before 1. ``queueToUse_`` can be nullptr and `` setQueueToUse(queueToUse_); `` should not be called 2. ``queueToUse`` was not set before 1. ``queueToUse_`` is nullptr -> Error Message 2. ``queueToUse_`` is not a nullptr -> call `` setQueueToUse(queueToUse_); ``
mohr was assigned by gaisser 2021-08-16 14:41:53 +02:00
muellerr added 1 commit 2021-09-06 18:48:26 +02:00
gaisser added 1 commit 2021-09-13 15:17:50 +02:00
gaisser merged commit a986b22345 into development 2021-09-13 15:24:35 +02:00
gaisser deleted branch meier/ActionHelperQueueCheck 2021-09-13 15:24:40 +02:00
Sign in to join this conversation.
No description provided.