Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bef1be3
Fix #69, Resource leak in spacewire module due to unclosed file.
ivanperez-keera Apr 7, 2026
cfbe9ff
Fix #69, Resource leak in spacewire module due to unclosed file.
ivanperez-keera Apr 7, 2026
3b5e96f
Fix #69, Fix uninitialized variable in spacewire module.
ivanperez-keera Apr 7, 2026
8d805df
Fix #69, Fix uninitialized variable in spacewire module.
ivanperez-keera Apr 7, 2026
5ee8f94
Fix #69, Fix issue with data structure not being initialized.
ivanperez-keera Apr 7, 2026
3cb2df9
Fix #69, Correct array index access before limits check.
ivanperez-keera Apr 7, 2026
261865f
Fix #69, Change argument name in function implementation to match pro…
ivanperez-keera Apr 7, 2026
828d573
Fix #69, Fix 4 cases where local variables shadow outer variables.
ivanperez-keera Apr 7, 2026
79d269c
Fix #69, Supress warning related to parameter that can be made const.
ivanperez-keera Apr 7, 2026
a8190ec
Fix #69, Remove unused initial value for variable.
ivanperez-keera Apr 7, 2026
206d740
Fix #69, Change argument name in function prototype to match implemen…
ivanperez-keera Apr 7, 2026
8155563
Fix #69, Fix 7 issues related to argument names in headers not matchi…
ivanperez-keera Apr 7, 2026
d861203
Fix #69, Fix two argument names not matching name in function impleme…
ivanperez-keera Apr 7, 2026
6fd2d69
Fix #69, Remove unused initial value for variables.
ivanperez-keera Apr 7, 2026
050e57d
Fix #69, Remove unused initial value for variable.
ivanperez-keera Apr 7, 2026
ca5a912
Fix #69, Remove unused initial value for variables.
ivanperez-keera Apr 7, 2026
5f31f07
Fix #69, Remove unused initial value for variable.
ivanperez-keera Apr 7, 2026
d83bc5d
Fix #69, Remove unused initial value for variable.
ivanperez-keera Apr 7, 2026
e2db02b
Fix #69, Remove unused initial value for variable.
ivanperez-keera Apr 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions fsw/src/sbn_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,16 +502,16 @@ SBN_Status_t SBN_RecvNetMsgs(void)
// TODO: make configurable
for (MsgCnt = 0; MsgCnt < 100; MsgCnt++) /* read at most 100 messages from peer */
{
CFE_ProcessorID_t ProcessorID = 0;
CFE_SpacecraftID_t SpacecraftID = 0;
SBN_MsgType_t MsgType = 0;
SBN_MsgSz_t MsgSz = 0;
CFE_ProcessorID_t PeerProcessorID = 0;
CFE_SpacecraftID_t PeerSpacecraftID = 0;
SBN_MsgType_t PeerMsgType = 0;
SBN_MsgSz_t PeerMsgSz = 0;

memset(SBN.MsgBuffer, 0, sizeof(SBN.MsgBuffer));

SBN_Status =
Net->IfOps
->RecvFromPeer(Net, Peer, &MsgType, &MsgSz, &ProcessorID, &SpacecraftID, SBN.MsgBuffer);
->RecvFromPeer(Net, Peer, &PeerMsgType, &PeerMsgSz, &PeerProcessorID, &PeerSpacecraftID, SBN.MsgBuffer);

if (SBN_Status == SBN_IF_EMPTY)
{
Expand All @@ -520,7 +520,7 @@ SBN_Status_t SBN_RecvNetMsgs(void)

OS_GetLocalTime(&Peer->LastRecv);

SBN_Status = SBN_ProcessNetMsg(Net, MsgType, ProcessorID, SpacecraftID, MsgSz, SBN.MsgBuffer);
SBN_Status = SBN_ProcessNetMsg(Net, PeerMsgType, PeerProcessorID, PeerSpacecraftID, PeerMsgSz, SBN.MsgBuffer);

if (SBN_Status != SBN_SUCCESS)
{
Expand Down Expand Up @@ -713,7 +713,8 @@ void SBN_SendTask(void)
static SBN_Status_t CheckPeerPipes(void)
{
CFE_Status_t CFE_Status;
int ReceivedFlag = 0, iter = 0;
int ReceivedFlag;
int iter = 0;
CFE_MSG_Message_t *MsgPtr = NULL;
CFE_MSG_Size_t MsgSz = 0;
SBN_MsgSz_t SBN_MsgSz = 0;
Expand Down Expand Up @@ -1096,7 +1097,7 @@ static cpuaddr LoadConf_Module(SBN_Module_Entry_t *e, CFE_ES_ModuleID_t *ModuleI
*/
static SBN_ModuleIdx_t LoadConf_Filters(SBN_Module_Entry_t *FilterModules,
SBN_ModuleIdx_t FilterModuleCnt,
SBN_FilterInterface_t **ConfFilters,
SBN_FilterInterface_t **ConfFilters, // cppcheck-suppress constParameter
char ModuleNames[SBN_MAX_FILTERS_PER_PEER][SBN_MAX_MOD_NAME_LEN],
SBN_FilterInterface_t **Filters)
{
Expand All @@ -1105,7 +1106,7 @@ static SBN_ModuleIdx_t LoadConf_Filters(SBN_Module_Entry_t *FilterModules,

memset(FilterModules, 0, sizeof(*FilterModules) * FilterCnt);

for (i = 0; *ModuleNames[i] && i < SBN_MAX_FILTERS_PER_PEER; i++)
for (i = 0; i < SBN_MAX_FILTERS_PER_PEER && *ModuleNames[i]; i++)
{
SBN_ModuleIdx_t FilterIdx = 0;
for (FilterIdx = 0; FilterIdx < FilterModuleCnt; FilterIdx++)
Expand Down Expand Up @@ -1681,7 +1682,7 @@ void SBN_AppMain(void)
* @param[in] MsgType The type of the message (application data, SBN protocol)
* @param[in] ProcessorID The ProcessorID to send this message to.
* @param[in] SpacecraftID The SpacecraftID to send this message to.
* @param[in] MsgSize The size of the message (in bytes).
* @param[in] MsgSz The size of the message (in bytes).
* @param[in] Msg The message contents.
*
* @return SBN_SUCCESS on successful processing, SBN_ERROR otherwise
Expand All @@ -1690,7 +1691,7 @@ SBN_Status_t SBN_ProcessNetMsg(SBN_NetInterface_t *Net,
SBN_MsgType_t MsgType,
CFE_ProcessorID_t ProcessorID,
CFE_SpacecraftID_t SpacecraftID,
SBN_MsgSz_t MsgSize,
SBN_MsgSz_t MsgSz,
void *Msg)
{
static const char FAIL_PREFIX[] = "ERROR: could not process peer message:";
Expand Down
6 changes: 3 additions & 3 deletions fsw/src/sbn_cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
** \par Assumptions, External Events, and Notes:
** None
**
** \param [in] MessagePtr A #CFE_MSG_Message_t pointer that
** references the software bus message
** \param [in] MsgPtr A #CFE_MSG_Message_t pointer that
** references the software bus message
**
** \sa #CFE_SB_ReceiveBuffer
**
*************************************************************************/
void SBN_HandleCommand(CFE_MSG_Message_t *MessagePtr);
void SBN_HandleCommand(CFE_MSG_Message_t *MsgPtr);

/************************************************************************/
/** \brief Reset telemetry counters to zero
Expand Down
32 changes: 16 additions & 16 deletions fsw/src/sbn_pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,73 +80,73 @@
return Pack_Data(PackPtr, &D, sizeof(D));
} /* end Pack_MsgID() */

bool Unpack_Data(Pack_t *Pack, void *DataBuf, size_t Sz)
bool Unpack_Data(Pack_t *PackPtr, void *DataBuf, size_t Sz)
{
if (Pack->BufUsed + Sz > Pack->BufSz)
if (PackPtr->BufUsed + Sz > PackPtr->BufSz)
{
return false;
}

memcpy(DataBuf, (uint8 *)Pack->Buf + Pack->BufUsed, Sz);
memcpy(DataBuf, (uint8 *)PackPtr->Buf + PackPtr->BufUsed, Sz);

Pack->BufUsed += Sz;
PackPtr->BufUsed += Sz;

return true;
} /* end Unpack_Data() */

bool Unpack_UInt8(Pack_t *Pack, uint8 *DataBuf)
bool Unpack_UInt8(Pack_t *PackPtr, uint8 *DataBuf)
{
return Unpack_Data(Pack, DataBuf, sizeof(*DataBuf));
return Unpack_Data(PackPtr, DataBuf, sizeof(*DataBuf));
} /* end Unpack_UInt8() */

bool Unpack_UInt16(Pack_t *Pack, uint16 *DataBuf)
bool Unpack_UInt16(Pack_t *PackPtr, uint16 *DataBuf)
{
uint16 D;
if (!Unpack_Data(Pack, &D, sizeof(D)))
if (!Unpack_Data(PackPtr, &D, sizeof(D)))
{
return false;
}
*DataBuf = CFE_MAKE_BIG16(D);
return true;
} /* end Unpack_UInt16() */

bool Unpack_Int16(Pack_t *Pack, int16 *DataBuf)
bool Unpack_Int16(Pack_t *PackPtr, int16 *DataBuf)
{
int16 D;
if (!Unpack_Data(Pack, &D, sizeof(D)))
if (!Unpack_Data(PackPtr, &D, sizeof(D)))
{
return false;
}
*DataBuf = CFE_MAKE_BIG16(D);
return true;
} /* end Unpack_Int16() */

bool Unpack_UInt32(Pack_t *Pack, uint32 *DataBuf)
bool Unpack_UInt32(Pack_t *PackPtr, uint32 *DataBuf)
{
uint32 D;
if (!Unpack_Data(Pack, &D, sizeof(D)))
if (!Unpack_Data(PackPtr, &D, sizeof(D)))
{
return false;
}
*DataBuf = CFE_MAKE_BIG32(D);
return true;
} /* end Unpack_UInt32() */

bool Unpack_Time(Pack_t *Pack, OS_time_t *DataBuf)
bool Unpack_Time(Pack_t *PackPtr, OS_time_t *DataBuf)
{
OS_time_t D;
if (!Unpack_Data(Pack, &D, sizeof(D)))
if (!Unpack_Data(PackPtr, &D, sizeof(D)))
{
return false;
}
*DataBuf = D;
return true;
} /* end Unpack_Time() */

bool Unpack_MsgID(Pack_t *Pack, CFE_SB_MsgId_t *DataBuf)
bool Unpack_MsgID(Pack_t *PackPtr, CFE_SB_MsgId_t *DataBuf)
{
uint32 D;
if (!Unpack_Data(Pack, &D, sizeof(D)))
if (!Unpack_Data(PackPtr, &D, sizeof(D)))
{
return false;
}
Expand Down
14 changes: 8 additions & 6 deletions fsw/src/sbn_subs.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
SBN_Status_t SBN_SendSubsRequests(void)
{
CFE_Status_t CFE_Status = CFE_SUCCESS;
CFE_Status_t CFE_Status;
CFE_MSG_CommandHeader_t CmdMsg;

/* Turn on SB subscription reporting */
Expand Down Expand Up @@ -207,7 +207,8 @@ static SBN_Status_t ProcessLocalSub(CFE_SB_MsgId_t MsgID, CFE_SB_Qos_t QoS)
SBN.Subs[SBN.SubCnt].QoS = QoS;
SBN.SubCnt++;

int NetIdx = 0, PeerIdx = 0;
int NetIdx;
int PeerIdx;
for (NetIdx = 0; NetIdx < SBN.NetCnt; NetIdx++)
{
SBN_NetInterface_t *Net = &SBN.Nets[NetIdx];
Expand Down Expand Up @@ -240,7 +241,7 @@ static SBN_Status_t ProcessLocalSub(CFE_SB_MsgId_t MsgID, CFE_SB_Qos_t QoS)
*/
static SBN_Status_t ProcessLocalUnsub(CFE_SB_MsgId_t MsgID)
{
SBN_Status_t SBN_Status = SBN_SUCCESS;
SBN_Status_t SBN_Status;
int SubIdx;

/* find idx of matching subscription */
Expand Down Expand Up @@ -273,7 +274,8 @@ static SBN_Status_t ProcessLocalUnsub(CFE_SB_MsgId_t MsgID)

/* send unsubscription to all peers if peer state is heartbeating and */
/* only if no more local subs (InUseCtr = 0) */
int NetIdx = 0, PeerIdx = 0;
int NetIdx;
int PeerIdx;
for (NetIdx = 0; NetIdx < SBN.NetCnt; NetIdx++)
{
SBN_NetInterface_t *Net = &SBN.Nets[NetIdx];
Expand Down Expand Up @@ -451,7 +453,7 @@ static SBN_Status_t ProcessSubFromPeer(SBN_PeerInterface_t *Peer, CFE_SB_MsgId_t
*/
SBN_Status_t SBN_ProcessSubsFromPeer(SBN_PeerInterface_t *Peer, void *Msg)
{
SBN_Status_t SBN_Status = SBN_SUCCESS;
SBN_Status_t SBN_Status;
Pack_t Pack;
char VersionHash[SBN_IDENT_LEN];

Expand Down Expand Up @@ -644,7 +646,7 @@ SBN_Status_t SBN_ProcessAllSubscriptions(CFE_SB_AllSubscriptionsTlm_t *Ptr)
SBN_Status_t SBN_RemoveAllSubsFromPeer(SBN_PeerInterface_t *Peer)
{
int i = 0;
CFE_Status_t CFE_Status = CFE_SUCCESS;
CFE_Status_t CFE_Status;

for (i = 0; i < Peer->SubCnt; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions fsw/src/sbn_subs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

SBN_Status_t SBN_SendLocalSubsToPeer(SBN_PeerInterface_t *Peer);
SBN_Status_t SBN_CheckSubscriptionPipe(void);
SBN_Status_t SBN_ProcessSubsFromPeer(SBN_PeerInterface_t *Peer, void *submsg);
SBN_Status_t SBN_ProcessUnsubsFromPeer(SBN_PeerInterface_t *Peer, void *submsg);
SBN_Status_t SBN_ProcessSubsFromPeer(SBN_PeerInterface_t *Peer, void *Msg);
SBN_Status_t SBN_ProcessUnsubsFromPeer(SBN_PeerInterface_t *Peer, void *Msg);
SBN_Status_t SBN_ProcessAllSubscriptions(CFE_SB_AllSubscriptionsTlm_t *Ptr);
SBN_Status_t SBN_RemoveAllSubsFromPeer(SBN_PeerInterface_t *Peer);
SBN_Status_t SBN_SendSubsRequests(void);
Expand Down
8 changes: 6 additions & 2 deletions modules/protocol/spacewire/fsw/src/spw_sbn_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ int SPW_GetData(SPW_SBNEntry_t spwEntry, void *dataBuffer, int dataSz, int *erro
dataRead = fread(dataBuffer, 1, dataSz, fp);
&error = ferror(fp);

fclose(fp);

if (error == SPW_FREAD_NO_ERROR)
{
return dataRead;
Expand Down Expand Up @@ -140,6 +142,8 @@ int SPW_SendData(SPW_SBNEntry_t spwEntry, void *dataBuffer, int dataSz, int *err
dataRead = fwrite(dataBuffer, 1, dataSz, fp);
&error = ferror(fp);

fclose(fp);

if (error == SPW_FREAD_NO_ERROR)
{
return dataRead;
Expand All @@ -159,7 +163,7 @@ int32 SBN_CheckForSPWNetProtoMsg(SBN_InterfaceData *Peer, SBN_NetProtoMsg_t *Pro
{
SPW_SBNPeerData_t *peer = Peer->PeerData;
int linkStatus, dataRead;
int error;
int error = SPW_FREAD_NO_ERROR;

dataRead = SPW_GetData(peer->spwEntry, (*void)ProtoMsgBuf, sizeof(SBN_NetProtoMsg_t), &error);
if (dataRead > 0 && error == SPW_FREAD_NO_ERROR)
Expand Down Expand Up @@ -195,7 +199,7 @@ int SBN_SPWRcvMsg(SBN_InterfaceData *Peer, NetDataUnion *DataMsgBuf)
{
SPW_SBNPeerData_t *peer = Peer->PeerData;
int dataRead;
int error;
int error = SPW_FREAD_NO_ERROR;

dataRead = SPW_GetData(peer->spwEntry, (*void)ProtoMsgBuf, SBN_MAX_MSG_SZ, &error);

Expand Down
2 changes: 2 additions & 0 deletions ut-stubs/sbn_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ bool SBN_UnpackMsg(void *SBNBuf,
uint32 status = 0;
SBN_Unpack_Buf_t p;

memset(&p, 0, sizeof(p));

status = UT_DEFAULT_IMPL(SBN_UnpackMsg);

if (status >= 0)
Expand Down
Loading