-
Notifications
You must be signed in to change notification settings - Fork 107
Address Overloaded Virtual Warnings #70
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -281,7 +281,7 @@ static WEAVE_ERROR ValidatePath(TLVReader &aReader, | |
| * a sub-class of the WDM client and supply the relevant methods as follows. | ||
| */ | ||
|
|
||
| class DMTestClient : | ||
| class DMTestClient __FINAL : | ||
| public DMClient | ||
| { | ||
| public: | ||
|
|
@@ -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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary virtual, but perhaps a beneficial override? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. See above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As with MockDMPublisher I think this is an error, as nothing calls There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #70 (comment). |
||
| { | ||
| printf("processing: <incomplete indication>\n"); | ||
| } | ||
|
|
||
| using DMClient::IncompleteIndication; | ||
|
|
||
| #if WEAVE_CONFIG_WDM_ALLOW_CLIENT_SUBSCRIPTION | ||
|
|
||
| WEAVE_ERROR SubscribeConfirm(const uint64_t &aResponderId, StatusReport &aStatus, uint16_t aTxnId) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| /* | ||
| * | ||
| * Copyright (c) 2018 Google LLC. | ||
| * Copyright (c) 2013-2017 Nest Labs, Inc. | ||
| * All rights reserved. | ||
| * | ||
|
|
@@ -274,7 +275,7 @@ ReferencedTLVData DataList; | |
| * a sub-class of the WDM client and supply the relevant methods as follows. | ||
| */ | ||
|
|
||
| class WDMTestClient : | ||
| class WDMTestClient __FINAL : | ||
| public DMClient | ||
| { | ||
| WEAVE_ERROR ViewConfirm(const uint64_t &aResponderId, StatusReport &aStatus, uint16_t aTxnId) | ||
|
|
@@ -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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unnecessary virtual but beneficial override? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. See above. |
||
| { | ||
| return; | ||
| } | ||
|
|
||
| using DMClient::IncompleteIndication; | ||
|
|
||
| }; | ||
|
|
||
| int main(int argc, char *argv[]) | ||
|
|
||
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.
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__OVERRIDEmacro to theIncompleteIndication. Because theIncompleteIndicationalready is declared virtual in base, there is no need to declare it virtual here, right?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.
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.
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.
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?
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.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Looking at this again,
src/lib/profiles/data-management/Legacy/ProtocolEngine.hdefines both:and:
The implementation of the former calls the latter making the base class abstract:
It seems like the test clients correctly override the latter which seems to imply that the warning is a bit pedantic.