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 #2150, Adds a cast to the negation of unsigned expression #2437

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

chillfig
Copy link
Contributor

@chillfig chillfig commented Aug 31, 2023

Checklist (Please check before submitting)

Describe the contribution

Testing performed
-coverage
-functional test

Expected behavior changes
Supress CodeQL warning

System(s) tested on

  • OS: Ubuntu 20.04

Additional context
Concur with the issue that this pr addresses. The problem is that when you apply a negation operator (-) to an unsigned integer, the result will not be a negative number as maybe expected. Instead, due to two's complement arithmetic, we get a very large positive number. Then, it will cause unexpected results when that large number is assigned to a signed variable like int32.

Third party code
N/A

Contributor Info - All information REQUIRED for consideration of pull request
Justin Figueroa, Vantage Systems

@chillfig chillfig added enhancement CCB:Ready Ready for discussion at the Configuration Control Board (CCB) labels Aug 31, 2023
@chillfig chillfig added CCB:Approved Indicates code review and approval by community CCB and removed CCB:Ready Ready for discussion at the Configuration Control Board (CCB) labels Sep 7, 2023
dzbaker added a commit to nasa/cFS that referenced this pull request Sep 13, 2023
*Combines:*

cFE v7.0.0-rc4+dev384
osal v6.0.0-rc4+dev229

**Includes:**

*cFE*
- nasa/cFE#2437

*osal*
- nasa/osal#1407
- nasa/osal#1408

Co-authored by: Justin Figueroa <chillfig@users.noreply.github.com>
Co-authored by: Jacob Hageman  <skliper@users.noreply.github.com>
@dzbaker dzbaker mentioned this pull request Sep 13, 2023
2 tasks
@dzbaker dzbaker merged commit db8ffb2 into nasa:main Sep 13, 2023
22 checks passed
dzbaker added a commit to nasa/cFS that referenced this pull request Sep 13, 2023
*Combines:*

cFE v7.0.0-rc4+dev384
osal v6.0.0-rc4+dev229

**Includes:**

*cFE*
- nasa/cFE#2437

*osal*
- nasa/osal#1407
- nasa/osal#1408

Co-authored by: Justin Figueroa <chillfig@users.noreply.github.com>
Co-authored by: Jacob Hageman  <skliper@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CCB:Approved Indicates code review and approval by community CCB enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unary minus operator should not be applied to an unsigned expression
2 participants