/* Returns: The matched object or NULL on path lookup failures.  */
static Object* object_resolve_link(Object *obj, const char *name, const char *path, Error **errp)
/* Returns: The matched object or NULL on path lookup failures.  */
static Object* object_resolve_link(Object *obj, const char *name, const char *path, Error **errp)
{
    const char *type;
    gchar *target_type;
    bool ambiguous = false;
    Object *target;
    type = object_property_get_type(obj, name, NULL);
    target_type = g_strndup(&type[5], strlen(type) - 6);
    target = object_resolve_path_type(path, target_type, &ambiguous);
    if (ambiguous) {
        error_set(errp, QERR_AMBIGUOUS_PATH, path);
    } else if (!target) {
        target = object_resolve_path(path, &ambiguous);
        if (target || ambiguous) {
            error_set(errp, QERR_INVALID_PARAMETER_TYPE, name, target_type);
        } else {
            error_set(errp, QERR_DEVICE_NOT_FOUND, path);
        }
        target = NULL;
    }
    g_free(target_type);
    return target;
}