From patchwork Wed Jun 27 20:23:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 167735 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 F32C7B6FAB for ; Thu, 28 Jun 2012 06:22:56 +1000 (EST) Received: from localhost ([::1]:33675 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjylK-0003JM-JL for incoming@patchwork.ozlabs.org; Wed, 27 Jun 2012 16:22:54 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sjyl3-0003Ei-4A for qemu-devel@nongnu.org; Wed, 27 Jun 2012 16:22:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sjykx-0003Kd-Jh for qemu-devel@nongnu.org; Wed, 27 Jun 2012 16:22:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:1028) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sjykx-0003Ip-8x for qemu-devel@nongnu.org; Wed, 27 Jun 2012 16:22:31 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5RKMRcl011410 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Jun 2012 16:22:28 -0400 Received: from blackpad.lan.raisama.net (vpn1-4-120.gru2.redhat.com [10.97.4.120]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5RKMPlx032112; Wed, 27 Jun 2012 16:22:25 -0400 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id 33FD220235D; Wed, 27 Jun 2012 17:23:13 -0300 (BRT) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Wed, 27 Jun 2012 17:23:00 -0300 Message-Id: <1340828587-15201-5-git-send-email-ehabkost@redhat.com> In-Reply-To: <1340828587-15201-1-git-send-email-ehabkost@redhat.com> References: <1340828587-15201-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Isaku Yamahata , Michael Tokarev , Gleb Natapov Subject: [Qemu-devel] [PATCH 04/11] acpi_table_add(): introduce 'qemu_len' variable 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 To make the length calculation clearer, introduce a 'qemu_len' variable, for the length of all data being added to acpi_tables (including the QEMU-specific prefix). No behavior change, just make the length calculation clearer. Signed-off-by: Eduardo Habkost --- hw/acpi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/acpi.c b/hw/acpi.c index abc959e..b5f0531 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -86,7 +86,8 @@ int acpi_table_add(const char *t) { char buf[1024], *p, *f; unsigned long val; - size_t acpi_len, start, allen; + size_t start, allen; + size_t qemu_len, acpi_len; bool has_header; int changed; int r; @@ -150,13 +151,17 @@ int acpi_table_add(const char *t) /* now fill in the header fields */ f = acpi_tables + start; /* start of the table */ + + /* length of the whole table, including our prefix */ + qemu_len = allen - start; + changed = 0; /* copy the header to temp place to align the fields */ memcpy(&hdr, has_header ? f : dfl_hdr, ACPI_TABLE_HDR_SIZE); /* length of the table minus our prefix */ - acpi_len = allen - start - ACPI_TABLE_PFX_SIZE; + acpi_len = qemu_len - ACPI_TABLE_PFX_SIZE; hdr._length = cpu_to_le16(acpi_len);