Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Address Overloaded Virtual Warnings #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gerickson
Copy link
Contributor

No description provided.

@gerickson gerickson force-pushed the bug/fix-overloaded-virtual-warnings branch from e464147 to 2180d04 Compare October 25, 2018 04:43
@codecov-io
Copy link

codecov-io commented Oct 25, 2018

Codecov Report

Merging #70 into master will increase coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #70      +/-   ##
==========================================
+ Coverage   60.13%   60.13%   +<.01%     
==========================================
  Files         306      306              
  Lines       49366    49367       +1     
==========================================
+ Hits        29685    29686       +1     
  Misses      19681    19681
Impacted Files Coverage Δ
src/test-apps/TestSystemObject.cpp 97.56% <0%> (+0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9726ae3...88da247. Read the comment docs.

Copy link
Member

@robszewczyk robszewczyk left a comment

Choose a reason for hiding this comment

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

This code seems to be most relevant to the Legacy WDM code. If clang is complaining, it is perhaps complaining for the wrong reasons; the IncompleteIndication is supposed to override / implement the pure virtual from ProtocolEngine.

void IncompleteIndication(const uint64_t &aPeerNodeId, StatusReport &aReport);
virtual void IncompleteIndication(const uint64_t &aPeerNodeId, StatusReport &aReport);

using DMPublisher::IncompleteIndication;
Copy link
Member

Choose a reason for hiding this comment

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

I don't quite understand. I believe the the intention here was to have the method above override the DMPublisher::IncompleteIndication; Arguably, it would be appropriate to add the __OVERRIDE macro to the IncompleteIndication. Because the IncompleteIndication already is declared virtual in base, there is no need to declare it virtual here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, this seems an odd warning. As Jay and I discussed this morning, it might make sense long-term to get rid of "-Wall" in configure.ac and select those warnings we feel actually make sense and add real, measurable value.

Using __OVERRIDE here might be better though that may then trigger -Winconsistent-missing-override. I'll give it a try.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The using statement here seems to be the required magic but it doesn't make much sense to me based on my knowledge of the language.

The better approach here might be just to disable -Woverloaded-virtual (-Wno-overloaded-virtual) for clang. Thoughts @robszewczyk or @jaylogue?

Copy link
Contributor

Choose a reason for hiding this comment

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

IncompleteIndication() has a different signature on the base class:
void IncompleteIndication(Binding *aBinding, StatusReport &aReport)
vs.
void IncompleteIndication(const uint64_t &aPeerNodeId, StatusReport &aReport)
This is likely erroneous, as nothing appears to call the subclass method.

Copy link
Contributor Author

@gerickson gerickson Oct 26, 2018

Choose a reason for hiding this comment

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

Looking at this again, src/lib/profiles/data-management/Legacy/ProtocolEngine.h defines both:

virtual void IncompleteIndication(Binding *aBinding, StatusReport &aReport);

and:

virtual void IncompleteIndication(const uint64_t &aPeerNodeId, StatusReport &aReport) = 0;

The implementation of the former calls the latter making the base class abstract:

void ProtocolEngine::IncompleteIndication(Binding *aBinding, StatusReport &aReport)
{
    bool indicated = FailTransactions(aBinding, aReport);

    if (!indicated)
        IncompleteIndication(aBinding->mPeerNodeId, aReport);
}

It seems like the test clients correctly override the latter which seems to imply that the warning is a bit pedantic.

@@ -327,11 +327,13 @@ class DMTestClient :
return err;
}

void IncompleteIndication(const uint64_t &aPeerNodeId, StatusReport &aReport)
virtual void IncompleteIndication(const uint64_t &aPeerNodeId, StatusReport &aReport)
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary virtual, but perhaps a beneficial override?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. See above.

Copy link
Contributor

Choose a reason for hiding this comment

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

As with MockDMPublisher I think this is an error, as nothing calls DMTestClient::IncompleteIndication(const uint64_t &aPeerNodeId, StatusReport &aReport).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -510,10 +511,13 @@ class WDMTestClient :
return err;
}

void IncompleteIndication(const uint64_t &aPeerNodeId, StatusReport &aReport)
virtual void IncompleteIndication(const uint64_t &aPeerNodeId, StatusReport &aReport)
Copy link
Member

Choose a reason for hiding this comment

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

Unnecessary virtual but beneficial override?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. See above.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants