Fix #99, Fill in Name variable to avoid being used uninitialized#100
Fix #99, Fill in Name variable to avoid being used uninitialized#100thnkslprpt wants to merge 1 commit intonasa:mainfrom
Name variable to avoid being used uninitialized#100Conversation
c4e87dc to
4b79eaf
Compare
| Name[sizeof(Name) - 1] = '\0'; | ||
|
|
||
| if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) | ||
| if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) |
Check warning
Code scanning / CodeQL
Side effect in a Boolean expression
| CS_AppData.HkPacket.Payload.OneShotInProgress == false) | ||
| { | ||
| /* make sure the entry is a valid number and is defined in the table */ | ||
| if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) |
Check warning
Code scanning / CodeQL
Side effect in a Boolean expression
|
|
||
| CFE_EVS_SendEvent(CS_DISABLE_APP_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, | ||
| "Checksumming of app %s is Disabled", Name); | ||
| if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) |
Check warning
Code scanning / CodeQL
Side effect in a Boolean expression
| "Checksumming of app %s is Disabled", Name); | ||
|
|
||
| CS_AppData.HkPacket.Payload.CmdCounter++; | ||
| if (CS_GetAppDefTblEntryByName(&DefinitionEntry, Name)) |
Check warning
Code scanning / CodeQL
Side effect in a Boolean expression
|
|
||
| CFE_EVS_SendEvent(CS_ENABLE_APP_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, | ||
| "Checksumming of app %s is Enabled", Name); | ||
| if (CS_GetAppResTblEntryByName(&ResultsEntry, Name)) |
Check warning
Code scanning / CodeQL
Side effect in a Boolean expression
| CS_AppData.HkPacket.Payload.OneShotInProgress == false) | ||
| { | ||
| /* make sure the entry is a valid number and is defined in the table */ | ||
| if (CS_GetTableResTblEntryByName(&ResultsEntry, Name)) |
Check warning
Code scanning / CodeQL
Side effect in a Boolean expression
|
|
||
| CFE_EVS_SendEvent(CS_DISABLE_TABLES_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, | ||
| "Checksumming of table %s is Disabled", Name); | ||
| if (CS_GetTableResTblEntryByName(&ResultsEntry, Name)) |
Check warning
Code scanning / CodeQL
Side effect in a Boolean expression
| "Checksumming of table %s is Disabled", Name); | ||
|
|
||
| CS_AppData.HkPacket.Payload.CmdCounter++; | ||
| if (CS_GetTableDefTblEntryByName(&DefinitionEntry, Name)) |
Check warning
Code scanning / CodeQL
Side effect in a Boolean expression
|
|
||
| CFE_EVS_SendEvent(CS_ENABLE_TABLES_NAME_INF_EID, CFE_EVS_EventType_INFORMATION, | ||
| "Checksumming of table %s is Enabled", Name); | ||
| if (CS_GetTableResTblEntryByName(&ResultsEntry, Name)) |
Check warning
Code scanning / CodeQL
Side effect in a Boolean expression
| "Checksumming of table %s is Enabled", Name); | ||
|
|
||
| CS_AppData.HkPacket.Payload.CmdCounter++; | ||
| if (CS_GetTableDefTblEntryByName(&DefinitionEntry, Name)) |
Check warning
Code scanning / CodeQL
Side effect in a Boolean expression
4b79eaf to
6f88718
Compare
6f88718 to
951d776
Compare
Checklist
Describe the contribution
Namevariable used in events before being filled in #99strncpyto fill in theNamevariable before theifblock, in order to ensure it is filled in for the final error event as well.Minor changes:
Baselinevariable inCS_ReportBaselineAppCmd,CS_ReportBaselineEntryIDEepromCmd,CS_ReportBaselineEntryIDMemoryCmdandCS_ReportBaselineTablesCmdonly used once in these functions - simplifies to use the value directly and avoid the extra variable (happy to separate out these changes into a separate PR if more suitable).CS_ReportBaselineEntryIDEepromCmd&CS_ReportBaselineEntryIDEepromCmdtwo additional simplifications look reasonable:ResultsEntrycan be removedCS_STATE_UNDEFINEDtoStatecan be done at initialization, simplifying theif/elsein the error conditionTesting performed
GitHub CI actions all passing successfully (incl. Build + Run, Unit/Functional Tests etc.).
Expected behavior changes
Namevariable will be filled in in all use-cases.Unnecessary variables are removed, which simplifies the code and eases maintenance/testing.
System(s) tested on
Debian 12 using the current main branch of cFS bundle.
Contributor Info
Avi Weiss @thnkslprpt