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

Cleanup two divide-by-zero issues from Coverity #2386

Merged
merged 3 commits into from
Sep 21, 2024

Conversation

jwrober
Copy link
Collaborator

@jwrober jwrober commented Sep 10, 2024

No related issue.

CID 1435482, 1435595

ai/default/aiunit.cpp Outdated Show resolved Hide resolved
@jwrober jwrober requested a review from lmoureaux September 11, 2024 15:23
ai/default/aiunit.cpp Outdated Show resolved Hide resolved
@lmoureaux
Copy link
Contributor

Pushed a commit using the same technique for aunit and punit. This makes the div by zero truly impossible by checking beforehand.

We could also have done some math and used a/b < c/d <=> a*d < b*c (for positive b and d), but this has different rounding which might be important.

@jwrober
Copy link
Collaborator Author

jwrober commented Sep 21, 2024

Thanks for the help on this one.

@jwrober jwrober merged commit 70858be into longturn:master Sep 21, 2024
21 checks passed
@lmoureaux lmoureaux self-assigned this Oct 26, 2024
lmoureaux added a commit that referenced this pull request Oct 26, 2024
Coverity CID 1435482, 1435595.
See #2386.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants