From patchwork Wed Jun 27 20:23:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 167747 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 23868B6FF4 for ; Thu, 28 Jun 2012 07:27:29 +1000 (EST) Received: from localhost ([::1]:39662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SjymI-0006Rw-TM for incoming@patchwork.ozlabs.org; Wed, 27 Jun 2012 16:23:54 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sjyl3-0003Eq-O1 for qemu-devel@nongnu.org; Wed, 27 Jun 2012 16:22:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sjykx-0003KZ-JS for qemu-devel@nongnu.org; Wed, 27 Jun 2012 16:22:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sjykx-0003Ir-97 for qemu-devel@nongnu.org; Wed, 27 Jun 2012 16:22:31 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5RKMSRa030290 (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-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q5RKMRU8021678; Wed, 27 Jun 2012 16:22:28 -0400 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id 9773C203BA9; Wed, 27 Jun 2012 17:23:13 -0300 (BRT) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Wed, 27 Jun 2012 17:23:04 -0300 Message-Id: <1340828587-15201-9-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.25 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 08/11] acpi_table_add(): eliminate 'start' 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 The 'start' variable is initialized with the value of 'acpi_tables_len', but neither 'acpi_tables_len' or 'start' are changed during the acpi_table_add() call (except at the end of the function), so 'start' can be simply replaced by 'acpi_tables_len'. No behavior change, just calculation methods changed. Signed-off-by: Eduardo Habkost --- hw/acpi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/acpi.c b/hw/acpi.c index e116528..251c770 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -189,7 +189,6 @@ static int acpi_make_table_header(const char *t, bool has_header, char *f, int acpi_table_add(const char *t) { char buf[1024], *f; - size_t start; size_t newlen; /* length of the new table */ bool has_header; int r; @@ -214,8 +213,7 @@ int acpi_table_add(const char *t) init_acpi_tables(); - start = acpi_tables_len; - acpi_tables = g_realloc(acpi_tables, start + ACPI_TABLE_HDR_SIZE); + acpi_tables = g_realloc(acpi_tables, acpi_tables_len + ACPI_TABLE_HDR_SIZE); newlen = has_header ? ACPI_TABLE_PFX_SIZE : ACPI_TABLE_HDR_SIZE; /* now read in the data files, reallocating buffer as needed */ @@ -234,8 +232,9 @@ int acpi_table_add(const char *t) if (r == 0) { break; } else if (r > 0) { - acpi_tables = g_realloc(acpi_tables, start + newlen + r); - memcpy(acpi_tables + start + newlen, data, r); + acpi_tables = g_realloc(acpi_tables, acpi_tables_len + newlen + + r); + memcpy(acpi_tables + acpi_tables_len + newlen, data, r); newlen += r; } else if (errno != EINTR) { fprintf(stderr, "can't read file %s: %s\n", @@ -250,7 +249,7 @@ int acpi_table_add(const char *t) /* now fill in the header fields */ - f = acpi_tables + start; /* start of the table */ + f = acpi_tables + acpi_tables_len; /* start of the table */ if (acpi_make_table_header(t, has_header, f, newlen) < 0) { return -1; @@ -260,7 +259,7 @@ int acpi_table_add(const char *t) (*(uint16_t *)acpi_tables) = cpu_to_le32(le32_to_cpu(*(uint16_t *)acpi_tables) + 1); - acpi_tables_len = start + newlen; + acpi_tables_len += newlen; return 0; }