Skip to content

Commit

Permalink
Fix #2118, Endian macro mask before shift to avoid shift overflow war…
Browse files Browse the repository at this point in the history
…ning
  • Loading branch information
skliper committed Jun 14, 2022
1 parent 10898c9 commit 41897e1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/core_api/fsw/inc/cfe_endian.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
#define CFE_MAKE_BIG16(n) (n)
#define CFE_MAKE_BIG32(n) (n)
#else
#define CFE_MAKE_BIG16(n) ((((n) << 8) & 0xFF00) | (((n) >> 8) & 0x00FF))
#define CFE_MAKE_BIG16(n) ((((n) & 0x00FF) << 8) | (((n) & 0xFF00) >> 8))
#define CFE_MAKE_BIG32(n) \
((((n) << 24) & 0xFF000000) | (((n) << 8) & 0x00FF0000) | (((n) >> 8) & 0x0000FF00) | (((n) >> 24) & 0x000000FF))
((((n) & 0x000000FF) << 24) | (((n) & 0x0000FF00) << 8) | (((n) & 0x00FF0000) >> 8) | (((n) & 0xFF000000) >> 24))
#endif

#endif /* CFE_ENDIAN_H */

0 comments on commit 41897e1

Please sign in to comment.