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 #1365, assert CFE_RESOURCEID_MAX is a bitmask #1371

Merged
Merged
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
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