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;
}
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;
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 (i == last) {
odirent = std::move(*child);
return true;
}
if (child->type != UPnPDirObject::Type::CONTAINER) {
error.Format(db_domain, DB_NOT_FOUND,
"Not a container");
return false;
}
objid = std::move(child->m_id);
}
}