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

Shift overflow compiler warning in endian macros #2118

Closed
skliper opened this issue Jun 14, 2022 · 0 comments · Fixed by #2119
Closed

Shift overflow compiler warning in endian macros #2118

skliper opened this issue Jun 14, 2022 · 0 comments · Fixed by #2119
Assignees
Milestone

Comments

@skliper
Copy link
Contributor

skliper commented Jun 14, 2022

Is your feature request related to a problem? Please describe.

cfe/modules/core_api/fsw/inc/cfe_endian.h:66:12: error: result of '13398 << 24' requires 39 bits to represent, but 'int' only has 32 bits [-Werror=shift-overflow=]
((((n) << 24) & 0xFF000000) | (((n) << 8) & 0x00FF0000) | (((n) >> 8) & 0x0000FF00) | (((n) >> 24) & 0x000000FF))

From:

#define CFE_MAKE_BIG16(n) ((((n) << 8) & 0xFF00) | (((n) >> 8) & 0x00FF))
#define CFE_MAKE_BIG32(n) \
((((n) << 24) & 0xFF000000) | (((n) << 8) & 0x00FF0000) | (((n) >> 8) & 0x0000FF00) | (((n) >> 24) & 0x000000FF))

Describe the solution you'd like
Mask, then shift.

Describe alternatives you've considered
None

Additional context

Or really transition to serializer/deserializaer concepts.

Requester Info
Jacob Hageman - NASA/GSFC

@skliper skliper added this to the Draco milestone Jun 14, 2022
@skliper skliper self-assigned this Jun 14, 2022
skliper added a commit to skliper/cFE that referenced this issue Jun 14, 2022
skliper added a commit to skliper/cFE that referenced this issue Jun 14, 2022
skliper added a commit to skliper/cFE that referenced this issue Jun 14, 2022
astrogeco added a commit that referenced this issue Jun 19, 2022
Fix #2118, Endian macro mask before shift to avoid shift overflow warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant