Skip to content

Conversation

jclarkeSTFC
Copy link
Contributor

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 because m_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

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • If there are changes in the release notes then do they describe the changes appropriately?
  • Do the release notes conform to the release notes guide?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed?
  • Do the changes handle unexpected situations, e.g. bad input?
  • Has the relevant (user and developer) documentation been added/updated?

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.

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.
@jclarkeSTFC jclarkeSTFC added Maintenance Unassigned issues to be addressed in the next maintenance period. ISIS: Core Issue and pull requests at ISIS that relate to Core features and functions labels Oct 3, 2024
@jclarkeSTFC jclarkeSTFC added this to the Release 6.12 milestone Oct 3, 2024
This refactor will protect against a null cast in the case of a
non-MultiDomainFunction being passed in.
@jclarkeSTFC jclarkeSTFC marked this pull request as ready for review October 4, 2024 12:02
FunctionFactory::Instance().createFunction("ProductFunction"));
product->addFunction(norm);
product->addFunction(inBrace);
auto composite = Kernel::DynamicPointerCastHelper::dynamicPointerCastWithCheck<CompositeFunction, API::IFunction>(
Copy link
Contributor

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"));

Copy link
Contributor Author

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.

Copy link
Contributor

@RichardWaiteSTFC RichardWaiteSTFC left a 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!

@SilkeSchomann SilkeSchomann self-assigned this Oct 9, 2024
@SilkeSchomann SilkeSchomann merged commit 3dec59b into mantidproject:main Oct 9, 2024
10 checks passed
@jclarkeSTFC jclarkeSTFC deleted the coverity_fixes branch October 9, 2024 07:50
peterfpeterson pushed a commit to peterfpeterson/mantid that referenced this pull request Nov 26, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ISIS: Core Issue and pull requests at ISIS that relate to Core features and functions Maintenance Unassigned issues to be addressed in the next maintenance period.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants