From patchwork Mon Dec 14 20:53:20 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 41133 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1CFC2B6F18 for ; Tue, 15 Dec 2009 07:59:29 +1100 (EST) Received: from localhost ([127.0.0.1]:36031 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKI0s-0005Vr-6x for incoming@patchwork.ozlabs.org; Mon, 14 Dec 2009 15:59:26 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NKHvR-0002GM-0X for qemu-devel@nongnu.org; Mon, 14 Dec 2009 15:53:49 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NKHvM-0002CI-6T for qemu-devel@nongnu.org; Mon, 14 Dec 2009 15:53:48 -0500 Received: from [199.232.76.173] (port=39713 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NKHvL-0002CA-WE for qemu-devel@nongnu.org; Mon, 14 Dec 2009 15:53:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58216) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NKHvL-0002eU-9v for qemu-devel@nongnu.org; Mon, 14 Dec 2009 15:53:43 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBEKrgr6022368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 Dec 2009 15:53:42 -0500 Received: from localhost (vpn-10-150.rdu.redhat.com [10.11.10.150]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBEKrfYw002654; Mon, 14 Dec 2009 15:53:41 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Mon, 14 Dec 2009 18:53:20 -0200 Message-Id: <1260824004-2941-2-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1260824004-2941-1-git-send-email-lcapitulino@redhat.com> References: <1260824004-2941-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 1/5] QDict: Fix size update X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Key replacement should not update the dictionary's size. This commit also adds a test for the bug. Signed-off-by: Luiz Capitulino --- check-qdict.c | 2 ++ qdict.c | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/check-qdict.c b/check-qdict.c index c37d448..f2b4826 100644 --- a/check-qdict.c +++ b/check-qdict.c @@ -205,6 +205,8 @@ START_TEST(qdict_put_exists_test) value = qdict_get_int(tests_dict, key); fail_unless(value == 2); + + fail_unless(qdict_size(tests_dict) == 1); } END_TEST diff --git a/qdict.c b/qdict.c index ef73265..ba8eef0 100644 --- a/qdict.c +++ b/qdict.c @@ -122,9 +122,8 @@ void qdict_put_obj(QDict *qdict, const char *key, QObject *value) /* allocate a new entry */ entry = alloc_entry(key, value); QLIST_INSERT_HEAD(&qdict->table[hash], entry, next); + qdict->size++; } - - qdict->size++; } /**