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

Fix coverity hits in Classifier, Decision Forest and GBT #3001

Merged
merged 8 commits into from
Dec 9, 2024

Conversation

Vika-F
Copy link
Contributor

@Vika-F Vika-F commented Dec 2, 2024

Rule of three violations were fixed mostly by adding default implementations or deleting copy constructors and assignment operators.

The default implementations were added into Parameter, Input, InputIface, Model, ModelImpl classes as they are meant to be copy-assignable and copy-constructible.

Non-default implementations of copy constructor and assignment operator were added in GBT ModelImpl and multiclass classifier Model classes because they contain non-POD members.

In the internal classes that do not need to be copyable the copy constructors and assignment operators were deleted.

PR completeness and readability

  • I have reviewed my changes thoroughly before submitting this pull request.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details).
  • I have added a respective label(s) to PR if I have a permission for that.
  • I have resolved any merge conflicts that might occur with the base branch.

Testing

  • I have run it locally and tested the changes extensively.
  • All CI jobs are green or I have provided justification why they aren't.

@Vika-F Vika-F changed the title Fix coverity hist in GBT Fix coverity hits in GBT Dec 2, 2024
@Vika-F Vika-F changed the title Fix coverity hits in GBT Fix coverity hits in Classifier, Decision Forest and GBT Dec 3, 2024
@Vika-F
Copy link
Contributor Author

Vika-F commented Dec 4, 2024

/intelci: run

@@ -99,6 +99,7 @@ class DAAL_EXPORT InputIface : public daal::algorithms::Input
public:
InputIface(size_t nElements);
InputIface(const InputIface & other) : daal::algorithms::Input(other) {}
InputIface & operator=(const InputIface & other) = default;
Copy link
Contributor

@avolkov-intel avolkov-intel Dec 5, 2024

Choose a reason for hiding this comment

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

Should we also add daal::algorithms::Input(other) as in copy-constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Default compiler-generated implementation should do this. No need to implement this manually.

I've unified all this kind of copy constructors and assignment operators in this PR to have definitions in .h and default implementations in .cpp files.

@Vika-F
Copy link
Contributor Author

Vika-F commented Dec 6, 2024

/intelci: run

@@ -38,6 +38,39 @@ Tree::~Tree() {}

ModelImpl::ModelImpl() : _nTree(0) {}

ModelImpl::ModelImpl(const ModelImpl & other)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps some small tests could be added for the ones with non-default constructors.

@Vika-F Vika-F merged commit 36803e0 into uxlfoundation:main Dec 9, 2024
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants