From patchwork Tue Jul 29 22:26:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 34494 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9D3A820DCC for ; Tue, 29 Jul 2014 22:27:47 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id tr6sf2151565ieb.2 for ; Tue, 29 Jul 2014 15:27:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=PBua5xjyHj63ZfUW7rldetdvXG0Ls7shtRbUhz3NUhA=; b=AOglDTBClj4tq//0zDunvw3ksuXQ6A9ldXu3w7CFqgdvM5DK8m93ugR/gKTF0JPTmS 0pAnBW5Driesnwww5V7V16DnPsKSNMyBVebZ4EMeOxxEgR+jD1uEhSC847rpbhn0AE13 /+tpsku1K53uGZvXb4p1+Imq4C4i90mXBqdt/n1KXh1gmnWlSPEJLxHq5ERNkfHKIElY Vb3IDV6FAa53BVguM4SFAjzeB55SxthOiKpUnPorj0xJdrWrA3n4I6chDSkpQ2SivvWy E2fc7d3al42S+gyqrLDy2I240UmGHj2jsPWIA8rGgYXncZNhDFe5jPMYpngcV9QDrWtA jMSA== X-Gm-Message-State: ALoCoQnuQBvPiiNDogcFQj+3i1xcpree6sMX5HgTyA0DD9SNoivJDP6/Ax1V7bh93Hw5QzBe+2ji X-Received: by 10.50.62.8 with SMTP id u8mr14874065igr.1.1406672866590; Tue, 29 Jul 2014 15:27:46 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.21.203 with SMTP id 69ls339485qgl.13.gmail; Tue, 29 Jul 2014 15:27:46 -0700 (PDT) X-Received: by 10.220.73.137 with SMTP id q9mr51104vcj.64.1406672866397; Tue, 29 Jul 2014 15:27:46 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id cz8si226692vcb.88.2014.07.29.15.27.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Jul 2014 15:27:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so584889vcb.15 for ; Tue, 29 Jul 2014 15:27:46 -0700 (PDT) X-Received: by 10.220.15.8 with SMTP id i8mr4831311vca.45.1406672866297; Tue, 29 Jul 2014 15:27:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp277482vcb; Tue, 29 Jul 2014 15:27:45 -0700 (PDT) X-Received: by 10.50.136.167 with SMTP id qb7mr1062522igb.31.1406672865687; Tue, 29 Jul 2014 15:27:45 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id hj4si27693812igb.55.2014.07.29.15.27.45 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 29 Jul 2014 15:27:45 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XCFru-0002ry-2s; Tue, 29 Jul 2014 22:27:38 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XCFr3-0002ow-Or for edk2-devel@lists.sourceforge.net; Tue, 29 Jul 2014 22:26:45 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=lersek@redhat.com; helo=mx1.redhat.com; Received: from mx1.redhat.com ([209.132.183.28]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1XCFr2-0006eD-No for edk2-devel@lists.sourceforge.net; Tue, 29 Jul 2014 22:26:45 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6TMQbve020668 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Jul 2014 18:26:37 -0400 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-55.ams2.redhat.com [10.36.116.55]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6TMQYWs027236; Tue, 29 Jul 2014 18:26:36 -0400 From: Laszlo Ersek To: edk2-devel@lists.sourceforge.net, Lowell_Dennis@Dell.com Date: Wed, 30 Jul 2014 00:26:31 +0200 Message-Id: <1406672792-7151-2-git-send-email-lersek@redhat.com> In-Reply-To: <1406672792-7151-1-git-send-email-lersek@redhat.com> References: <1406672792-7151-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Spam-Score: -2.2 (--) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1XCFr2-0006eD-No Subject: [edk2] [PATCH 1/2] ShellPkg: UpdateStdInStdOutStdErr(): extract WriteFileTag() X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lersek@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Drop TagBuffer in the process. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- .../Application/Shell/ShellParametersProtocol.c | 48 +++++++++++++++------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/ShellPkg/Application/Shell/ShellParametersProtocol.c b/ShellPkg/Application/Shell/ShellParametersProtocol.c index 7809a0e..88453a2 100644 --- a/ShellPkg/Application/Shell/ShellParametersProtocol.c +++ b/ShellPkg/Application/Shell/ShellParametersProtocol.c @@ -2,6 +2,7 @@ Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation, manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL. + Copyright (C) 2014, Red Hat, Inc. Copyright (c) 2013 Hewlett-Packard Development Company, L.P. Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials @@ -594,6 +595,36 @@ RemoveFileTag( } /** + Write the unicode file tag to the specified file. + + It is the caller's responsibility to ensure that + ShellInfoObject.NewEfiShellProtocol has been initialized before calling this + function. + + @param[in] FileHandle The file to write the unicode file tag to. + + @return Status code from ShellInfoObject.NewEfiShellProtocol->WriteFile. +**/ +STATIC +EFI_STATUS +WriteFileTag ( + IN SHELL_FILE_HANDLE FileHandle + ) +{ + CHAR16 FileTag; + UINTN Size; + EFI_STATUS Status; + + FileTag = gUnicodeFileTag; + Size = sizeof FileTag; + Status = ShellInfoObject.NewEfiShellProtocol->WriteFile (FileHandle, &Size, + &FileTag); + ASSERT (EFI_ERROR (Status) || Size == sizeof FileTag); + return Status; +} + + +/** Funcion will replace the current StdIn and StdOut in the ShellParameters protocol structure by parsing NewCommandLine. The current values are returned to the user. @@ -638,7 +669,6 @@ UpdateStdInStdOutStdErr( BOOLEAN OutAppend; BOOLEAN ErrAppend; UINTN Size; - CHAR16 TagBuffer[2]; SPLIT_LIST *Split; CHAR16 *FirstLocation; @@ -1050,13 +1080,7 @@ UpdateStdInStdOutStdErr( } Status = ShellOpenFileByName(StdErrFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE,0); if (!ErrAppend && ErrUnicode && !EFI_ERROR(Status)) { - // - // Write out the gUnicodeFileTag - // - Size = sizeof(CHAR16); - TagBuffer[0] = gUnicodeFileTag; - TagBuffer[1] = CHAR_NULL; - ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer); + Status = WriteFileTag (TempHandle); } if (!ErrUnicode && !EFI_ERROR(Status)) { TempHandle = CreateFileInterfaceFile(TempHandle, FALSE); @@ -1085,13 +1109,7 @@ UpdateStdInStdOutStdErr( if (StrStr(StdOutFileName, L"NUL")==StdOutFileName) { //no-op } else if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) { - // - // Write out the gUnicodeFileTag - // - Size = sizeof(CHAR16); - TagBuffer[0] = gUnicodeFileTag; - TagBuffer[1] = CHAR_NULL; - ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer); + Status = WriteFileTag (TempHandle); } else if (OutAppend) { // // Move to end of file