Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2039, Replace CFE_SB_ValueToMsgId(0) with CFE_SB_INVALID_MSG_ID #2042

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion modules/cfe_testcase/src/message_id_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void TestMsgId(void)
void TestGetTypeFromMsgId(void)
{
UtPrintf("Testing: CFE_MSG_GetTypeFromMsgId");
CFE_SB_MsgId_t msgid = CFE_SB_ValueToMsgId(0);
CFE_SB_MsgId_t msgid = CFE_SB_INVALID_MSG_ID;
CFE_MSG_Type_t msgtype;
int32 status;

Expand Down
4 changes: 2 additions & 2 deletions modules/cfe_testcase/src/msg_api_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void TestMsgApiBasic(void)
msgId = CFE_SB_ValueToMsgId(1);

/* test msg-init */
UtAssert_INT32_EQ(CFE_MSG_Init(NULL, CFE_SB_ValueToMsgId(0), sizeof(cmd)), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_Init(NULL, CFE_SB_INVALID_MSG_ID, sizeof(cmd)), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_Init(CFE_MSG_PTR(cmd), msgId, 0), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(
CFE_MSG_Init(CFE_MSG_PTR(cmd), CFE_SB_ValueToMsgId(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1), sizeof(cmd)),
Expand Down Expand Up @@ -139,7 +139,7 @@ void TestMsgApiAdvanced(void)
CFE_MSG_SequenceCount_t seqCnt;

memset(&cmd, 0xFF, sizeof(cmd));
msgId = CFE_SB_ValueToMsgId(0);
msgId = CFE_SB_INVALID_MSG_ID;

UtAssert_INT32_EQ(CFE_MSG_Init(CFE_MSG_PTR(cmd), msgId, sizeof(cmd)), CFE_SUCCESS);

Expand Down
2 changes: 1 addition & 1 deletion modules/msg/ut-coverage/test_cfe_msg_ccsdsext.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void Test_MSG_Init_Ext(void)

/* Get msgid version by checking if msgid sets "has secondary" field*/
memset(&msg, 0xFF, sizeof(msg));
CFE_UtAssert_SUCCESS(CFE_MSG_SetMsgId(&msg, CFE_SB_ValueToMsgId(0)));
CFE_UtAssert_SUCCESS(CFE_MSG_SetMsgId(&msg, CFE_SB_INVALID_MSG_ID));
CFE_UtAssert_SUCCESS(CFE_MSG_GetHasSecondaryHeader(&msg, &hassec));
is_v1 = !hassec;

Expand Down
4 changes: 2 additions & 2 deletions modules/msg/ut-coverage/test_cfe_msg_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ void Test_MSG_Init(void)
bool is_v1;

UtPrintf("Bad parameter tests, Null pointer, invalid size, invalid msgid");
UtAssert_INT32_EQ(CFE_MSG_Init(NULL, CFE_SB_ValueToMsgId(0), sizeof(cmd)), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_Init(CFE_MSG_PTR(cmd), CFE_SB_ValueToMsgId(0), 0), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_Init(NULL, CFE_SB_INVALID_MSG_ID, sizeof(cmd)), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(CFE_MSG_Init(CFE_MSG_PTR(cmd), CFE_SB_INVALID_MSG_ID, 0), CFE_MSG_BAD_ARGUMENT);
UtAssert_INT32_EQ(
CFE_MSG_Init(CFE_MSG_PTR(cmd), CFE_SB_ValueToMsgId(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1), sizeof(cmd)),
CFE_MSG_BAD_ARGUMENT);
Expand Down
2 changes: 1 addition & 1 deletion modules/msg/ut-coverage/test_cfe_msg_msgid_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
void Test_MSG_GetTypeFromMsgId(void)
{
CFE_MSG_Message_t msg;
CFE_SB_MsgId_t msgid = CFE_SB_ValueToMsgId(0);
CFE_SB_MsgId_t msgid = CFE_SB_INVALID_MSG_ID;
CFE_MSG_Type_t actual = CFE_MSG_Type_Invalid;

UtPrintf("Bad parameter tests, Null pointer");
Expand Down
6 changes: 3 additions & 3 deletions modules/sbr/ut-coverage/test_cfe_sbr_map_direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ void Test_SBR_Map_Direct(void)
uint32 i;

UtPrintf("Invalid msg checks");
UtAssert_INT32_EQ(CFE_SBR_SetRouteId(CFE_SB_ValueToMsgId(0), CFE_SBR_ValueToRouteId(0)), 0);
UtAssert_BOOL_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_ValueToMsgId(0))));
UtAssert_INT32_EQ(CFE_SBR_SetRouteId(CFE_SB_INVALID_MSG_ID, CFE_SBR_ValueToRouteId(0)), 0);
UtAssert_BOOL_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_INVALID_MSG_ID)));

UtPrintf("Initialize map");
CFE_SBR_Init_Map();
Expand Down Expand Up @@ -83,7 +83,7 @@ void Test_SBR_Map_Direct(void)

UtPrintf("Set/Get a range of ids ");
routeid = CFE_SBR_ValueToRouteId(CFE_PLATFORM_SB_MAX_MSG_IDS + 1);
msgid = CFE_SB_ValueToMsgId(0);
msgid = CFE_SB_INVALID_MSG_ID;
UtAssert_INT32_EQ(CFE_SBR_SetRouteId(msgid, routeid), 0);
UtAssert_INT32_EQ(CFE_SBR_GetRouteId(msgid).RouteId, routeid.RouteId);

Expand Down
6 changes: 3 additions & 3 deletions modules/sbr/ut-coverage/test_cfe_sbr_map_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ void Test_SBR_Map_Hash(void)
uint32 collisions;

UtPrintf("Invalid msg checks");
UtAssert_INT32_EQ(CFE_SBR_SetRouteId(CFE_SB_ValueToMsgId(0), CFE_SBR_ValueToRouteId(0)), 0);
UtAssert_BOOL_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_ValueToMsgId(0))));
UtAssert_INT32_EQ(CFE_SBR_SetRouteId(CFE_SB_INVALID_MSG_ID, CFE_SBR_ValueToRouteId(0)), 0);
UtAssert_BOOL_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_GetRouteId(CFE_SB_INVALID_MSG_ID)));

UtPrintf("Initialize routing and map");
CFE_SBR_Init();
Expand Down Expand Up @@ -102,7 +102,7 @@ void Test_SBR_Map_Hash(void)

/* Note AddRoute required for hash logic to work since it depends on MsgId in routing table */
UtPrintf("Add routes and check with a rollover and a skip");
msgid[0] = CFE_SB_ValueToMsgId(0);
msgid[0] = CFE_SB_INVALID_MSG_ID;
msgid[1] = Test_SBR_Unhash(0xFFFFFFFF);
msgid[2] = Test_SBR_Unhash(0x7FFFFFFF);
routeid[0] = CFE_SBR_AddRoute(msgid[0], &collisions);
Expand Down
6 changes: 3 additions & 3 deletions modules/sbr/ut-coverage/test_cfe_sbr_route_unsorted.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ void Test_SBR_Route_Unsort_General(void)
CFE_SBR_Init();

UtPrintf("Invalid msg checks");
UtAssert_BOOL_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_AddRoute(CFE_SB_ValueToMsgId(0), NULL)));
UtAssert_BOOL_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_AddRoute(CFE_SB_ValueToMsgId(0), &collisions)));
UtAssert_BOOL_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_AddRoute(CFE_SB_INVALID_MSG_ID, NULL)));
UtAssert_BOOL_FALSE(CFE_SBR_IsValidRouteId(CFE_SBR_AddRoute(CFE_SB_INVALID_MSG_ID, &collisions)));
UtAssert_INT32_EQ(collisions, 0);

/*
Expand Down Expand Up @@ -159,7 +159,7 @@ void Test_SBR_Route_Unsort_GetSet(void)
UtAssert_INT32_EQ(count, 0);

UtPrintf("Add routes and initialize values for testing");
msgid[0] = CFE_SB_ValueToMsgId(0);
msgid[0] = CFE_SB_INVALID_MSG_ID;
msgid[1] = CFE_SB_ValueToMsgId(1);
msgid[2] = CFE_SB_ValueToMsgId(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID);

Expand Down
2 changes: 1 addition & 1 deletion modules/tbl/fsw/src/cfe_tbl_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void CFE_TBL_InitData(void)
sizeof(CFE_TBL_Global.TblRegPacket));

/* Message ID is set when sent, so OK as 0 here */
CFE_MSG_Init(CFE_MSG_PTR(CFE_TBL_Global.NotifyMsg.CommandHeader), CFE_SB_ValueToMsgId(0),
CFE_MSG_Init(CFE_MSG_PTR(CFE_TBL_Global.NotifyMsg.CommandHeader), CFE_SB_INVALID_MSG_ID,
sizeof(CFE_TBL_Global.NotifyMsg));
}

Expand Down