db/upnp: merge duplicate branches in Namei()

This commit is contained in:
Max Kellermann 2014-01-21 23:42:02 +01:00
parent b38b8b9c18
commit 0ed48b364a

View File

@ -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);
} }
} }