Skip to content

Commit 8913ce5

Browse files
author
Jacob Hageman
committed
Fix #1204, Use mask instead of cast to alter value
1 parent 7f8e475 commit 8913ce5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

modules/msg/fsw/src/cfe_msg_msgid_v1.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ int32 CFE_MSG_SetMsgId(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId)
6565
return CFE_MSG_BAD_ARGUMENT;
6666
}
6767

68-
MsgPtr->CCSDS.Pri.StreamId[0] = (uint8)(msgidval >> 8);
69-
MsgPtr->CCSDS.Pri.StreamId[1] = (uint8)(msgidval);
68+
/* Shift and mask bytes to be endian agnostic */
69+
MsgPtr->CCSDS.Pri.StreamId[0] = (msgidval >> 8) & 0xFF;
70+
MsgPtr->CCSDS.Pri.StreamId[1] = msgidval & 0xFF;
7071

7172
return CFE_SUCCESS;
7273
}

0 commit comments

Comments
 (0)