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

CFE_ES_GenPoolInitialize: Error if AlignSize is not a power of 2 #1346

Closed
skliper opened this issue Apr 14, 2021 · 0 comments · Fixed by #1372 or #1431
Closed

CFE_ES_GenPoolInitialize: Error if AlignSize is not a power of 2 #1346

skliper opened this issue Apr 14, 2021 · 0 comments · Fixed by #1372 or #1431
Assignees
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Apr 14, 2021

Is your feature request related to a problem? Please describe.
CFE_ES_GenPoolInitialize handles when AlignSize isn't a power of 2, but may be more appropriate as an error:

/*
* Convert alignment to a bit mask.
* This sets all LSBs if the passed in value was not actually a power of 2.
*/
if (AlignSize <= 1)
{
AlignMask = 0;
}
else
{
AlignMask = AlignSize - 1;
AlignMask |= AlignMask >> 1;
AlignMask |= AlignMask >> 2;
AlignMask |= AlignMask >> 4;
AlignMask |= AlignMask >> 8;
AlignMask |= AlignMask >> 16;
}

Describe the solution you'd like
Analyze, make it an error or document why it's ok as-is for future reference

Describe alternatives you've considered
None

Additional context
Code review

Requester Info
Jacob Hageman - NASA/GSFC

@skliper skliper added this to the 7.0.0 milestone Apr 14, 2021
jphickey added a commit to jphickey/cFE that referenced this issue Apr 16, 2021
Instead of "fixing" the alignment mask, return an error if the
passed-in value is not actually a power of two.

In ES this only gets passed from two possible sources: one is
hardcoded (4) and the other is sourced from the ALIGN_OF macro.
astrogeco added a commit that referenced this issue Apr 28, 2021
Fix #1346, error if alignment size not a power of two
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants