public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pedro Falcato" <pedro.falcato@gmail.com>
To: devel@edk2.groups.io
Cc: Pedro Falcato <pedro.falcato@gmail.com>,
	Jian J Wang <jian.j.wang@intel.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	Hao A Wu <hao.a.wu@intel.com>, Ray Ni <ray.ni@intel.com>,
	Laszlo Ersek <lersek@redhat.com>
Subject: [PATCH v3 04/12] MdeModulePkg/SataControllerDxe: Fix up ASSERTS (Private != NULL)
Date: Thu,  1 Jun 2023 18:27:32 +0100	[thread overview]
Message-ID: <20230601172740.9165-5-pedro.falcato@gmail.com> (raw)
In-Reply-To: <20230601172740.9165-1-pedro.falcato@gmail.com>

ASSERT (Private != NULL) (where Private = CR(...)) is ineffective as
CR(Ptr, Type, Member, Sig) either returns Ptr - offsetof(Type, Member),
or ASSERTS on the signature, so it's unlikely to ever return NULL
(must be passed a pointer = member's offset, or in this case, 0x4).

ASSERT on This != NULL instead.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
---
 MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
index f0ffd311d7b9..ea0116071c6a 100644
--- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
+++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
@@ -611,7 +611,6 @@ SataControllerStop (
   }
 
   Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (IdeInit);
-  ASSERT (Private != NULL);
 
   //
   // Uninstall the IDE Controller Init Protocol from this instance
@@ -745,8 +744,8 @@ IdeInitGetChannelInfo (
 {
   EFI_SATA_CONTROLLER_PRIVATE_DATA  *Private;
 
+  ASSERT (This != NULL);
   Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
-  ASSERT (Private != NULL);
 
   if (Channel < This->ChannelCount) {
     *Enabled    = TRUE;
@@ -845,8 +844,8 @@ IdeInitSubmitData (
   EFI_SATA_CONTROLLER_PRIVATE_DATA  *Private;
   UINTN                             DeviceIndex;
 
+  ASSERT (This != NULL);
   Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
-  ASSERT (Private != NULL);
 
   if ((Channel >= This->ChannelCount) || (Device >= Private->DeviceCount)) {
     return EFI_INVALID_PARAMETER;
@@ -924,8 +923,8 @@ IdeInitDisqualifyMode (
   EFI_SATA_CONTROLLER_PRIVATE_DATA  *Private;
   UINTN                             DeviceIndex;
 
+  ASSERT (This != NULL);
   Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
-  ASSERT (Private != NULL);
 
   if ((Channel >= This->ChannelCount) || (BadModes == NULL) || (Device >= Private->DeviceCount)) {
     return EFI_INVALID_PARAMETER;
@@ -1017,8 +1016,8 @@ IdeInitCalculateMode (
   EFI_STATUS                        Status;
   UINTN                             DeviceIndex;
 
+  ASSERT (This != NULL);
   Private = SATA_CONTROLLER_PRIVATE_DATA_FROM_THIS (This);
-  ASSERT (Private != NULL);
 
   if ((Channel >= This->ChannelCount) || (SupportedModes == NULL) || (Device >= Private->DeviceCount)) {
     return EFI_INVALID_PARAMETER;
-- 
2.40.1


  parent reply	other threads:[~2023-06-01 17:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01 17:27 [PATCH v3 00/12] OvmfPkg: Replace the OVMF-specific SataControllerDxe with the generic one Pedro Falcato
2023-06-01 17:27 ` [PATCH v3 01/12] MdeModulePkg/SataControllerDxe: Clean up error handling in Start() Pedro Falcato
2023-06-01 17:27 ` [PATCH v3 02/12] MdeModulePkg/SataControllerDxe: Log expected errors at DEBUG_INFO level Pedro Falcato
2023-06-01 17:27 ` [PATCH v3 03/12] MdeModulePkg/SataControllerDxe: Remove useless null check Pedro Falcato
2023-06-01 17:27 ` Pedro Falcato [this message]
2023-06-01 17:27 ` [PATCH v3 05/12] OvmfPkg: Replace the OVMF-specific SataControllerDxe Pedro Falcato
2023-06-01 17:27 ` [PATCH v3 06/12] OvmfPkg/Microvm: " Pedro Falcato
2023-06-01 17:27 ` [PATCH v3 07/12] OvmfPkg/Bhyve: " Pedro Falcato
2023-06-01 17:27 ` [PATCH v3 08/12] OvmfPkg/CloudHv: " Pedro Falcato
2023-06-01 17:27 ` [PATCH v3 09/12] OvmfPkg/IntelTdx: " Pedro Falcato
2023-06-01 17:27 ` [PATCH v3 10/12] OvmfPkg/AmdSev: " Pedro Falcato
2023-06-01 17:27 ` [PATCH v3 11/12] OvmfPkg/Xen: " Pedro Falcato
2023-06-01 17:27 ` [PATCH v3 12/12] OvmfPkg: Remove SataControllerDxe Pedro Falcato
2023-06-01 18:09 ` [PATCH v3 00/12] OvmfPkg: Replace the OVMF-specific SataControllerDxe with the generic one 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=20230601172740.9165-5-pedro.falcato@gmail.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