From mboxrd@z Thu Jan 1 00:00:00 1970 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) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 18 Apr 2013 18:44:02 +0200 Message-Id: <1366303444-24620-7-git-send-email-pbonzini@redhat.com> In-Reply-To: <1366303444-24620-1-git-send-email-pbonzini@redhat.com> References: <1366303444-24620-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 6/8] qom: do not return root for empty path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: av1474@comtv.ru 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; } -- 1.8.1.4