aboutsummaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-21 23:42:02 +0100
committerMax Kellermann <max@duempel.org>2014-01-21 23:42:02 +0100
commit0ed48b364abe5a9dabb762b4a5afcbc556114663 (patch)
treebdbf9cac19fedb7b6b553f9cb76f054f2b618a8f /src/db
parentb38b8b9c189817929508177f2f23a0f8aa8ced9c (diff)
downloadmpd-0ed48b364abe5a9dabb762b4a5afcbc556114663.tar.gz
mpd-0ed48b364abe5a9dabb762b4a5afcbc556114663.tar.xz
mpd-0ed48b364abe5a9dabb762b4a5afcbc556114663.zip
db/upnp: merge duplicate branches in Namei()
Diffstat (limited to '')
-rw-r--r--src/db/UpnpDatabasePlugin.cxx35
1 files changed, 10 insertions, 25 deletions
diff --git a/src/db/UpnpDatabasePlugin.cxx b/src/db/UpnpDatabasePlugin.cxx
index 0d285f63c..abab93dcc 100644
--- a/src/db/UpnpDatabasePlugin.cxx
+++ b/src/db/UpnpDatabasePlugin.cxx
@@ -494,33 +494,18 @@ UpnpDatabase::Namei(ContentDirectoryService &server,
return false;
}
- switch (child->type) {
- case UPnPDirObject::Type::UNKNOWN:
- assert(false);
- gcc_unreachable();
-
- case UPnPDirObject::Type::CONTAINER:
- objid = child->m_id; // Next readdir target
- if (i == last) {
- // The last element in the path was found and it's
- // a container, we're done
- odirent = std::move(*child);
- return true;
- }
- break;
+ if (i == last) {
+ odirent = std::move(*child);
+ return true;
+ }
- case UPnPDirObject::Type::ITEM:
- // If this is the last path elt, we found the target,
- // else it does not exist
- if (i == last) {
- odirent = std::move(*child);
- return true;
- } else {
- error.Format(db_domain, DB_NOT_FOUND,
- "No such object");
- return false;
- }
+ if (child->type != UPnPDirObject::Type::CONTAINER) {
+ error.Format(db_domain, DB_NOT_FOUND,
+ "Not a container");
+ return false;
}
+
+ objid = std::move(child->m_id);
}
}