diff --git a/.github/workflows/snapshot-module.yml b/.github/workflows/snapshot-module.yml new file mode 100644 index 0000000..260a7f8 --- /dev/null +++ b/.github/workflows/snapshot-module.yml @@ -0,0 +1,41 @@ +name: Snapshot CFS module + +on: + workflow_dispatch: + inputs: + base-branch: + description: 'The base branch to merge into' + type: string + required: false + default: 'main' + ic-branch: + description: 'The temporary integration branch to create (ic)' + type: string + required: false + default: 'ic-snapshot-dev' + dev-branch: + description: 'The branch to pull in' + type: string + required: false + default: 'dev' + pr-label: + description: 'The label(s) to apply to the generated PR' + type: string + required: false + default: '' + version-numbers: + description: 'The pending version/tag info, as a JSON object' + type: string + required: false + default: '{}' + +jobs: + snapshot-module: + name: Snapshot module + uses: nasa/cFS/.github/workflows/snapshot-module-reusable.yml@dev + with: + base-branch: ${{ inputs.base-branch }} + ic-branch: ${{ inputs.ic-branch }} + dev-branch: ${{ inputs.dev-branch }} + pr-label: ${{ inputs.pr-label }} + version-numbers: ${{ inputs.version-numbers }} diff --git a/fsw/src/lc_action.c b/fsw/src/lc_action.c index 92c1d35..455b690 100644 --- a/fsw/src/lc_action.c +++ b/fsw/src/lc_action.c @@ -288,27 +288,27 @@ void LC_SampleSingleAP(uint16 APNumber) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * StackPtr is an index into an array RPNStack (see LC_EvaluateRPN) + * StackIdx is an index into an array RPNStack (see LC_EvaluateRPN) * which contains values to be used in an RPN function. This macro - * validates the StackPtr to confirm that another operand is present + * validates the StackIdx to confirm that another operand is present * in the RPMStack array, then returns the next element. */ -#define POP_RPN_DATA ((StackPtr <= 0) ? (IllegalRPN = true) : (RPNStack[--StackPtr])) +#define POP_RPN_DATA ((StackIdx <= 0) ? (IllegalRPN = true) : (RPNStack[--StackIdx])) uint8 LC_EvaluateRPN(uint16 APNumber) { bool Done; bool IllegalRPN; bool IllegalOperand; uint8 EvalResult = LC_ACTION_ERROR; - int32 RPNEquationPtr; - int32 StackPtr; + int32 RPNEquationIdx; + int32 StackIdx; uint16 RPNData; uint16 RPNStack[LC_MAX_RPN_EQU_SIZE]; uint16 Operand1; uint16 Operand2; - StackPtr = 0; - RPNEquationPtr = 0; + StackIdx = 0; + RPNEquationIdx = 0; IllegalRPN = false; IllegalOperand = false; Done = false; @@ -322,7 +322,9 @@ uint8 LC_EvaluateRPN(uint16 APNumber) ** Pick off each piece of the RPN equation and handle ** one at a time */ - RPNData = LC_OperData.ADTPtr[APNumber].RPNEquation[RPNEquationPtr++]; + RPNData = LC_OperData.ADTPtr[APNumber].RPNEquation[RPNEquationIdx]; + + RPNEquationIdx++; /* ** The data is either an RPN operator or a watchpoint number @@ -339,20 +341,23 @@ uint8 LC_EvaluateRPN(uint16 APNumber) Operand1 = POP_RPN_DATA; if ((Operand1 == LC_WATCH_FALSE) || (Operand2 == LC_WATCH_FALSE)) { - RPNStack[StackPtr++] = LC_WATCH_FALSE; + RPNStack[StackIdx] = LC_WATCH_FALSE; } else if ((Operand1 == LC_WATCH_ERROR) || (Operand2 == LC_WATCH_ERROR)) { - RPNStack[StackPtr++] = LC_WATCH_ERROR; + RPNStack[StackIdx] = LC_WATCH_ERROR; } else if ((Operand1 == LC_WATCH_STALE) || (Operand2 == LC_WATCH_STALE)) { - RPNStack[StackPtr++] = LC_WATCH_STALE; + RPNStack[StackIdx] = LC_WATCH_STALE; } else { - RPNStack[StackPtr++] = LC_WATCH_TRUE; + RPNStack[StackIdx] = LC_WATCH_TRUE; } + + StackIdx++; + break; case LC_RPN_OR: @@ -360,20 +365,23 @@ uint8 LC_EvaluateRPN(uint16 APNumber) Operand1 = POP_RPN_DATA; if ((Operand1 == LC_WATCH_TRUE) || (Operand2 == LC_WATCH_TRUE)) { - RPNStack[StackPtr++] = LC_WATCH_TRUE; + RPNStack[StackIdx] = LC_WATCH_TRUE; } else if ((Operand1 == LC_WATCH_ERROR) || (Operand2 == LC_WATCH_ERROR)) { - RPNStack[StackPtr++] = LC_WATCH_ERROR; + RPNStack[StackIdx] = LC_WATCH_ERROR; } else if ((Operand1 == LC_WATCH_STALE) || (Operand2 == LC_WATCH_STALE)) { - RPNStack[StackPtr++] = LC_WATCH_STALE; + RPNStack[StackIdx] = LC_WATCH_STALE; } else { - RPNStack[StackPtr++] = LC_WATCH_FALSE; + RPNStack[StackIdx] = LC_WATCH_FALSE; } + + StackIdx++; + break; case LC_RPN_XOR: @@ -381,32 +389,38 @@ uint8 LC_EvaluateRPN(uint16 APNumber) Operand1 = POP_RPN_DATA; if ((Operand1 == LC_WATCH_ERROR) || (Operand2 == LC_WATCH_ERROR)) { - RPNStack[StackPtr++] = LC_WATCH_ERROR; + RPNStack[StackIdx] = LC_WATCH_ERROR; } else if ((Operand1 == LC_WATCH_STALE) || (Operand2 == LC_WATCH_STALE)) { - RPNStack[StackPtr++] = LC_WATCH_STALE; + RPNStack[StackIdx] = LC_WATCH_STALE; } else { - RPNStack[StackPtr++] = (Operand1 != Operand2); + RPNStack[StackIdx] = (Operand1 != Operand2); } + + StackIdx++; + break; case LC_RPN_NOT: Operand1 = POP_RPN_DATA; if (Operand1 == LC_WATCH_ERROR) { - RPNStack[StackPtr++] = LC_WATCH_ERROR; + RPNStack[StackIdx] = LC_WATCH_ERROR; } else if (Operand1 == LC_WATCH_STALE) { - RPNStack[StackPtr++] = LC_WATCH_STALE; + RPNStack[StackIdx] = LC_WATCH_STALE; } else { - RPNStack[StackPtr++] = (Operand1 == LC_WATCH_FALSE); + RPNStack[StackIdx] = (Operand1 == LC_WATCH_FALSE); } + + StackIdx++; + break; case LC_RPN_EQUAL: @@ -415,7 +429,7 @@ uint8 LC_EvaluateRPN(uint16 APNumber) { IllegalOperand = true; } - else if (StackPtr == 0) + else if (StackIdx == 0) { Done = true; } @@ -432,7 +446,9 @@ uint8 LC_EvaluateRPN(uint16 APNumber) default: if (RPNData < LC_MAX_WATCHPOINTS) { - RPNStack[StackPtr++] = LC_OperData.WRTPtr[RPNData].WatchResult; + RPNStack[StackIdx] = LC_OperData.WRTPtr[RPNData].WatchResult; + + StackIdx++; } else { @@ -447,7 +463,7 @@ uint8 LC_EvaluateRPN(uint16 APNumber) */ if ((Done == false) && (IllegalRPN == false) && (IllegalOperand == false)) { - if (RPNEquationPtr >= LC_MAX_RPN_EQU_SIZE) + if (RPNEquationIdx >= LC_MAX_RPN_EQU_SIZE) { IllegalRPN = true; } @@ -459,10 +475,10 @@ uint8 LC_EvaluateRPN(uint16 APNumber) { CFE_EVS_SendEvent(LC_INVALID_RPN_ERR_EID, CFE_EVS_EventType_ERROR, - "AP has illegal RPN expression: AP = %d, LastOperand = %d, StackPtr = %d", + "AP has illegal RPN expression: AP = %d, LastOperand = %d, StackIdx = %d", APNumber, - (int)(RPNEquationPtr - 1), - (int)StackPtr); + (int)(RPNEquationIdx - 1), + (int)StackIdx); EvalResult = LC_ACTION_ERROR; } diff --git a/fsw/src/lc_app.c b/fsw/src/lc_app.c index 94324f0..13e99cd 100644 --- a/fsw/src/lc_app.c +++ b/fsw/src/lc_app.c @@ -54,10 +54,10 @@ LC_AppData_t LC_AppData; void LC_AppMain(void) { - int32 Status = CFE_SUCCESS; - bool Initialized = false; - uint32 RunStatus = CFE_ES_RunStatus_APP_RUN; - CFE_SB_Buffer_t *BufPtr = NULL; + int32 Status; + bool Initialized; + uint32 RunStatus = CFE_ES_RunStatus_APP_RUN; + CFE_SB_Buffer_t *BufPtr = NULL; /* ** Performance Log, Start @@ -186,7 +186,7 @@ void LC_AppMain(void) CFE_Status_t LC_AppInit(void) { - CFE_Status_t Status = CFE_SUCCESS; + CFE_Status_t Status; /* ** Zero out the global data structures... @@ -241,7 +241,7 @@ CFE_Status_t LC_AppInit(void) CFE_Status_t LC_EvsInit(void) { - CFE_Status_t Status = CFE_SUCCESS; + CFE_Status_t Status; /* ** If an application event filter table is added @@ -269,7 +269,7 @@ CFE_Status_t LC_EvsInit(void) CFE_Status_t LC_SbInit(void) { - CFE_Status_t Status = CFE_SUCCESS; + CFE_Status_t Status; /* ** Initialize housekeeping packet... diff --git a/fsw/src/lc_watch.c b/fsw/src/lc_watch.c index 67e8bb9..1a4f3ef 100644 --- a/fsw/src/lc_watch.c +++ b/fsw/src/lc_watch.c @@ -135,7 +135,9 @@ void LC_CreateHashTable(void) if (CFE_SB_MsgId_Equal(LastMessageID, MessageID) && (WatchPtLink != (LC_WatchPtList_t *)NULL)) { /* WatchPtLink points to last link in list for this Message ID */ - WatchPtLink->Next = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount++]; + WatchPtLink->Next = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount]; + + LC_OperData.WatchpointCount++; /* Add new link to end of list, point to new last link */ WatchPtLink = WatchPtLink->Next; @@ -180,7 +182,9 @@ LC_WatchPtList_t *LC_AddWatchpoint(CFE_SB_MsgId_t MessageID) if (LC_OperData.HashTable[HashTableIndex] == (LC_MessageList_t *)NULL) { /* Get next unused MessageID linked list entry */ - MessageLink = &LC_OperData.MessageLinks[LC_OperData.MessageIDsCount++]; + MessageLink = &LC_OperData.MessageLinks[LC_OperData.MessageIDsCount]; + + LC_OperData.MessageIDsCount++; /* Set first (and only) link in this hash table entry linked list */ LC_OperData.HashTable[HashTableIndex] = MessageLink; @@ -202,9 +206,11 @@ LC_WatchPtList_t *LC_AddWatchpoint(CFE_SB_MsgId_t MessageID) if (MessageLink->Next == (LC_MessageList_t *)NULL) { /* Reached end of list without finding MessageID */ - MessageLink->Next = &LC_OperData.MessageLinks[LC_OperData.MessageIDsCount++]; + MessageLink->Next = &LC_OperData.MessageLinks[LC_OperData.MessageIDsCount]; MessageLink = MessageLink->Next; + LC_OperData.MessageIDsCount++; + /* Add link with this MessageID (will exit loop) */ MessageLink->MessageID = MessageID; @@ -237,7 +243,9 @@ LC_WatchPtList_t *LC_AddWatchpoint(CFE_SB_MsgId_t MessageID) if (MessageLink->WatchPtList == (LC_WatchPtList_t *)NULL) { /* Get next unused watchpoint linked list entry */ - WatchPtLink = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount++]; + WatchPtLink = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount]; + + LC_OperData.WatchpointCount++; /* Set the start (and only) link in the watchpoint link list */ MessageLink->WatchPtList = WatchPtLink; @@ -253,8 +261,10 @@ LC_WatchPtList_t *LC_AddWatchpoint(CFE_SB_MsgId_t MessageID) } /* Add the new watchpoint link to the end of the list */ - WatchPtLink->Next = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount++]; + WatchPtLink->Next = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount]; WatchPtLink = WatchPtLink->Next; + + LC_OperData.WatchpointCount++; } /* Return pointer to last link in watchpoint linked list */ @@ -785,9 +795,9 @@ bool LC_WPOffsetValid(uint16 WatchIndex, const CFE_SB_Buffer_t *BufPtr) { size_t MsgLength = 0; uint32 Offset; - uint32 NumOfDataBytes = 0; - bool OffsetValid = true; - CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; + uint32 NumOfDataBytes; + bool OffsetValid = true; + CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID; /* ** Check the message length against the watchpoint @@ -907,7 +917,7 @@ bool LC_GetSizedWPData(uint16 WatchIndex, const uint8 *WPDataPtr, uint32 *SizedD { case LC_DATA_WATCH_BYTE: TempBuffer.Signed8 = *WPDataPtr; - *SizedDataPtr = TempBuffer.Signed8; /* Extend signed 8 bit value to 32 bits */ + *SizedDataPtr = (uint32)TempBuffer.Signed8; /* Extend signed 8 bit value to 32 bits */ break; case LC_DATA_WATCH_UBYTE: diff --git a/unit-test/lc_action_tests.c b/unit-test/lc_action_tests.c index 8aba324..506d398 100644 --- a/unit-test/lc_action_tests.c +++ b/unit-test/lc_action_tests.c @@ -1106,7 +1106,7 @@ void LC_EvaluateRPN_Test_DefaultIllegalRPN(void) snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "AP has illegal RPN expression: AP = %%d, LastOperand = %%d, StackPtr = %%d"); + "AP has illegal RPN expression: AP = %%d, LastOperand = %%d, StackIdx = %%d"); LC_OperData.ADTPtr[APNumber].RPNEquation[0] = LC_MAX_WATCHPOINTS; @@ -1135,7 +1135,7 @@ void LC_EvaluateRPN_Test_EndOfBufferWhenNotDone(void) snprintf(ExpectedEventString, CFE_MISSION_EVS_MAX_MESSAGE_LENGTH, - "AP has illegal RPN expression: AP = %%d, LastOperand = %%d, StackPtr = %%d"); + "AP has illegal RPN expression: AP = %%d, LastOperand = %%d, StackIdx = %%d"); for (i = 0; i < (sizeof(LC_OperData.ADTPtr[0].RPNEquation) / sizeof(LC_OperData.ADTPtr[0].RPNEquation[0])); i++) {