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

Unsigned Compared Against 0 always true #1991

Closed
ArielSAdamsNASA opened this issue Oct 6, 2021 · 1 comment · Fixed by #2400
Closed

Unsigned Compared Against 0 always true #1991

ArielSAdamsNASA opened this issue Oct 6, 2021 · 1 comment · Fixed by #2400
Assignees

Comments

@ArielSAdamsNASA
Copy link

Describe the bug
This greater-than-or-equal-to-zero comparison of an unsigned value is always true. CmdPtr->TriggerMode >= CFE_ES_PERF_TRIGGER_START.

Expected behavior
Fix the if statement.

Code snips

if ((CmdPtr->TriggerMode >= CFE_ES_PERF_TRIGGER_START) && (CmdPtr->TriggerMode < CFE_ES_PERF_MAX_MODES))

System observed on:
Coverity: https://scan.coverity.com/projects/arielsadamsnasa-cfs-jsf-rules?tab=overview

Reporter Info
Ariel Adams, ASRC Federal

@skliper
Copy link
Contributor

skliper commented Oct 7, 2021

Not really a bug since it works as intended. Could improve by making 0 an invalid mode, but would break any code that didn't use the CFE_ES_PerfMode_t enum values and/or assumes 0 is valid.

@skliper skliper changed the title Unsigned Compared Against 0 Unsigned Compared Against 0 always true Oct 7, 2021
@skliper skliper self-assigned this Jul 17, 2023
dzbaker added a commit that referenced this issue Sep 1, 2023
Fix #1991, TriggerMode unsigned compare with 0
@dzbaker dzbaker closed this as completed in 126e23d Sep 1, 2023
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.

2 participants