From patchwork Fri Jul 12 00:06:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 258666 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id F268D2C032D for ; Fri, 12 Jul 2013 10:06:14 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UxQsF-0000Bh-Pw; Fri, 12 Jul 2013 00:06:11 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UxQsA-0000B5-BI for fwts-devel@lists.ubuntu.com; Fri, 12 Jul 2013 00:06:06 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1UxQsA-00046I-5a for fwts-devel@lists.ubuntu.com; Fri, 12 Jul 2013 00:06:06 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] fwts_iasl_interface.c: ensure we read in all of stdout (LP: #1200426) Date: Fri, 12 Jul 2013 01:06:05 +0100 Message-Id: <1373587565-15149-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.8.1.2 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Redirecting stdout to a file when running the syntaxcheck test results in no failures. We need to ensure we fflush on stdout to flush the IASL output on stdout down the pipe to the reading parent process. This patch also ensures we check for NULL on realloc. Also fixes an incorrect stdout fd check on pipefds[0] and removes an unnecessary close on pipefds[1] on the child process. Took the opportunity to do some white space cleanup and a general tidy up of the code too. Must of had a bad day when I originally wrote this code. Signed-off-by: Colin Ian King Acked-by: Alex Hung Acked-by: Keng-Yu Lin --- src/acpica/source/compiler/fwts_iasl_interface.c | 64 +++++++++++++++--------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/src/acpica/source/compiler/fwts_iasl_interface.c b/src/acpica/source/compiler/fwts_iasl_interface.c index 84670e4..206e0c8 100644 --- a/src/acpica/source/compiler/fwts_iasl_interface.c +++ b/src/acpica/source/compiler/fwts_iasl_interface.c @@ -33,7 +33,7 @@ static void init_asl_core(void) AcpiDbgLevel = 0; - for (i=0; i 0) { data = realloc(data, len + n + 1); + if (data == NULL) { + ret = -1; + break; + } memcpy(data + len, buffer, n); len += n; - data[len] = 0; + data[len] = '\0'; } - waitpid(pid, &status, WUNTRACED | WCONTINUED); - close(pipefds[0]); + (void)waitpid(pid, &status, WUNTRACED | WCONTINUED); + (void)close(pipefds[0]); + break; } *output = data; - return 0; + return ret; }