From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=203.18.50.4; helo=nat-hk.nvidia.com; envelope-from=jbrasen@nvidia.com; receiver=edk2-devel@lists.01.org Received: from nat-hk.nvidia.com (nat-hk.nvidia.com [203.18.50.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0E79A21A07A80 for ; Thu, 8 Nov 2018 08:53:21 -0800 (PST) Received: from hkpgpgate102.nvidia.com (Not Verified[10.18.92.77]) by nat-hk.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 09 Nov 2018 00:53:20 +0800 Received: from HKMAIL102.nvidia.com ([10.18.16.11]) by hkpgpgate102.nvidia.com (PGP Universal service); Thu, 08 Nov 2018 08:53:19 -0800 X-PGP-Universal: processed; by hkpgpgate102.nvidia.com on Thu, 08 Nov 2018 08:53:19 -0800 Received: from DRBGMAIL103.nvidia.com (10.18.16.22) by HKMAIL102.nvidia.com (10.18.16.11) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 8 Nov 2018 16:53:18 +0000 Received: from HKMAIL104.nvidia.com (10.18.16.13) by DRBGMAIL103.nvidia.com (10.18.16.22) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 8 Nov 2018 16:53:17 +0000 Received: from NAM05-CO1-obe.outbound.protection.outlook.com (216.32.181.88) by HKMAIL104.nvidia.com (10.18.16.13) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Thu, 8 Nov 2018 16:53:16 +0000 Received: from DM5PR12MB2439.namprd12.prod.outlook.com (52.132.141.32) by DM5PR12MB1179.namprd12.prod.outlook.com (10.168.236.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1294.27; Thu, 8 Nov 2018 16:52:56 +0000 Received: from DM5PR12MB2439.namprd12.prod.outlook.com ([fe80::d0a8:220b:4ebc:35e2]) by DM5PR12MB2439.namprd12.prod.outlook.com ([fe80::d0a8:220b:4ebc:35e2%4]) with mapi id 15.20.1294.034; Thu, 8 Nov 2018 16:52:56 +0000 From: Jeff Brasen To: Ard Biesheuvel , Leif Lindholm CC: "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() Thread-Index: AQHUcJfrXcw0NO+210KzJUgPbBvZnaVFxxcAgABdxFM= Date: Thu, 8 Nov 2018 16:52:56 +0000 Message-ID: References: , In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=jbrasen@nvidia.com; x-originating-ip: [216.228.112.22] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR12MB1179; 6:DAzg5ZpS4d78N8lCwohVMKkH5qCO/wnGwtDw9IP+Kd9WfnZImydqG2GjI1xutBPcaz0MflLUYZ+doMK1pu+XyGrv6S+uX4KEvUhWp+IXlwI1GMERyyU0bRbJjStvdI0p4m9HJgVmDCoywgt8rOjZDDb8nUBQgPQbPxhBQilzYnqYAfIsyyaS6D/RrzDAoQoaDwTf2Egq59+qmSn6/d25jzeFBqaE8tmlFhnXr2kEg36KSmU6Fkrazqs47Tn+mbpNmWf0Nb/Wr+bhEqhpDNWLBAiHHZhqayBqCRaJNKBhRkdGibUhAB4tv/3u5rwKTXCErQXhUg9/cWKXPLGnGhhfZ1t6hxd8YmqQ7ZCVxSlN9iYfhwTNA/mOLQYtVF7qfWRrCUMAcUaGee2auNdl4S2ipajqHZh2mj9ZT8J5ETFJsm5fFXFrczN/280gR4r2ZGabVmYQbnQk4YsTOWUM8DSsZQ==; 5:ZlsjESAbFX8pZh25on3lvXM6xC+wT2RcAolm//2WNXE5/Eo0kZgsZ/v1wE8km0uHIUIEq4cqtkWMWqTfI9pPgIn8JjywVY8qKtEENsXMOpgvnIAqHJRdnrnQeZudsU8VODNajbnlpo4cx/XJ3YS2qr59k5zTWhlPRWkB31o6zTs=; 7:504nH07DIPYuXtKZEwFKPv578OvjtvIS3rDYjMvmnZODeZuolGPhIUDbABKN01eXWqgfwNi5N/b09DCLpeoVke4h+8O8E2jPrT2/HlNgn2oGIhv7ZOw4uHKhNc1UprgHYPDEuV3E+0AZQA/psdWaOA== x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 430c724a-4697-47b7-1906-08d6459aa20c x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:DM5PR12MB1179; x-ms-traffictypediagnostic: DM5PR12MB1179: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(162533806227266)(18589796830644); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231382)(944501410)(52105095)(148016)(149066)(150057)(6041310)(20161123558120)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:DM5PR12MB1179; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1179; x-forefront-prvs: 0850800A29 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6029001)(366004)(396003)(376002)(346002)(136003)(39860400002)(189003)(199004)(186003)(2906002)(86362001)(478600001)(6606003)(229853002)(7696005)(6436002)(6506007)(33656002)(1015004)(99286004)(26005)(102836004)(53546011)(76176011)(316002)(110136005)(6116002)(3846002)(256004)(14444005)(5660300001)(2900100001)(19627405001)(25786009)(4326008)(97736004)(106356001)(81156014)(68736007)(105586002)(74316002)(71200400001)(71190400001)(966005)(236005)(55016002)(54896002)(14454004)(6306002)(9686003)(606006)(66066001)(7736002)(486006)(81166006)(446003)(6246003)(8676002)(53936002)(476003)(11346002)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1179; H:DM5PR12MB2439.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: pcvqY88vZZB8auIDTwbjK+OoWGCOzZBhGseo+lwrn00Gb6pqBbdAjVmb1Q4voylkaQTDxy8VRqnUW6eiAcLEBUx3oJrTh/e8+4+7ByHLpH2QoV59zw1OkbjrdsB4uk4Qg3gRl4OuwzwPvXcLwx0HokWUbqYO4MEEGuVFgZ3mQnvOP1AgvXWsPaXu2Uf6MU6wzJF6bLBTLm8eG9TjQqxq4kGybHxCLMP1FsdDD6hki4SgAaKxInNT3mq6ki9O3P57S9iO0NB6iogdYoWDKUUEGfNd6KdIGOSLryWu0fxncvq8rBv3tGjhnyU7pcdjzEOksHZ3YOv8XfSV+xcXghftWC+buC9bE+daWa2nMGA6X3k= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 430c724a-4697-47b7-1906-08d6459aa20c X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Nov 2018 16:52:56.5173 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1179 X-OriginatorOrg: Nvidia.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1541696001; bh=y0yL2R5NT876SegFoSye4rEi9C2Y7iJbQ7TY/v9vcSw=; h=X-PGP-Universal:From:To:CC:Subject:Thread-Topic:Thread-Index:Date: Message-ID:References:In-Reply-To:Accept-Language:X-MS-Has-Attach: X-MS-TNEF-Correlator:authentication-results:x-originating-ip: x-ms-publictraffictype:x-microsoft-exchange-diagnostics: x-ms-exchange-antispam-srfa-diagnostics: x-ms-office365-filtering-correlation-id:x-microsoft-antispam: x-ms-traffictypediagnostic:x-microsoft-antispam-prvs: x-exchange-antispam-report-test:x-ms-exchange-senderadcheck: x-exchange-antispam-report-cfa-test:x-forefront-prvs: x-forefront-antispam-report:received-spf: x-microsoft-antispam-message-info:spamdiagnosticoutput: spamdiagnosticmetadata:MIME-Version: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-originalarrivaltime: X-MS-Exchange-CrossTenant-fromentityheader: X-MS-Exchange-CrossTenant-id: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg: Content-Language:Content-Type; b=j3qa+vbstP44Mj49ZY3gj8Shaqsbo69nqcNewYsu9csrzYhgG6Jq/k5So32+lIkLw dZ1u2hUW+Y7VyI2hMrnE0U+50/7ByQjnhWb1fx3c2M1zQw4o+1YSqspGWK0KdQCyy7 flX4kpMjo6In7VvhwKF2meOOEQ/Vo3W9Xi51FsHd90mag+X7xg5u+CA4B42sUP6zwP hr+Br/oud8oiiCfnEbESwt12OwwWnqSoxyJAZ6eJyGW4w/jQL+1H4kDLVIKCqH71ik xHRXnwRcKVpwpsIfrIizAkpSqAmZtd+ZXZLCLIOyTQtoVSrZP+bwrv/KdqQ7bazAmN d8zbF/AsJkLGg== X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Added AllocateZeroPool() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Nov 2018 16:53:22 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ________________________________ From: Ard Biesheuvel Sent: Thursday, November 8, 2018 4:13 AM To: Jeff Brasen; Leif Lindholm Cc: edk2-devel@lists.01.org Subject: Re: [edk2] [PATCH 1/2] EmbeddedPkg/PrePiMemoryAllocationLib: Add= ed AllocateZeroPool() On 30 October 2018 at 22:30, Jeff Brasen wrote: > This function is exposed by the MemoryAllocationLib header. > An AllocateZeroPool() function has been added to fix modules depending = on > this library and this function. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jeff Brasen > --- > .../PrePiMemoryAllocationLib/MemoryAllocationLib.c | 32 ++++++++++++++= ++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocat= ionLib.c b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationL= ib.c > index 0e75e23..f93f9cf 100644 > --- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.= c > +++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/MemoryAllocationLib.= c > @@ -16,6 +16,7 @@ > #include > > #include > +#include > #include > #include > > @@ -195,6 +196,37 @@ AllocatePool ( > } > > /** > + Allocates and zeros a buffer of type EfiBootServicesData. > + > + Allocates the number bytes specified by AllocationSize of type EfiBo= otServicesData, clears the > + buffer with zeros, and returns a pointer to the allocated buffer. I= f AllocationSize is 0, then a > + valid buffer of 0 size is returned. I guess this is just boilerplate, but what on earth is 'a valid buffer of 0 size'? [JB] Copied this from the MemoryAllocationLib but allocate with create cr= eates a free-able buffer is created with a unique pointer but you can't r= ead/write to it (as it has no . > If there is not enough memory remaining to satisfy the > + request, then NULL is returned. > + > + @param AllocationSize The number of bytes to allocate and ze= ro. > + > + @return A pointer to the allocated buffer or NULL if allocation fail= s. > + > +**/ > +VOID * > +EFIAPI > +AllocateZeroPool ( > + IN UINTN AllocationSize > + ) > +{ > + VOID *Buffer; > + > + Buffer =3D AllocatePool (AllocationSize); > + if (NULL =3D=3D Buffer) { Please don't use Yoda speak [JB] Will update, habit of mine from before compilers would generally rep= ort a warning for assignments in if statements. > + return NULL; > + } > + > + SetMem (Buffer, AllocationSize, 0); > + > + return Buffer; > +} > + > +/** > Frees a buffer that was previously allocated with one of the pool al= location functions in the > Memory Allocation Library. > > -- > 2.7.4 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel Thanks, Jeff Thanks, Jeff -------------------------------------------------------------------------= ---------- This email message is for the sole use of the intended recipient(s) and m= ay contain confidential information. Any unauthorized review, use, disclosure or di= stribution is prohibited. If you are not the intended recipient, please contact the= =20sender by reply email and destroy all copies of the original message. -------------------------------------------------------------------------= ----------