From patchwork Mon Sep 19 08:13:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 76516 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp837963qgf; Mon, 19 Sep 2016 01:14:05 -0700 (PDT) X-Received: by 10.98.157.199 with SMTP id a68mr45203970pfk.75.1474272845108; Mon, 19 Sep 2016 01:14:05 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id y68si62915303pfk.180.2016.09.19.01.14.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Sep 2016 01:14:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 85F341A1E30; Mon, 19 Sep 2016 01:14:03 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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 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: [edk2] [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: , Cc: vishalo@qti.qualcomm.com, leif.lindholm@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(+) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel 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);