public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Hao A" <hao.a.wu@intel.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"Gao, Liming" <liming.gao@intel.com>
Cc: "vishalo@qti.qualcomm.com" <vishalo@qti.qualcomm.com>,
	"leif.lindholm@linaro.org" <leif.lindholm@linaro.org>
Subject: Re: [PATCH v2 2/3] MdePkg/BaseMemoryLib*: add missing ASSERT()s
Date: Tue, 20 Sep 2016 02:00:12 +0000	[thread overview]
Message-ID: <B80AF82E9BFB8E4FBD8C89DA810C6A092F2AFC1F@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <1474272831-20840-3-git-send-email-ard.biesheuvel@linaro.org>

Hi Ard,

The NULL checks for the input Guids in APIs CopyGuid(), CompareGuid() and
IsZeroGuid() are implicitly done within calls to BaseLib APIs
ReadUnaligned64() and WriteUnaligned64().

So I think the functions behavior matches with their comments. What do you
think?

Best Regards,
Hao Wu

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ard
> Biesheuvel
> Sent: Monday, September 19, 2016 4:14 PM
> To: edk2-devel@lists.01.org; Gao, Liming
> Cc: vishalo@qti.qualcomm.com; leif.lindholm@linaro.org; Ard Biesheuvel
> Subject: [edk2] [PATCH v2 2/3] MdePkg/BaseMemoryLib*: add missing
> ASSERT()s
> 
> Add the ASSERT() statements to CopyGuid (), CompareGuid() and
> IsZeroGuid() that are mentioned in the respective comments but
> were missing from the actual code.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  MdePkg/Library/BaseMemoryLib/MemLibGuid.c       | 8 ++++++++
>  MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c    | 8 ++++++++
>  MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c | 8 ++++++++
>  MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c | 8 ++++++++
>  MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c | 8 ++++++++
>  MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c   | 8 ++++++++
>  MdePkg/Library/PeiMemoryLib/MemLibGuid.c        | 8 ++++++++
>  MdePkg/Library/UefiMemoryLib/MemLibGuid.c       | 8 ++++++++
>  8 files changed, 64 insertions(+)
> 
> diff --git a/MdePkg/Library/BaseMemoryLib/MemLibGuid.c
> b/MdePkg/Library/BaseMemoryLib/MemLibGuid.c
> index b2590f83caef..dff9bde653a9 100644
> --- a/MdePkg/Library/BaseMemoryLib/MemLibGuid.c
> +++ b/MdePkg/Library/BaseMemoryLib/MemLibGuid.c
> @@ -47,6 +47,9 @@ CopyGuid (
>    IN CONST GUID  *SourceGuid
>    )
>  {
> +  ASSERT (DestinationGuid != NULL);
> +  ASSERT (SourceGuid != NULL);
> +
>    WriteUnaligned64 (
>      (UINT64*)DestinationGuid,
>      ReadUnaligned64 ((CONST UINT64*)SourceGuid)
> @@ -86,6 +89,9 @@ CompareGuid (
>    UINT64  HighPartOfGuid1;
>    UINT64  HighPartOfGuid2;
> 
> +  ASSERT (Guid1 != NULL);
> +  ASSERT (Guid2 != NULL);
> +
>    LowPartOfGuid1  = ReadUnaligned64 ((CONST UINT64*) Guid1);
>    LowPartOfGuid2  = ReadUnaligned64 ((CONST UINT64*) Guid2);
>    HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
> @@ -164,6 +170,8 @@ IsZeroGuid (
>    UINT64  LowPartOfGuid;
>    UINT64  HighPartOfGuid;
> 
> +  ASSERT (Guid != NULL);
> +
>    LowPartOfGuid  = ReadUnaligned64 ((CONST UINT64*) Guid);
>    HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1);
> 
> diff --git a/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c
> b/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c
> index cbb385fddfba..60babaf0dc49 100644
> --- a/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c
> +++ b/MdePkg/Library/BaseMemoryLibMmx/MemLibGuid.c
> @@ -47,6 +47,9 @@ CopyGuid (
>    IN CONST GUID  *SourceGuid
>    )
>  {
> +  ASSERT (DestinationGuid != NULL);
> +  ASSERT (SourceGuid != NULL);
> +
>    WriteUnaligned64 (
>      (UINT64*)DestinationGuid,
>      ReadUnaligned64 ((CONST UINT64*)SourceGuid)
> @@ -86,6 +89,9 @@ CompareGuid (
>    UINT64  HighPartOfGuid1;
>    UINT64  HighPartOfGuid2;
> 
> +  ASSERT (Guid1 != NULL);
> +  ASSERT (Guid2 != NULL);
> +
>    LowPartOfGuid1  = ReadUnaligned64 ((CONST UINT64*) Guid1);
>    LowPartOfGuid2  = ReadUnaligned64 ((CONST UINT64*) Guid2);
>    HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
> @@ -164,6 +170,8 @@ IsZeroGuid (
>    UINT64  LowPartOfGuid;
>    UINT64  HighPartOfGuid;
> 
> +  ASSERT (Guid != NULL);
> +
>    LowPartOfGuid  = ReadUnaligned64 ((CONST UINT64*) Guid);
>    HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1);
> 
> diff --git a/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c
> b/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c
> index cbb385fddfba..60babaf0dc49 100644
> --- a/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c
> +++ b/MdePkg/Library/BaseMemoryLibOptDxe/MemLibGuid.c
> @@ -47,6 +47,9 @@ CopyGuid (
>    IN CONST GUID  *SourceGuid
>    )
>  {
> +  ASSERT (DestinationGuid != NULL);
> +  ASSERT (SourceGuid != NULL);
> +
>    WriteUnaligned64 (
>      (UINT64*)DestinationGuid,
>      ReadUnaligned64 ((CONST UINT64*)SourceGuid)
> @@ -86,6 +89,9 @@ CompareGuid (
>    UINT64  HighPartOfGuid1;
>    UINT64  HighPartOfGuid2;
> 
> +  ASSERT (Guid1 != NULL);
> +  ASSERT (Guid2 != NULL);
> +
>    LowPartOfGuid1  = ReadUnaligned64 ((CONST UINT64*) Guid1);
>    LowPartOfGuid2  = ReadUnaligned64 ((CONST UINT64*) Guid2);
>    HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
> @@ -164,6 +170,8 @@ IsZeroGuid (
>    UINT64  LowPartOfGuid;
>    UINT64  HighPartOfGuid;
> 
> +  ASSERT (Guid != NULL);
> +
>    LowPartOfGuid  = ReadUnaligned64 ((CONST UINT64*) Guid);
>    HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1);
> 
> diff --git a/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c
> b/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c
> index cbb385fddfba..60babaf0dc49 100644
> --- a/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c
> +++ b/MdePkg/Library/BaseMemoryLibOptPei/MemLibGuid.c
> @@ -47,6 +47,9 @@ CopyGuid (
>    IN CONST GUID  *SourceGuid
>    )
>  {
> +  ASSERT (DestinationGuid != NULL);
> +  ASSERT (SourceGuid != NULL);
> +
>    WriteUnaligned64 (
>      (UINT64*)DestinationGuid,
>      ReadUnaligned64 ((CONST UINT64*)SourceGuid)
> @@ -86,6 +89,9 @@ CompareGuid (
>    UINT64  HighPartOfGuid1;
>    UINT64  HighPartOfGuid2;
> 
> +  ASSERT (Guid1 != NULL);
> +  ASSERT (Guid2 != NULL);
> +
>    LowPartOfGuid1  = ReadUnaligned64 ((CONST UINT64*) Guid1);
>    LowPartOfGuid2  = ReadUnaligned64 ((CONST UINT64*) Guid2);
>    HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
> @@ -164,6 +170,8 @@ IsZeroGuid (
>    UINT64  LowPartOfGuid;
>    UINT64  HighPartOfGuid;
> 
> +  ASSERT (Guid != NULL);
> +
>    LowPartOfGuid  = ReadUnaligned64 ((CONST UINT64*) Guid);
>    HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1);
> 
> diff --git a/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c
> b/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c
> index cbb385fddfba..60babaf0dc49 100644
> --- a/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c
> +++ b/MdePkg/Library/BaseMemoryLibRepStr/MemLibGuid.c
> @@ -47,6 +47,9 @@ CopyGuid (
>    IN CONST GUID  *SourceGuid
>    )
>  {
> +  ASSERT (DestinationGuid != NULL);
> +  ASSERT (SourceGuid != NULL);
> +
>    WriteUnaligned64 (
>      (UINT64*)DestinationGuid,
>      ReadUnaligned64 ((CONST UINT64*)SourceGuid)
> @@ -86,6 +89,9 @@ CompareGuid (
>    UINT64  HighPartOfGuid1;
>    UINT64  HighPartOfGuid2;
> 
> +  ASSERT (Guid1 != NULL);
> +  ASSERT (Guid2 != NULL);
> +
>    LowPartOfGuid1  = ReadUnaligned64 ((CONST UINT64*) Guid1);
>    LowPartOfGuid2  = ReadUnaligned64 ((CONST UINT64*) Guid2);
>    HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
> @@ -164,6 +170,8 @@ IsZeroGuid (
>    UINT64  LowPartOfGuid;
>    UINT64  HighPartOfGuid;
> 
> +  ASSERT (Guid != NULL);
> +
>    LowPartOfGuid  = ReadUnaligned64 ((CONST UINT64*) Guid);
>    HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1);
> 
> diff --git a/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c
> b/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c
> index cbb385fddfba..60babaf0dc49 100644
> --- a/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c
> +++ b/MdePkg/Library/BaseMemoryLibSse2/MemLibGuid.c
> @@ -47,6 +47,9 @@ CopyGuid (
>    IN CONST GUID  *SourceGuid
>    )
>  {
> +  ASSERT (DestinationGuid != NULL);
> +  ASSERT (SourceGuid != NULL);
> +
>    WriteUnaligned64 (
>      (UINT64*)DestinationGuid,
>      ReadUnaligned64 ((CONST UINT64*)SourceGuid)
> @@ -86,6 +89,9 @@ CompareGuid (
>    UINT64  HighPartOfGuid1;
>    UINT64  HighPartOfGuid2;
> 
> +  ASSERT (Guid1 != NULL);
> +  ASSERT (Guid2 != NULL);
> +
>    LowPartOfGuid1  = ReadUnaligned64 ((CONST UINT64*) Guid1);
>    LowPartOfGuid2  = ReadUnaligned64 ((CONST UINT64*) Guid2);
>    HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
> @@ -164,6 +170,8 @@ IsZeroGuid (
>    UINT64  LowPartOfGuid;
>    UINT64  HighPartOfGuid;
> 
> +  ASSERT (Guid != NULL);
> +
>    LowPartOfGuid  = ReadUnaligned64 ((CONST UINT64*) Guid);
>    HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1);
> 
> diff --git a/MdePkg/Library/PeiMemoryLib/MemLibGuid.c
> b/MdePkg/Library/PeiMemoryLib/MemLibGuid.c
> index cbb385fddfba..60babaf0dc49 100644
> --- a/MdePkg/Library/PeiMemoryLib/MemLibGuid.c
> +++ b/MdePkg/Library/PeiMemoryLib/MemLibGuid.c
> @@ -47,6 +47,9 @@ CopyGuid (
>    IN CONST GUID  *SourceGuid
>    )
>  {
> +  ASSERT (DestinationGuid != NULL);
> +  ASSERT (SourceGuid != NULL);
> +
>    WriteUnaligned64 (
>      (UINT64*)DestinationGuid,
>      ReadUnaligned64 ((CONST UINT64*)SourceGuid)
> @@ -86,6 +89,9 @@ CompareGuid (
>    UINT64  HighPartOfGuid1;
>    UINT64  HighPartOfGuid2;
> 
> +  ASSERT (Guid1 != NULL);
> +  ASSERT (Guid2 != NULL);
> +
>    LowPartOfGuid1  = ReadUnaligned64 ((CONST UINT64*) Guid1);
>    LowPartOfGuid2  = ReadUnaligned64 ((CONST UINT64*) Guid2);
>    HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
> @@ -164,6 +170,8 @@ IsZeroGuid (
>    UINT64  LowPartOfGuid;
>    UINT64  HighPartOfGuid;
> 
> +  ASSERT (Guid != NULL);
> +
>    LowPartOfGuid  = ReadUnaligned64 ((CONST UINT64*) Guid);
>    HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1);
> 
> diff --git a/MdePkg/Library/UefiMemoryLib/MemLibGuid.c
> b/MdePkg/Library/UefiMemoryLib/MemLibGuid.c
> index cbb385fddfba..60babaf0dc49 100644
> --- a/MdePkg/Library/UefiMemoryLib/MemLibGuid.c
> +++ b/MdePkg/Library/UefiMemoryLib/MemLibGuid.c
> @@ -47,6 +47,9 @@ CopyGuid (
>    IN CONST GUID  *SourceGuid
>    )
>  {
> +  ASSERT (DestinationGuid != NULL);
> +  ASSERT (SourceGuid != NULL);
> +
>    WriteUnaligned64 (
>      (UINT64*)DestinationGuid,
>      ReadUnaligned64 ((CONST UINT64*)SourceGuid)
> @@ -86,6 +89,9 @@ CompareGuid (
>    UINT64  HighPartOfGuid1;
>    UINT64  HighPartOfGuid2;
> 
> +  ASSERT (Guid1 != NULL);
> +  ASSERT (Guid2 != NULL);
> +
>    LowPartOfGuid1  = ReadUnaligned64 ((CONST UINT64*) Guid1);
>    LowPartOfGuid2  = ReadUnaligned64 ((CONST UINT64*) Guid2);
>    HighPartOfGuid1 = ReadUnaligned64 ((CONST UINT64*) Guid1 + 1);
> @@ -164,6 +170,8 @@ IsZeroGuid (
>    UINT64  LowPartOfGuid;
>    UINT64  HighPartOfGuid;
> 
> +  ASSERT (Guid != NULL);
> +
>    LowPartOfGuid  = ReadUnaligned64 ((CONST UINT64*) Guid);
>    HighPartOfGuid = ReadUnaligned64 ((CONST UINT64*) Guid + 1);
> 
> --
> 2.7.4
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


  reply	other threads:[~2016-09-20  2:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-19  8:13 [PATCH v2 0/3] MdePkg/BaseMemoryLibOptDxe: generic and ARM/AARCH64 fixes Ard Biesheuvel
2016-09-19  8:13 ` [PATCH v2 1/3] MdePkg/BaseMemoryLibOptDxe ARM: fix arithmetic bugs in CompareMem() Ard Biesheuvel
2016-09-19  8:13 ` [PATCH v2 2/3] MdePkg/BaseMemoryLib*: add missing ASSERT()s Ard Biesheuvel
2016-09-20  2:00   ` Wu, Hao A [this message]
2016-09-20  8:38     ` Ard Biesheuvel
2016-09-20 12:02       ` Wu, Hao A
2016-09-20 12:16         ` Ard Biesheuvel
2016-09-20 12:40           ` Ard Biesheuvel
2016-09-21  1:27             ` Gao, Liming
2016-09-19  8:13 ` [PATCH v2 3/3] MdePkg/BaseMemoryLibOptDxe ARM|AARCH64: implement accelerated GUID functions Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B80AF82E9BFB8E4FBD8C89DA810C6A092F2AFC1F@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox