Skip to content

Commit 70ebc47

Browse files
committed
Fix nasa#31, Refactor message action logic dependent conditionals to support full coverage
1 parent 2fc0dd9 commit 70ebc47

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

fsw/src/hs_monitors.c

+14-15
Original file line numberDiff line numberDiff line change
@@ -172,20 +172,18 @@ void HS_MonitorApplications(void)
172172
break;
173173

174174
/*
175-
** Also the case for Message Action types
175+
** Message Action types processing (invalid will be skipped)
176176
*/
177-
case HS_AMT_ACT_NOACT:
178177
default:
178+
179+
/* Calculate the requested message action index */
180+
MsgActsIndex = ActionType - HS_AMT_ACT_LAST_NONMSG - 1;
181+
179182
/*
180-
** Check to see if this is a Message Action Type
183+
** Check to see if this is a valid Message Action Type
181184
*/
182-
if ((HS_AppData.MsgActsState == HS_STATE_ENABLED) &&
183-
(ActionType > HS_AMT_ACT_LAST_NONMSG) &&
184-
(ActionType <= (HS_AMT_ACT_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES)))
185+
if ((HS_AppData.MsgActsState == HS_STATE_ENABLED) && (MsgActsIndex < HS_MAX_MSG_ACT_TYPES))
185186
{
186-
/* Calculate index in Message Action Table */
187-
MsgActsIndex = ActionType - HS_AMT_ACT_LAST_NONMSG - 1;
188-
189187
/*
190188
** Send the message if off cooldown and not disabled
191189
*/
@@ -332,17 +330,18 @@ void HS_MonitorEvent(const CFE_EVS_LongEventTlm_t *EventPtr)
332330
break;
333331

334332
/*
335-
** Also the case for Message Action types
333+
** Message Action types processing (invalid will be skipped)
336334
*/
337-
case HS_EMT_ACT_NOACT:
338335
default:
336+
337+
/* Calculate the requested message action index */
338+
MsgActsIndex = ActionType - HS_AMT_ACT_LAST_NONMSG - 1;
339+
339340
/*
340-
** Check to see if this is a Message Action Type
341+
** Check to see if this is a valid Message Action Type
341342
*/
342-
if ((HS_AppData.MsgActsState == HS_STATE_ENABLED) && (ActionType > HS_EMT_ACT_LAST_NONMSG) &&
343-
(ActionType <= (HS_EMT_ACT_LAST_NONMSG + HS_MAX_MSG_ACT_TYPES)))
343+
if ((HS_AppData.MsgActsState == HS_STATE_ENABLED) && (MsgActsIndex < HS_MAX_MSG_ACT_TYPES))
344344
{
345-
MsgActsIndex = ActionType - HS_EMT_ACT_LAST_NONMSG - 1;
346345

347346
/*
348347
** Send the message if off cooldown and not disabled

0 commit comments

Comments
 (0)