Skip to content

Commit 9f1c687

Browse files
author
Jooyung Han
committed
servicemanager: Fix loop continue/break
in getVintfUpdatableApex, it can break out the outer loop if the nested forEach find a match. Bug: n/a Test: TH Change-Id: I0261a2d43156a563e9e7fd7e96f89544c0f0fd50
1 parent d52639e commit 9f1c687

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

cmds/servicemanager/ServiceManager.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,15 @@ static std::optional<std::string> getVintfUpdatableApex(const std::string& name)
150150
std::optional<std::string> updatableViaApex;
151151

152152
forEachManifest([&](const ManifestWithDescription& mwd) {
153-
mwd.manifest->forEachInstance([&](const auto& manifestInstance) {
153+
bool cont = mwd.manifest->forEachInstance([&](const auto& manifestInstance) {
154154
if (manifestInstance.format() != vintf::HalFormat::AIDL) return true;
155155
if (manifestInstance.package() != aname.package) return true;
156156
if (manifestInstance.interface() != aname.iface) return true;
157157
if (manifestInstance.instance() != aname.instance) return true;
158158
updatableViaApex = manifestInstance.updatableViaApex();
159159
return false; // break (libvintf uses opposite convention)
160160
});
161-
if (updatableViaApex.has_value()) return true; // break (found match)
162-
return false; // continue
161+
return !cont;
163162
});
164163

165164
return updatableViaApex;

0 commit comments

Comments
 (0)