-
Notifications
You must be signed in to change notification settings - Fork 128
Coverity fixes plus fix for potential multithreading issue #38142
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
Conversation
Most fixes were for copying in instead of moving in to a method that I've recently added to fix Coverity warnings about null objects. The changes in FindPeaksConvolve were because m_pdf was being either read or written to without the lock.
This refactor will protect against a null cast in the case of a non-MultiDomainFunction being passed in.
FunctionFactory::Instance().createFunction("ProductFunction")); | ||
product->addFunction(norm); | ||
product->addFunction(inBrace); | ||
auto composite = Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck<CompositeFunction, API::IFunction>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question to help me - why is this necessary?
Note this line is also present in PawleyFunction.cpp
and a few other places
std::dynamic_pointer_cast<CompositeFunction>(FunctionFactory::Instance().createFunction("CompositeFunction")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do dynamic_pointer_cast<T>
and then use the result without checking for null, then Coverity complains. In #38100 I added dynamicPointerCastWithCheck
to include the null check before returning the pointer, (and save duplicating if ( thing == nullptr)
in several places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, followed instructions for FindPeaksConvolve
in #36352 - just a quick question for my own understanding!
This gets the changes from mantidproject#38142 into ornl-next Most fixes were for copying in instead of moving in to a method that I've recently added to fix Coverity warnings about null objects. The changes in FindPeaksConvolve were because m_pdf was being either read or written to without the lock. Refactor to avoid potential null cast This refactor will protect against a null cast in the case of a non-MultiDomainFunction being passed in.
Most fixes were for copying in instead of moving in to a method that I've recently added to fix other Coverity warnings about null objects (#38100). The changes in
FindPeaksConvolve
were becausem_pdf
was being either read or written to without the lock, so a potential bug.To test:
Try running
FindPeaksConvolve
, e..g the test code in #38135.This does not require release notes because it has no impact on the user.
Reviewer
Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.