From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web12.1440.1579201646854129787 for ; Thu, 16 Jan 2020 11:07:27 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TXeXP8cY; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579201645; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OCyU6vy1vb2wlWwNhBOx4QGbtE7FcKVuEJauRAwmpG4=; b=TXeXP8cYUCwSaQoqawdQOVxZGq30KX21qFhsQhUSkGW6x4hiKRQ8XAHmmatY6fX0g5ejRM KM6GkFTeQTVnEuEcp8a9OIwNUZt9fqQxE8RUanaR0e+SHk9m3BPrEGlaTVlEUldmcpk2Gb Y+ViLR29pJkNqzxM09kUfM0ZhOZJ9gI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-31-W_luB2xzPB6nLOBmxVChNQ-1; Thu, 16 Jan 2020 14:07:22 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5E55800EBF; Thu, 16 Jan 2020 19:07:20 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-120.ams2.redhat.com [10.36.116.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8785C80890; Thu, 16 Jan 2020 19:07:19 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Chao Zhang , Jian J Wang , Jiewen Yao Subject: [PATCH 08/11] SecurityPkg/DxeImageVerificationHandler: eliminate "Status" variable Date: Thu, 16 Jan 2020 20:07:02 +0100 Message-Id: <20200116190705.18816-9-lersek@redhat.com> In-Reply-To: <20200116190705.18816-1-lersek@redhat.com> References: <20200116190705.18816-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: W_luB2xzPB6nLOBmxVChNQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: base64 VGhlICJTdGF0dXMiIHZhcmlhYmxlIGlzIHNldCB0byBFRklfQUNDRVNTX0RFTklFRCBhdCB0aGUg dG9wIG9mIHRoZQpmdW5jdGlvbi4gVGhlbiBpdCBpcyBvdmVyd3JpdHRlbiB3aXRoIEVGSV9TRUNV UklUWV9WSU9MQVRJT04gdW5kZXIgdGhlCiJGYWlsZWQiIChlYXJsaWVyOiAiRG9uZSIpIGxhYmVs LiBXZSBmaW5hbGx5IHJldHVybiAiU3RhdHVzIi4KClRoZSBhYm92ZSBjb3ZlcnMgdGhlIGNvbXBs ZXRlIHVzYWdlIG9mICJTdGF0dXMiIGluCkR4ZUltYWdlVmVyaWZpY2F0aW9uSGFuZGxlcigpLiBS ZW1vdmUgdGhlIHZhcmlhYmxlLCBhbmQgc2ltcGx5IHJldHVybgpFRklfU0VDVVJJVFlfVklPTEFU SU9OIGluIHRoZSBlbmQuCgpUaGlzIHBhdGNoIGlzIGEgbm8tb3AsIHJlZ2FyZGluZyBiZWhhdmlv ci4KCkNjOiBDaGFvIFpoYW5nIDxjaGFvLmIuemhhbmdAaW50ZWwuY29tPgpDYzogSmlhbiBKIFdh bmcgPGppYW4uai53YW5nQGludGVsLmNvbT4KQ2M6IEppZXdlbiBZYW8gPGppZXdlbi55YW9AaW50 ZWwuY29tPgpSZWY6IGh0dHBzOi8vYnVnemls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iAgVUlOVE4gICAgICAgICAgICAgICAgICAg ICAgICAgICAgRmlsZVNpemUsDQogICBJTiAgQk9PTEVBTiAgICAgICAgICAgICAgICAgICAgICAg ICAgQm9vdFBvbGljeQ0KICAgKQ0KIHsNCi0gIEVGSV9TVEFUVVMgICAgICAgICAgICAgICAgICAg ICAgICAgICBTdGF0dXM7DQogICBFRklfSU1BR0VfRE9TX0hFQURFUiAgICAgICAgICAgICAgICAg KkRvc0hkcjsNCiAgIEJPT0xFQU4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICBJc1Zlcmlm aWVkOw0KICAgRUZJX1NJR05BVFVSRV9MSVNUICAgICAgICAgICAgICAgICAgICpTaWduYXR1cmVM aXN0Ow0KICAgVUlOVE4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNpZ25hdHVyZUxp c3RTaXplOw0KICAgRUZJX1NJR05BVFVSRV9EQVRBICAgICAgICAgICAgICAgICAgICpTaWduYXR1 cmU7DQogICBFRklfSU1BR0VfRVhFQ1VUSU9OX0FDVElPTiAgICAgICAgICAgQWN0aW9uOw0KICAg V0lOX0NFUlRJRklDQVRFICAgICAgICAgICAgICAgICAgICAgICpXaW5DZXJ0aWZpY2F0ZTsNCiAg IFVJTlQzMiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBQb2xpY3k7DQogICBVSU5UOCAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKlNlY3VyZUJvb3Q7DQogICBQRV9DT0ZGX0xP QURFUl9JTUFHRV9DT05URVhUICAgICAgICAgSW1hZ2VDb250ZXh0Ow0KICAgVUlOVDMyICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIE51bWJlck9mUnZhQW5kU2l6ZXM7DQogICBXSU5fQ0VS VElGSUNBVEVfRUZJX1BLQ1MgICAgICAgICAgICAgKlBrY3NDZXJ0RGF0YTsNCiAgIFdJTl9DRVJU SUZJQ0FURV9VRUZJX0dVSUQgICAgICAgICAgICAqV2luQ2VydFVlZmlHdWlkOw0KICAgVUlOVDgg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICpBdXRoRGF0YTsNCiAgIFVJTlROICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICBBdXRoRGF0YVNpemU7DQogICBFRklfSU1BR0VfREFU QV9ESVJFQ1RPUlkgICAgICAgICAgICAgKlNlY0RhdGFEaXI7DQogICBVSU5UMzIgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgT2ZmU2V0Ow0KICAgQ0hBUjE2ICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICpOYW1lU3RyOw0KICAgUkVUVVJOX1NUQVRVUyAgICAgICAgICAgICAgICAg ICAgICAgIFBlQ29mZlN0YXR1czsNCiAgIEVGSV9TVEFUVVMgICAgICAgICAgICAgICAgICAgICAg ICAgICBIYXNoU3RhdHVzOw0KIA0KICAgU2lnbmF0dXJlTGlzdCAgICAgPSBOVUxMOw0KICAgU2ln bmF0dXJlTGlzdFNpemUgPSAwOw0KICAgV2luQ2VydGlmaWNhdGUgICAgPSBOVUxMOw0KICAgU2Vj RGF0YURpciAgICAgICAgPSBOVUxMOw0KICAgUGtjc0NlcnREYXRhICAgICAgPSBOVUxMOw0KICAg QWN0aW9uICAgICAgICAgICAgPSBFRklfSU1BR0VfRVhFQ1VUSU9OX0FVVEhfVU5URVNURUQ7DQot ICBTdGF0dXMgICAgICAgICAgICA9IEVGSV9BQ0NFU1NfREVOSUVEOw0KICAgSXNWZXJpZmllZCAg ICAgICAgPSBGQUxTRTsNCiANCiANCiAgIC8vDQogICAvLyBDaGVjayB0aGUgaW1hZ2UgdHlwZSBh bmQgZ2V0IHBvbGljeSBzZXR0aW5nLg0KICAgLy8NCiAgIHN3aXRjaCAoR2V0SW1hZ2VUeXBlIChG aWxlKSkgew0KIA0KICAgY2FzZSBJTUFHRV9GUk9NX0ZWOg0KICAgICBQb2xpY3kgPSBBTFdBWVNf RVhFQ1VURTsNCiAgICAgYnJlYWs7DQogDQogICBjYXNlIElNQ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