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

i.gensigset: fix possible pole and divide by zero errors in regroup #4500

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ymdatta
Copy link
Contributor

@ymdatta ymdatta commented Oct 11, 2024

Using logarithm function call with zero argument will lead to a pole error, which occurs if the mathematical function has an exact infinite result.

Check if the argument value is zero before passing that to the log function to avoid such errors. I also added check for negative numbers just to make sure the argument is in the right domain for the log function as well.

There was also a possible divide by zero scenario when we were dividing the class data by subsum, which can be zero. Added a conditional check which avoids going to that stage.

@github-actions github-actions bot added C Related code is in C module imagery labels Oct 11, 2024
if (subsum > 0)
likelihood += log(subsum) + maxlike;

if (subsum) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't combine both of these in the same conditional as subsum being negative is not valid for log, but valid while calculating Data.

@nilason nilason added this to the 8.5.0 milestone Oct 12, 2024
Using logarithm function call with zero argument will lead to
a pole error, which occurs if the mathematical function has
an exact infinite result.

Check if the argument value is zero before passing that to
the log function to avoid such errors. I also added check
for negative numbers just to make sure the argument is in
the right domain for the log function as well.

There was also a possible divide by zero scenario when we
were dividing the class data by subsum, which can be zero.
Added a conditional check which avoids going to that stage.

Signed-off-by: Mohan Yelugoti <[email protected]>
@ymdatta ymdatta force-pushed the cppcheck_imagery_log2 branch from 3f08d03 to 2b1b9e6 Compare October 23, 2024 21:41
ymdatta added a commit to ymdatta/grass that referenced this pull request Nov 27, 2024
Documented each supression issue with comments to distinguish between
false positives and true positives awaiting resolution.

For the false positives supressions, appropriate information is
provided on why those were considered as false positive.

True positives will be removed from the suppression file once
their corresponding fixes(OSGeo#4702, OSGeo#4638, OSGeo#4500, OSGeo#4499) are merged.

Run:

`cppcheck --suppressions-list=.cppcheck-supressions <path>`

Signed-off-by: Mohan Yelugoti <[email protected]>
ymdatta added a commit to ymdatta/grass that referenced this pull request Nov 27, 2024
Documented each suppression issue with comments to distinguish between
false positives and true positives awaiting resolution.

For the false positives suppressions, appropriate information is
provided on why those were considered as false positive.

True positives will be removed from the suppression file once
their corresponding fixes(OSGeo#4702, OSGeo#4638, OSGeo#4500, OSGeo#4499) are merged.

Run:

`cppcheck --suppressions-list=.cppcheck-suppressions <path>`

Signed-off-by: Mohan Yelugoti <[email protected]>
@echoix
Copy link
Member

echoix commented Dec 11, 2024

Maybe a fresh, updated CI run might be wanted before a merge, last run is getting old

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C imagery module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants