fix: initialize variables flagged as uninitialized by static analysis#2761
Open
stark256-spec wants to merge 1 commit into
Open
fix: initialize variables flagged as uninitialized by static analysis#2761stark256-spec wants to merge 1 commit into
stark256-spec wants to merge 1 commit into
Conversation
Static analyzer reported several variables that were passed to functions as output parameters without being explicitly initialized first (issue nasa#2736). While not runtime bugs (the functions properly initialize these outputs), adding explicit initialization eliminates false-positive SA warnings and follows defensive programming practice. Changes: - cfe_tbl_dump.c: FileDescriptor = OS_OBJECT_ID_UNDEFINED in both CFE_TBL_TxnOpenTableDumpFile and CFE_TBL_WriteSnapshotToFile - cfe_sb_priv.c: BufDscPtr = NULL in CFE_SB_ReceiveTxn_PipeHandler - es_cds_test.c: IdByName = CFE_ES_CDS_BAD_HANDLE in TestCDSName - es_resource_id_test.c: TestAppIdx = 0 in TestAppIDToIndex, CounterIdx = 0 in TestCounterIDToIndex - sb_pipe_mang_test.c: PipeNameBuf = {0} in TestPipeName Fixes nasa#2736
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2736
Static analyzer reported several variables passed to functions as output parameters without being explicitly initialized at the point of declaration.
These are not runtime bugs — the called functions properly initialize the outputs via pointer — but the SA tool cannot prove this, generating false-positive warnings. Adding explicit initialization at declaration eliminates the warnings and follows defensive programming practice.
Changes
cfe_tbl_dump.c(TxnOpenTableDumpFile)FileDescriptorOS_OBJECT_ID_UNDEFINEDcfe_tbl_dump.c(WriteSnapshotToFile)FileDescriptorOS_OBJECT_ID_UNDEFINEDcfe_sb_priv.c(ReceiveTxn_PipeHandler)BufDscPtrNULLes_cds_test.c(TestCDSName)IdByNameCFE_ES_CDS_BAD_HANDLEes_resource_id_test.c(TestAppIDToIndex)TestAppIdx0es_resource_id_test.c(TestCounterIDToIndex)CounterIdx0sb_pipe_mang_test.c(TestPipeName)PipeNameBuf{0}Test plan