From nobody Wed May 8 14:10:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+43823+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43823+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1563317973; cv=none; d=zoho.com; s=zohoarc; b=WH37WIo+r48gcLftTJwx4hEO5SBKphDYvb8zYiUwar32oSWCYfGNCeMD1HRo0cvaQ1cjUJbRoUYUA8oZ7G/q5m7QaqxRLsp4S9gcyyUDpejnT7KzCt5hLpcvMfVRqfwmXODyiacmzLW8PzZx8v0NwnlAbu5Yis+LlVwDESjvFs0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563317973; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=XqHgLN+8YzpQyqX34i0iJuJlKhSFyGNzp3vcc5cLqXI=; b=mX5hVr2HHLDcl1qB4NHCuHQ8hwSckzjLcgv2ERBUiU0ByXLhg7KV2gf3fQTPZTq4X94FAcF55vR3uxfJ/DjULue17x3U0k5vaU4voW8xekWZDfGjpJtKbAmaJzCh0hLHEb2l/Lk6KdrWxgQGj+ZLZFiSXP6k3eIdiXoUv3JV9ik= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+43823+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1563317973499407.7772103383817; Tue, 16 Jul 2019 15:59:33 -0700 (PDT) Return-Path: X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 16 Jul 2019 15:59:32 -0700 X-Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B777307D90D; Tue, 16 Jul 2019 22:59:32 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-187.ams2.redhat.com [10.36.117.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F08260C4C; Tue, 16 Jul 2019 22:59:28 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Liming Gao , Michael D Kinney , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhichao Gao Subject: [edk2-devel] [PATCH] MdePkg/BaseLib: Base64Decode(): don't declare variables in nested blocks Date: Wed, 17 Jul 2019 00:59:26 +0200 Message-Id: <20190716225926.19732-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 16 Jul 2019 22:59:32 +0000 (UTC) Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,lersek@redhat.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1563317973; bh=NOpXTZME+TVBsMGfgBIQTE2IqSX/DVnRe1xgRkv5t50=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=CZekq4s7i40bB3g8yoshA3Sj8dlNdF1ALFJ7EUDhhtfsLHPUeHuPlnjrNee8iBJgjFO m91M0zaUeq3GNqjBF0wDU4J1zVJigZqBwIJw9rgp+tPDm7/ZqCCu3m/XsuFX4RTYeP+pH CCFrWL4DwU8sSPdH1JXGrkDYld+yTGEwC34= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The EDK II C Coding Standards Specification (v2.20) strongly discourages variable declarations in nested block scope: 5 Source Files 5.4 Code File Structure 5.4.1 Scoping Rules 5.4.1.1 Scope > Block (local) Scope > > [...] > > Data declarations may follow the opening brace of a compound statement, > regardless of nesting depth, and before any code generating statements > have been entered. Other than at the outermost block of a function body, > this type of declaration is strongly discouraged. Hoist such variable declarations in Base64Decode() to the outermost function scope. Cc: Liming Gao Cc: Michael D Kinney Cc: Philippe Mathieu-Daud=C3=A9 Cc: Zhichao Gao Fixes: 35e242b698cdc6205e99a6d6a188bf27fecf9fb4 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1980 Reported-by: Zhichao Gao Signed-off-by: Laszlo Ersek Reviewed-by: Liming Gao Reviewed-by: Philippe Mathieu-Daude Reviewed-by: Rebecca Cran Tested-by: Philippe Mathieu-Daude --- Notes: Repo: https://github.com/lersek/edk2.git Branch: b64_decode_no_nested_bz1980 MdePkg/Library/BaseLib/String.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/Strin= g.c index 6198ccbc9672..45198373f25c 100644 --- a/MdePkg/Library/BaseLib/String.c +++ b/MdePkg/Library/BaseLib/String.c @@ -1978,6 +1978,9 @@ Base64Decode ( UINT32 Accumulator; UINTN OriginalDestinationSize; UINTN SourceIndex; + CHAR8 SourceChar; + UINT32 Base64Value; + UINT8 DestinationOctet; =20 if (DestinationSize =3D=3D NULL) { return RETURN_INVALID_PARAMETER; @@ -2054,10 +2057,6 @@ Base64Decode ( // Decoding loop. // for (SourceIndex =3D 0; SourceIndex < SourceSize; SourceIndex++) { - CHAR8 SourceChar; - UINT32 Base64Value; - UINT8 DestinationOctet; - SourceChar =3D Source[SourceIndex]; =20 // --=20 2.19.1.3.g30247aa5d201 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#43823): https://edk2.groups.io/g/devel/message/43823 Mute This Topic: https://groups.io/mt/32497166/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-