[edk2-devel] [PATCH v2 03/12] MdeModulePkg/SataControllerDxe: Remove useless null check

Pedro Falcato posted 12 patches 2 years, 9 months ago
There is a newer version of this series
[edk2-devel] [PATCH v2 03/12] MdeModulePkg/SataControllerDxe: Remove useless null check
Posted by Pedro Falcato 2 years, 9 months ago
ASSERT (Private != NULL) already covers this check.
See commit 81310a6.

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>
Cc: Mike Maslenkin <mike.maslenkin@gmail.com>
Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
---
 .../Pci/SataControllerDxe/SataController.c    | 44 +++++++++----------
 1 file changed, 21 insertions(+), 23 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
index 277bc6182db6..f0ffd311d7b9 100644
--- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
+++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
@@ -626,34 +626,32 @@ SataControllerStop (
     return Status;
   }
 
-  if (Private != NULL) {
-    if (Private->DisqualifiedModes != NULL) {
-      FreePool (Private->DisqualifiedModes);
-    }
-
-    if (Private->IdentifyData != NULL) {
-      FreePool (Private->IdentifyData);
-    }
+  if (Private->DisqualifiedModes != NULL) {
+    FreePool (Private->DisqualifiedModes);
+  }
 
-    if (Private->IdentifyValid != NULL) {
-      FreePool (Private->IdentifyValid);
-    }
+  if (Private->IdentifyData != NULL) {
+    FreePool (Private->IdentifyData);
+  }
 
-    if (Private->PciAttributesChanged) {
-      //
-      // Restore original PCI attributes
-      //
-      Private->PciIo->Attributes (
-                        Private->PciIo,
-                        EfiPciIoAttributeOperationSet,
-                        Private->OriginalPciAttributes,
-                        NULL
-                        );
-    }
+  if (Private->IdentifyValid != NULL) {
+    FreePool (Private->IdentifyValid);
+  }
 
-    FreePool (Private);
+  if (Private->PciAttributesChanged) {
+    //
+    // Restore original PCI attributes
+    //
+    Private->PciIo->Attributes (
+                      Private->PciIo,
+                      EfiPciIoAttributeOperationSet,
+                      Private->OriginalPciAttributes,
+                      NULL
+                      );
   }
 
+  FreePool (Private);
+
   //
   // Close protocols opened by Sata Controller driver
   //
-- 
2.40.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104408): https://edk2.groups.io/g/devel/message/104408
Mute This Topic: https://groups.io/mt/98787856/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2 03/12] MdeModulePkg/SataControllerDxe: Remove useless null check
Posted by Wu, Hao A 2 years, 9 months ago
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>

Best Regards,
Hao Wu

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Pedro
> Falcato
> Sent: Wednesday, May 10, 2023 12:32 AM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek <lersek@redhat.com>; Pedro Falcato
> <pedro.falcato@gmail.com>; Wang, Jian J <jian.j.wang@intel.com>; Gao,
> Liming <gaoliming@byosoft.com.cn>; Wu, Hao A <hao.a.wu@intel.com>; Ni,
> Ray <ray.ni@intel.com>; Mike Maslenkin <mike.maslenkin@gmail.com>
> Subject: [edk2-devel] [PATCH v2 03/12] MdeModulePkg/SataControllerDxe:
> Remove useless null check
> 
> ASSERT (Private != NULL) already covers this check.
> See commit 81310a6.
> 
> 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>
> Cc: Mike Maslenkin <mike.maslenkin@gmail.com>
> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
> ---
>  .../Pci/SataControllerDxe/SataController.c    | 44 +++++++++----------
>  1 file changed, 21 insertions(+), 23 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> index 277bc6182db6..f0ffd311d7b9 100644
> --- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> +++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
> @@ -626,34 +626,32 @@ SataControllerStop (
>      return Status;
>    }
> 
> -  if (Private != NULL) {
> -    if (Private->DisqualifiedModes != NULL) {
> -      FreePool (Private->DisqualifiedModes);
> -    }
> -
> -    if (Private->IdentifyData != NULL) {
> -      FreePool (Private->IdentifyData);
> -    }
> +  if (Private->DisqualifiedModes != NULL) {
> +    FreePool (Private->DisqualifiedModes);
> +  }
> 
> -    if (Private->IdentifyValid != NULL) {
> -      FreePool (Private->IdentifyValid);
> -    }
> +  if (Private->IdentifyData != NULL) {
> +    FreePool (Private->IdentifyData);
> +  }
> 
> -    if (Private->PciAttributesChanged) {
> -      //
> -      // Restore original PCI attributes
> -      //
> -      Private->PciIo->Attributes (
> -                        Private->PciIo,
> -                        EfiPciIoAttributeOperationSet,
> -                        Private->OriginalPciAttributes,
> -                        NULL
> -                        );
> -    }
> +  if (Private->IdentifyValid != NULL) {
> +    FreePool (Private->IdentifyValid);
> +  }
> 
> -    FreePool (Private);
> +  if (Private->PciAttributesChanged) {
> +    //
> +    // Restore original PCI attributes
> +    //
> +    Private->PciIo->Attributes (
> +                      Private->PciIo,
> +                      EfiPciIoAttributeOperationSet,
> +                      Private->OriginalPciAttributes,
> +                      NULL
> +                      );
>    }
> 
> +  FreePool (Private);
> +
>    //
>    // Close protocols opened by Sata Controller driver
>    //
> --
> 2.40.1
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104725): https://edk2.groups.io/g/devel/message/104725
Mute This Topic: https://groups.io/mt/98787856/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v2 03/12] MdeModulePkg/SataControllerDxe: Remove useless null check
Posted by Laszlo Ersek 2 years, 9 months ago
On 5/9/23 18:32, Pedro Falcato wrote:
> ASSERT (Private != NULL) already covers this check.
> See commit 81310a6.
> 
> 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>
> Cc: Mike Maslenkin <mike.maslenkin@gmail.com>
> Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
> ---
>  .../Pci/SataControllerDxe/SataController.c    | 44 +++++++++----------
>  1 file changed, 21 insertions(+), 23 deletions(-)

Reviewed-by: Laszlo Ersek <lersek@redhat.com>




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104519): https://edk2.groups.io/g/devel/message/104519
Mute This Topic: https://groups.io/mt/98787856/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-