Skip to content

Commit

Permalink
Merge pull request #1371 from jphickey/fix-1365-resourceid-max
Browse files Browse the repository at this point in the history
Fix #1365, assert CFE_RESOURCEID_MAX is a bitmask
  • Loading branch information
astrogeco authored Apr 28, 2021
2 parents f6c9974 + da86146 commit 68f83b1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/resourceid/fsw/src/cfe_resourceid_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
#include "cfe_resourceid.h"
#include "cfe_resourceid_basevalue.h"

/*
* The "CFE_RESOURCEID_MAX" limit is used as both a numeric maximum as well
* as a mask to separate the serial number bits from the base value bits.
*
* This sanity checks that the value is one less than a power of two so it
* works as a mask and the logic in this file works as expected.
*/
CompileTimeAssert(((CFE_RESOURCEID_MAX + 1) & CFE_RESOURCEID_MAX) == 0, CFE_RESOURCEID_MAX_BITMASK);

/*********************************************************************/
/*
* CFE_ResourceId_GetBase
Expand Down

0 comments on commit 68f83b1

Please sign in to comment.