From patchwork Thu Apr 18 16:44:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 237687 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D7BEF2C01C0 for ; Fri, 19 Apr 2013 02:48:54 +1000 (EST) Received: from localhost ([::1]:37934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USs0z-0003yF-5i for incoming@patchwork.ozlabs.org; Thu, 18 Apr 2013 12:48:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60500) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USrwg-0006pM-NK for qemu-devel@nongnu.org; Thu, 18 Apr 2013 12:44:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USrwb-0006OL-Qc for qemu-devel@nongnu.org; Thu, 18 Apr 2013 12:44:26 -0400 Received: from mail-ee0-f41.google.com ([74.125.83.41]:54978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USrwb-0006O5-Ko for qemu-devel@nongnu.org; Thu, 18 Apr 2013 12:44:21 -0400 Received: by mail-ee0-f41.google.com with SMTP id c1so1428890eek.0 for ; Thu, 18 Apr 2013 09:44:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=efKjIt092ZCvQ3yk3XH9qp9cG/xV2s3ISHa3CfIvyCM=; b=R99WQ4UEAwBEMrYLAZhqws1sfo9nJWxWbmvnWMEqzQB7OQEorIUwHx61nyJGm6v/1f nlpu0GgizlwHNBbb7rcJSC81CLz7Tve/oufE8S01y12kefr7jF5AIS7kt0IEbhjusxW0 Zl0mQpqKNGUBQD2McfALKCVtRtU+QhILqjWZeDAyHiJGdz32mu5sZPjSBTWXBG12iRQq tX+wASq54jCEcTb9L1prvfcCsgo1yuvxqDheSK5h13moySkI19wVvUyYCoNKVgy2KEOC FD7ldHGxFbhA+QLwd7JoD5ox85DjRtx06kx48lGN0p4TDndGgU6rTXBu062dwS3brfv9 /wBg== X-Received: by 10.14.182.72 with SMTP id n48mr32269532eem.3.1366303460848; Thu, 18 Apr 2013 09:44:20 -0700 (PDT) Received: from playground.lan (93-34-176-20.ip50.fastwebnet.it. [93.34.176.20]) by mx.google.com with ESMTPS id f9sm1873198eeu.11.2013.04.18.09.44.18 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 18 Apr 2013 09:44:19 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 18 Apr 2013 18:44:02 +0200 Message-Id: <1366303444-24620-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1366303444-24620-1-git-send-email-pbonzini@redhat.com> References: <1366303444-24620-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 74.125.83.41 Cc: av1474@comtv.ru Subject: [Qemu-devel] [PATCH 6/8] qom: do not return root for empty path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org An empty path will return the sole object of that type in the QOM tree. This is different from "/", which returns the root. Signed-off-by: Paolo Bonzini --- qom/object.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/qom/object.c b/qom/object.c index 093502e..dd53d24 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1113,21 +1113,13 @@ static Object *object_resolve_partial_path(Object *parent, Object *object_resolve_path_type(const char *path, const char *typename, bool *ambiguous) { - bool partial_path = true; Object *obj; gchar **parts; parts = g_strsplit(path, "/", 0); - if (parts == NULL || parts[0] == NULL) { - g_strfreev(parts); - return object_get_root(); - } - - if (strcmp(parts[0], "") == 0) { - partial_path = false; - } + assert(parts); - if (partial_path) { + if (parts[0] == NULL || strcmp(parts[0], "") != 0) { if (ambiguous) { *ambiguous = false; }