[shill] FindService should return a ServiceRefPtr, and should always return something
We weren't explicitly returning a value from FindService on failure,
which was causing a unit test to pass erroneously. Once I fixed it,
the test started failing because of a dumb thing I was doing in
MockService. So, fix that so that the tests can pass as they should.
BUG=None
TEST=unit tests
Change-Id: Ice304e514ea0e3add779ac061b0945b5712dea29
Reviewed-on: http://gerrit.chromium.org/gerrit/2374
Tested-by: Chris Masone <cmasone@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
diff --git a/manager.cc b/manager.cc
index df60b2b..7b5b08c 100644
--- a/manager.cc
+++ b/manager.cc
@@ -98,12 +98,14 @@
}
}
-Service* Manager::FindService(const std::string& name) {
+ServiceRefPtr Manager::FindService(const std::string& name) {
vector<ServiceRefPtr>::iterator it;
for (it = services_.begin(); it != services_.end(); ++it) {
- if (name == (*it)->UniqueName())
- return it->get();
+ if (name == (*it)->UniqueName()) {
+ return *it;
+ }
}
+ return NULL;
}
} // namespace shill