aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-21 23:37:27 +0100
committerMax Kellermann <max@duempel.org>2014-01-21 23:37:27 +0100
commitb38b8b9c189817929508177f2f23a0f8aa8ced9c (patch)
tree7ab3a83fb05ab48b81a35982574c4314e7d2bdce /src
parent54348561362f23b709c04d3e5deac9694698d784 (diff)
downloadmpd-b38b8b9c189817929508177f2f23a0f8aa8ced9c.tar.gz
mpd-b38b8b9c189817929508177f2f23a0f8aa8ced9c.tar.xz
mpd-b38b8b9c189817929508177f2f23a0f8aa8ced9c.zip
db/upnp: simplify Namei()
Diffstat (limited to '')
-rw-r--r--src/db/UpnpDatabasePlugin.cxx13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx
index 3b9615295..0d285f63c 100644
--- a/src/db/UpnpDatabasePlugin.cxx
+++ b/src/db/UpnpDatabasePlugin.cxx
@@ -481,16 +481,18 @@ UpnpDatabase::Namei(ContentDirectoryService &server,
std::string objid(rootid);
// Walk the path elements, read each directory and try to find the next one
- for (auto i = vpath.begin(), end = vpath.end(), last = std::prev(end);
- i != end; ++i) {
+ for (auto i = vpath.begin(), last = std::prev(vpath.end());; ++i) {
UPnPDirContent dirbuf;
if (!server.readDir(handle, objid.c_str(), dirbuf, error))
return false;
// Look for the name in the sub-container list
UPnPDirObject *child = dirbuf.FindObject(i->c_str());
- if (child == nullptr)
- break;
+ if (child == nullptr) {
+ error.Format(db_domain, DB_NOT_FOUND,
+ "No such object");
+ return false;
+ }
switch (child->type) {
case UPnPDirObject::Type::UNKNOWN:
@@ -520,9 +522,6 @@ UpnpDatabase::Namei(ContentDirectoryService &server,
}
}
}
-
- error.Format(db_domain, DB_NOT_FOUND, "No such object");
- return false;
}
// vpath is a parsed and writeable version of selection.uri. There is