Skip to content

Commit daf86b9

Browse files
committed
Merge pull request #2515 from jphickey:fix-2514-msg-api-struct
Fix #2514, change CFE_MSG_Message from union to struct
2 parents 8cdad66 + 777feec commit daf86b9

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

modules/core_api/fsw/inc/cfe_msg_api_typedefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ typedef enum CFE_MSG_PlaybackFlag
9999
/**
100100
* \brief cFS generic base message
101101
*/
102-
typedef union CFE_MSG_Message CFE_MSG_Message_t;
102+
typedef struct CFE_MSG_Message CFE_MSG_Message_t;
103103

104104
/**
105105
* \brief cFS command header

modules/core_api/ut-stubs/src/cfe_sb_handlers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ void UT_DefaultHandler_CFE_SB_GetUserData(void *UserObj, UT_EntryKey_t FuncKey,
348348
if (UT_Stub_CopyToLocal(UT_KEY(CFE_SB_GetUserData), &Result, sizeof(Result)) != sizeof(Result))
349349
{
350350
BytePtr = (uint8 *)MsgPtr;
351-
if ((MsgPtr->Byte[0] & 0x10) != 0)
351+
if ((*BytePtr & 0x10) != 0)
352352
{
353353
HdrSize = sizeof(CFE_MSG_CommandHeader_t);
354354
}

modules/core_private/ut-stubs/src/ut_support.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,13 +342,15 @@ int32 UT_SoftwareBusSnapshotHook(void *UserObj, int32 StubRetcode, uint32 CallCo
342342
{
343343
UT_SoftwareBusSnapshot_Entry_t *Snapshot = UserObj;
344344
const CFE_MSG_Message_t * MsgPtr = UT_Hook_GetArgValueByName(Context, "MsgPtr", CFE_MSG_Message_t *);
345+
const uint8_t * BytePtr;
345346

346347
if (MsgPtr != NULL && Snapshot != NULL)
347348
{
348349
++Snapshot->Count;
349350
if (Snapshot->SnapshotSize > 0 && Snapshot->SnapshotBuffer != NULL)
350351
{
351-
memcpy(Snapshot->SnapshotBuffer, &MsgPtr->Byte[Snapshot->SnapshotOffset], Snapshot->SnapshotSize);
352+
BytePtr = (const uint8 *)MsgPtr;
353+
memcpy(Snapshot->SnapshotBuffer, &BytePtr[Snapshot->SnapshotOffset], Snapshot->SnapshotSize);
352354
}
353355
}
354356

@@ -535,7 +537,7 @@ uint16 UT_GetNumEventsSent(void)
535537
*/
536538
void UT_DisplayPkt(CFE_MSG_Message_t *MsgPtr, size_t size)
537539
{
538-
uint8 *BytePtr = MsgPtr->Byte;
540+
uint8 *BytePtr = (uint8 *)MsgPtr;
539541
size_t i;
540542
size_t BufSize = UT_MAX_MESSAGE_LENGTH;
541543
char DisplayMsg[UT_MAX_MESSAGE_LENGTH];

modules/msg/fsw/src/cfe_msg_sechdr_checksum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
CFE_MSG_Checksum_t CFE_MSG_ComputeCheckSum(const CFE_MSG_Message_t *MsgPtr)
3535
{
3636
CFE_MSG_Size_t PktLen = 0;
37-
const uint8 * BytePtr = MsgPtr->Byte;
37+
const uint8 * BytePtr = (const uint8 *)MsgPtr;
3838
CFE_MSG_Checksum_t chksum = 0xFF;
3939

4040
/* Message already checked, no error case reachable */

modules/msg/option_inc/default_cfe_msg_hdr_pri.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ typedef struct
8989
*
9090
* This provides the definition of CFE_MSG_Message_t
9191
*/
92-
union CFE_MSG_Message
92+
struct CFE_MSG_Message
9393
{
94-
CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS Header (Pri or Pri + Ext) */
95-
uint8 Byte[sizeof(CCSDS_SpacePacket_t)]; /**< \brief Byte level access */
94+
CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS Header (Pri or Pri + Ext) */
9695
};
9796

9897
/**

modules/msg/option_inc/default_cfe_msg_hdr_priext.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,9 @@ typedef struct
9696
/**
9797
* \brief cFS generic base message
9898
*/
99-
union CFE_MSG_Message
99+
struct CFE_MSG_Message
100100
{
101-
CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS Header (Pri or Pri + Ext) */
102-
uint8 Byte[sizeof(CCSDS_SpacePacket_t)]; /**< \brief Byte level access */
101+
CCSDS_SpacePacket_t CCSDS; /**< \brief CCSDS Header (Pri or Pri + Ext) */
103102
};
104103

105104
/**

0 commit comments

Comments
 (0)