Commit 0ed48b36 authored by Max Kellermann's avatar Max Kellermann

db/upnp: merge duplicate branches in Namei()

parent b38b8b9c
...@@ -494,33 +494,18 @@ UpnpDatabase::Namei(ContentDirectoryService &server, ...@@ -494,33 +494,18 @@ UpnpDatabase::Namei(ContentDirectoryService &server,
return false; 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) { if (i == last) {
// The last element in the path was found and it's
// a container, we're done
odirent = std::move(*child); odirent = std::move(*child);
return true; return true;
} }
break;
case UPnPDirObject::Type::ITEM: if (child->type != UPnPDirObject::Type::CONTAINER) {
// 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, error.Format(db_domain, DB_NOT_FOUND,
"No such object"); "Not a container");
return false; return false;
} }
}
objid = std::move(child->m_id);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment