From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com [IPv6:2a00:1450:400c:c09::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 42BDF1A1E30 for ; Mon, 19 Sep 2016 01:14:02 -0700 (PDT) Received: by mail-wm0-x231.google.com with SMTP id w84so62424389wmg.1 for ; Mon, 19 Sep 2016 01:14:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yG2v7mRF9qBSDNJM6TCUcn6D9qgV646KHGbjWpdVYVo=; b=TCi8XEPdKWnvwHdfuV0VHFAclY+7Lw13ZEbcqzaK+Ym3YDttLR6hxqlLDPZPHCCTB1 JXOQv2VDZrb8a90fDIFvcLoRSjnfuqNn6CMMoS0LGy49TgujMHlOjETKYWXK8jRKgZ3J VUjPNkynB574fzjgO5i0PLFvNA4ztaNJx1Ivc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yG2v7mRF9qBSDNJM6TCUcn6D9qgV646KHGbjWpdVYVo=; b=efepbwMD5AVmf/O6foOMH1weL2iKW2fHzv9lLds32MZVngvH9kzDwX/qiJ52dXqlko x3kEpt6i2g5l4SW7y8cDC1ZCV5p7HzxghPNLKRBtNVADCvkc5y04IY0TBLGLLP1Cc9aK lo+mGy05Tl22UUAWiTd3kg7+lyzskc6stFL4riYYnki3G2sauODSs73euY9P3YoctpOR kuJ9AC0PS91PiQT5gDNPzHw4o10f8CTzon/nnpmzlR3pUNI5JQ+dMXpqIVoZHc6mmf7I g8ycuwgiaQynM9Ul3HDAGT+uIaRTMRLOdNvrdFhHkLL7g7B6ywF0sv8f+DE+x0Fmxf7o YYqw== X-Gm-Message-State: AE9vXwMkwRpDxLM0LfVoCGAYjbIt5xJ53/0rVq24khdr+no/LKyH8kaKAqTpEt83djjkrxHY X-Received: by 10.28.92.71 with SMTP id q68mr7572600wmb.85.1474272840857; Mon, 19 Sep 2016 01:14:00 -0700 (PDT) Received: from localhost.localdomain ([160.161.71.58]) by smtp.gmail.com with ESMTPSA id lj2sm21679784wjc.38.2016.09.19.01.13.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 19 Sep 2016 01:14:00 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, liming.gao@intel.com Cc: leif.lindholm@linaro.org, vishalo@qti.qualcomm.com, Ard Biesheuvel Date: Mon, 19 Sep 2016 09:13:50 +0100 Message-Id: <1474272831-20840-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1474272831-20840-1-git-send-email-ard.biesheuvel@linaro.org> References: <1474272831-20840-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [PATCH v2 2/3] MdePkg/BaseMemoryLib*: add missing ASSERT()s X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Sep 2016 08:14:02 -0000 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 --- 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